问题原文
原帖链接 · root · CC BY-SA 3.0
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.
已采纳解答
原帖链接 · MadHatter · CC BY-SA 3.0
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
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
