In Linux, you can create a virtual network – aka. vlan. To create it you need to create a file under /etc/sysconfig/network-scripts/ directory.
For example, if you want to create a virtual network for eth0, you need to create a file something like below. Here I created with a tag 0.
$ cat /etc/sysconfig/network-scripts/ifcfg-eth0:0 DEVICE="eth0:0" BOOTPROTO=static IPADDR=172.16.0.1 NETMASK=255.255.255.0 NM_CONTROLLED="no"
If you does not use NetworkManager service, it is very easy. Just need to restart network service.
$ service network restart
But, if you try to use NetworkManager service, it fails to show this virtual network device properly.
To make it work properly, you need to create a dispatcher file like below.
$ cat /etc/NetworkManager/dispatcher.d/00-virtip #!/bin/bash iface="$1" shift action="$1" shift if [ "$action" = "up" ]; then for ALIAS in /etc/sysconfig/network-scripts/ifcfg-$iface:*; do ALIAS=`echo $ALIAS | cut -d: -f 2` if [ "$ALIAS" = '*' ]; then break fi /sbin/ifup $iface:$ALIAS done fi
This file should have a execution permission. So, set the permission like below and also restart network and NetworkManager service.
$ chmod a+x /etc/NetworkManager/dispatcher.d/00-virtip $ service network restart $ service NetworkManager restart
Now it will show you virtual network as well.