UPDATED for CentOS 7:
CentOS 7 multiple VLANs on one interface
The scenario I had was 1 eth0 device, and my port trunk’d to allow 9 and 10 vlans. I wanted to assign the full /24 to this box, using only eth0 and the trunk port in CentOS 6. This is what I had to do.
in linux NEED eth0 and one VLAN’d CFG:
cd /etc/sysconfig/network-scripts/
ifcfg-eth0.9 the .9 is the vlan
# Broadcom Corporation NetXtreme BCM5721 Gigabit Ethernet PCI Express
DEVICE=eth0.9
BOOTPROTO=none
HWADDR=00:1d:xx:xx:xx:xx
ONBOOT=yes
TYPE=Ethernet
IPADDR=173.243.116.2
NETMASK=255.255.255.0
VLAN=yes
ifcfg-eth0.10
# Broadcom Corporation NetXtreme BCM5721 Gigabit Ethernet PCI Express
DEVICE=eth0.10
BOOTPROTO=none
HWADDR=00:1d:xx:xx:xx:xx
ONBOOT=yes
TYPE=Ethernet
IPADDR=173.243.117.2
NETMASK=255.255.255.0
VLAN=yes
ifcfg-eth0
# Broadcom Corporation NetXtreme BCM5721 Gigabit Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:1d:xx:xx:xx:xx
ONBOOT=yes
TYPE=Ethernet
ifcfg-eth0.9-range0
IPADDR_START=173.243.116.3
IPADDR_END=173.243.116.254
NETMASK=255.255.255.0
CLONENUM_START=3
ifcfg-eth0.11-range0
IPADDR_START=199.96.80.3
IPADDR_END=199.96.80.254
NETMASK=255.255.255.0
CLONENUM_START=257
******************************************************************************************
CENTOS 6 REQUIRES NO GATEWAY in ifcfg-eth0.xx so remove it
CENTOS 6 REQUIRES ROUTES ADDED:
You can do this to test, as once the server is rebooted, or network restarted these rules drop:
ip route add default via 192.119.164.1 dev eth0.8 table 1
ip route add default via 192.119.165.1 dev eth0.9 table 2
ip rule add from 192.119.164.2 tab 1 priority 500
ip rule add from 192.119.165.2 tab 2 priority 501
ip rule add from 192.119.164.0/24 table 1
ip rule add from 192.119.165.0/24 table 2
To make it permanent:
cd /etc/sysconfig/network-scripts/
echo ‘default via 192.119.169.1 dev eth0.3 table 1’ > route-eth0.3
echo ‘default via 192.119.174.1 dev eth0.6 table 2’ > route-eth0.6
echo ‘from 192.119.169.2 tab 1 priority 500’ > rule-eth0.3
echo ‘from 192.119.174.2 tab 2 priority 501’ > rule-eth0.6
echo ‘from 192.119.169.0/24 table 1’ > rule-eth0.3
echo ‘from 192.119.174.0/24 table 2’ > rule-eth0.6
******************************************************************************************