Virtual Interfaces

If you have only one Ethernet adapter on your machine with the IP address of, but you have a machine on that network segment with the IP address of, you are going to have a tough time communicating with the machine because your only network connection is on a different subnet than The only way to communicate with this machine is to set your IP address to a machine in the network. However, this is usually not an option as your connectivity to the outside world would probably be lost.

The quickest and easiest way to resolve this is to use a virtual interface. A virtual interface (also called a virtual adapter) is something you create and for all intents and purposes is seen as a new physical network interface. A virtual interface uses the physical connectivity of an existing network interface (in this case eth0) to be able to send and receive data. This does not affect the working of the main interface address (, and it enables you to send and receive network traffic to both subnets.

One of the most common reasons for using virtual interfaces is that you need your computer to receive network traffic on multiple addresses on the same subnet. For example, if you were testing a new mail infrastructure with a separate SMTP and IMAP server, you could set up a test infrastructure on one machine running both the SMTP and IMAP server, but have them listening on and, respectively. Using a virtual interface, you can test the connectivity from a desktop machine, and it seems, as far as the client machine is concerned, that the SMTP and IMAP services are running on separate machines.

To configure a virtual interface using ifconfig, you use exactly the same syntax as you do when setting up the IP address of eth0, with a slight twist. When specifying the network adapter to attach the virtual IP address to, you need to specify it in the form of realnet-workadapter:virtualinterface. So, for your first virtual adapter connected to eth0, you use eth0:1 .

bible:~ # ifconfig eth0:1 up

When the interface has been configured, you can then use it as you would any other real network interface you have on your system.

i: You can add an additional IP address to an interface using the ip command with a command line such as: ip addr add dev eth0.

Was this article helpful?

0 0

Post a comment