RedHat Linux 7.2怎么设置vlan(vconfig用不了)?

RedHat Linux 7.2怎么设置vlan(vconfig用不了)?,第1张

1.安装vlan(vconfig)和加载8021q模块

#aptitude install vlan

#modprobe 8021q

或:

#yum install vconfig

#modprobe 8021q

#lsmod |grep -i 8021q

2.使用linux vconfig命令配置vlan

#vconfig add eth0 100

#vconfig add eth0 200

在eth0接口上配置两个VLAN

#vconfig set_flag eth0.100 1 1

#vconfig set_flag eth0.200 1 1

设置VLAN的REORDER_HDR参数,默认就行了。

可以使用cat /proc/net/vlan/eth0.100查看eth0.100参数

#ifconfig eth0 0.0.0.0

#ifconfig eth0.100 192.168.100.50 netmask 255.255.255.0 up

#ifconfig eth0.200 192.168.200.50 netmask 255.255.255.0 up

配置网络信息

#vconfig rem eth0.100

#vconfig rem eth0.200

删除VLAN命令

3.将VLAN信息写入配置文件

#echo "modprobe 8021q">>/etc/rc.local

开机加载8021q模块,或者使用echo "8021q">>/etc/modules

#cp /etc/network/interfaces /etc/network/interfaces.default

#vim /etc/network/interfaces

auto lo eth0

iface lo inet loopback

iface eth0.100 inet static

address 192.168.100.50

netmask 255.255.255.0

iface eth0.200 inet static

address 192.168.200.50

netmask 255.255.255.0

此前 Arch Linux 用 vconfig 命令设置 VLANs ,该命令已被 ip 命令取代。下面的范例假定  网口  是 enp125s0f0, 名字  是 enp125s0f0.100 , vlan id  是 100。

用下列命令添加 VLAN 网口:

执行 ip link 命令确认 VLAN 已创建。

这个 VLAN 网口就像一个普通的物理网口,所有流经这个网口的数据包将被加上 VLAN tag 并流经它关联的物理网口(本例中的 enp125s0f0)。仅配置为相同 VLAN 的设备可接收这些数据包,否则将被丢弃。

 Using a  name  like enp125s0f0.100 is just convention and not enforcedyou can alternatively use enp125s0f0_100 or something descriptive like IPTV. To see the VLAN ID on an interface, in case you used an unconventional name:

The -d flag shows full details on an interface:

Now add an IPv4 address to the just created vlan link, and activate the link:

To cleanly shutdown the setting before you remove the link, you can do:

Removing a VLAN interface is significantly less convoluted

在enp8s0f1接口上配置两个VLAN

设置VLAN的REORDER_HDR参数,默认就行了。

配置网络信息

删除VLAN命令

开机加载8021q模块,或者使用


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/6171809.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-17
下一篇 2023-03-17

发表评论

登录后才能评论

评论列表(0条)

保存