Linux – how to connect linux/centos machine to trunk port

centoslinuxlinux-networkingnetworkingvlan

I'm trying to connect Centos7 Machine to trunk port, which is having multiple vlan tagged. How do i add multiple ips single ethernet or how to define vlan id for specific subnet.

Best Answer

In Linux, VLAN tagging is handled with subinterfaces according to the naming scheme ifX.N, where ifX is interface X and N is the VLAN ID. So, if you are attached to this switch via interface eth0, traffic to/from VLAN 10 will appear on eth0.10, and traffic to/from VLAN25 will appear on eth0.25.

You will need to create the subinterfaces, with eg

ifconfig eth0.10 192.168.10.1 netmask 255.255.255.0 up

This can be automated in CentOS with a file such as

[me@bill ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eth0.10
VLAN=yes
DEVICE=eth0.10
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.10.1
NETMASK=255.255.255.0
IPV6INIT=yes
IPV6ADDR=2001:db8:6049:10::1/64