How Ubuntu builds virtual network card

  
                

The so-called virtual network card, that is, using software to simulate the network environment, simulate the network adapter, then how to build a virtual network card in Ubuntu? The following small series will introduce the method to everyone, I hope to help you.

If you have an understanding of network operations and IP networks, you should know that in most cases, each network card will only be assigned an IP address. We are used to thinking that this is a one-to-one thing.

A network card corresponds to an IP address. You can only bind or run a single network service/port on a network card and its IP address on one machine. For example, if you want to run a web server on port 80, an IP address and port number can only be listened to by a web server. This is how it is designed.

So, the network card and IP address are not one-to-one. You can create a virtual network card that can be assigned an IP address separately. Therefore, a single physical NIC can cluster unlimited subnet cards or virtual NICs. Each can assign its own IP address to the corresponding port.

This short tutorial will show you how to do this on Ubuntu. This is a great way to run and test multiple network services on a single computer with a single physical network card and a single port number.

Let's do it, run the following command to open the network interface file.

sudo gedit /etc/network/interfaces

Then follow the steps in the figure below to add as many virtual NICs as you want. By default, Linux assigns the first NIC the name of eth0, so if your machine has only one NIC, it will be named eth0.

Add a virtual NIC, create multiple static NICs and name them eth0:1, eth0:2, eth0:3, etc. (eth0 is followed by a colon and a number).

For every card you create, but also to ensure that the network is different subnets, which is a network of common sense (translation: not the case, the virtual card can be the same IP subnet Address, as long as you need)

After you finish, save the file and restart the network service with the following command.

sudo service networking restart

That's it!

The above method is to create a virtual network card Ubuntu introduced, because most systems have built-in virtual NIC, so no need to download and install, comes as no need to own the Internet to download and install.

Copyright © Windows knowledge All Rights Reserved