前面介绍了些关于网络设备的一些基础的认知,也了解到了网卡,网桥等基础,那这里开始了解下网桥的整体工作流程。这里写下swconfig的配置指令,已经vlan的参数简单认知。
一、 swconfig命令
以下是linux后台中的swconfig命令去配置vlan的划分,包括vlan id ,port id以及一些使用说明
swconfig list ; 列出可用的SWITCH设备信息(dev参数)
Found: switch0 - ag71xx-mdio.0
swconfig dev switch0 help ; 查询该设备信息
switch0: ag71xx-mdio.0(Atheros AR8337), ports: 7 (cpu @ 0), vlans: 128
--switch
Attribute 1 (int): enable_vlan (Enable VLAN mode)
Attribute 2 (none): reset_mibs (Reset all MIB counters)
Attribute 3 (int): enable_mirror_rx (Enable mirroring of RX packets)
Attribute 4 (int): enable_mirror_tx (Enable mirroring of TX packets)
Attribute 5 (int): mirror_monitor_port (Mirror monitor port)
Attribute 6 (int): mirror_source_port (Mirror source port)
Attribute 7 (string): arl_table (Get ARL table)
Attribute 8 (none): apply (Activate changes in the hardware)
Attribute 9 (none): reset (Reset the switch)
--vlan
Attribute 1 (int): vid (VLAN ID (0-4094))
Attribute 2 (ports): ports (VLAN port mapping)
--port
Attribute 1 (none): reset_mib (Reset single port MIB counters)
Attribute 2 (string): mib (Get port's MIB counters)
Attribute 3 (int): enable_eee (Enable EEE PHY sleep mode)
Attribute 4 (int): pvid (Primary VLAN ID)
Attribute 5 (string): link (Get port link information)
swconfig dev <dev> [port <port>|vlan <vlan>] (help|set <key> <value>|get <key>|load <config>|show) ;设置switch,port,vlan
swconfig dev switch0 show ;显示switch信息
1) swconfig dev switch0 show 显示switch信息
2) swconfig list 可以查看设备上有哪些switch桥
3)linux后台划分vlan的实例指令:
swconfig dev switch0 set enable_vlan 1
swconfig dev switch0 vlan 1 set vid 1
swconfig dev switch0 vlan 1 set ports \"0t 2 3 4 5\"
swconfig dev switch0 port 2 set pvid 1
swconfig dev switch0 port 3 set pvid 1
swconfig dev switch0 port 4 set pvid 1
swconfig dev switch0 port 5 set pvid 1
swconfig dev switch0 vlan 2 set vid 2
swconfig dev switch0 vlan 2 set ports \"0t 1\"
swconfig dev switch0 port 1 set pvid 2
4) 对应产看vlan和port id查看:
~# swconfig dev eth1 show
Global attributes:
enable_vlan: 1
Port 0:
pvid: 1
link: port:0 link:up speed:1000baseT full-duplex txflow rxflow
Port 1:
pvid: 1
link: port:1 link:down
Port 2:
pvid: 1
link: port:2 link:down
Port 3:
pvid: 1
link: port:3 link:down
Port 4:
pvid: 1
link: port:4 link:down
VLAN 1:
vid: 1
ports: 0 1 2 3 4
~# swconfig list
Found: switch0 - eth1
以上的指令参考到 : https://www.cnblogs.com/embedded-linux/p/8834613.html
二、基础参数和配置说明
vlan划分的一些参数。参考到以下的链接:
https://blog.csdn.net/weixin_33670713/article/details/85982817
https://www.icode9.com/content-4-994960.html
https://blog.csdn.net/qianguozheng/article/details/38326189
pvid 即端口vlan id号,是非标记端口的vlan id 设定,当非标记数据包进入交换机,交换机将检查vlan设定并决定是否进行转发。一个ip包进入交换机端口的时候,如果没有带tag头,且该端口上配置了pvid,那么,该数据包就会被打上相应的tag头!如果进入的ip包已经带有tag头(vlan数据)的话,那么交换机一般不会再增加tag头,即使是端口上配置了pvid号;当非标记数据包进入交换机。
vid 即vlan id; 1:vlan1(eth0.1); 2:vlan2(eth0.2);