大网数据广告活动
服务器运维问答

how to connect linux/centos machine to trunk port

· 52CE 我爱测

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.

问题原文

原帖链接 · 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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-11-28)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。