2、同样将eth2添加到VLAN3112中:
[root@test ~]# vconfig add eth2 3112
Added VLAN with VID == 3112 to IF -:eth2:-
3、检查添加的VLAN虚拟网卡信息:
[root@test ~]# cat/proc/net/vlan/config
VLAN Dev name | VLAN ID
Name-Type:VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
eth1.3111 | 3111 | eth1
eth2.3112 | 3112 | eth2
可以看到所有的VLAN虚拟网卡以及它们所归属的主物理网卡 。
(如果只有一个物理网卡,也可配置为文件ifcfg-eth1.3111和ifcfg-eth1.3112)
4、为VLAN虚拟网卡设定IP地址并且进行启用:
[root@test ~]# ifconfig eth1.3111 192.168.20.1 up
[root@test ~]# ifconfig eth2.3112 192.168.30.1 up
这是临时的,可以这样做
利用cp命令复制接口的ip地址配置
cp ifcfg-eth1 ifcfg-eth1.3111
cp ifcfg-eth2 ifcfg-eth2.3112
把ifcfg-eth1和ifcfg-eth2中的原有地址去掉,再vi修改ifcfg-eth1.3111和ifcfg-eth2.3112文件,设置IP地址等信息 。
5、最后重启network服务,令配置生效 。
重新启动网络服务
[root@test ~]# service network restart
Shutting down interface eth1: [ OK ]
Shutting down interface eth2: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth1: [ OK ]
Bringing up interface eth2: [ OK ]
6、检查Linux系统下的所有网络接口信息:
[root@test ~]# ifconfig |more
到这里已经基本上将VLAN的主要配置完成了 。
7、验证连通性
[root@test ~]# ping 192.168.20.254
PING 192.168.20.254 (192.168.20.254) 56(84) bytes of data.
64 bytes from 192.168.20.254: icmp_seq=1 ttl=255 time=8.42 ms
64 bytes from 192.168.20.254: icmp_seq=2 ttl=255 time=1.47 ms
64 bytes from 192.168.20.254: icmp_seq=3 ttl=255 time=1.51 ms
64 bytes from 192.168.20.254: icmp_seq=4 ttl=255 time=1.58 ms
^C
--- 192.168.20.254 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 6325ms
rtt min/avg/max/mdev = 1.470/2.550/8.427/2.400 ms
[root@test ~]# ping 192.168.30.254
PING 192.168.30.254 (192.168.30.254) 56(84) bytes of data.
64 bytes from 192.168.30.254: icmp_seq=1 ttl=255 time=8.42 ms
64 bytes from 192.168.30.254: icmp_seq=2 ttl=255 time=1.47 ms
64 bytes from 192.168.30.254: icmp_seq=3 ttl=255 time=1.51 ms
64 bytes from 192.168.30.254: icmp_seq=4 ttl=255 time=1.58 ms
^C
--- 192.168.30.254 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 6325ms
rtt min/avg/max/mdev = 1.470/2.550/8.427/2.400 ms
【Linux网卡的Vlan配置,你可能不了解的玩法】
推荐阅读
- 检测TCP/UDP端口的连通性
- 淘宝开店怎么开的怎么注册 开淘宝店怎么注册账号
- 传说中的水鬼 真的有水鬼的存在吗
- spring源码深度解析—容器的基本实现,你知多少?
- 幽室恐惧症 幽闭恐惧症治疗的方法有哪些
- seo是一场智慧和力量的博弈
- 梦见凶猛的狗咬自己 梦见凶猛的狗咬别人,被我赶跑了
- APP应用的安全保护指南
- 关于SEO链接结构的10大谎言
- 沈培平谈人们对普洱茶的质疑有三大好处