Linux VLAN 实验

3200阅读 0评论2013-11-16 sungm1984
分类:LINUX

拓扑:



为了让实验不受影响,所以把selinux和iptables关了

配置 switch1:
配置eth0为trunk口,添加vlan10和vlan20


点击(此处)折叠或打开

  1. # modprobe 8021q
  2. # vconfig add eth0 10
  3. # vconfig add eth0 20
  4. # ifconfig eth0 0.0.0.0 up
  5. # ifconfig eth0.10 up
  6. # ifconfig eth0.20 up
  7. # brctl addbr brvlan10
  8. # brctl addif brvlan10 eth0.10
  9. # brctl addif brvlan10 eth1
  10. # brctl addbr brvlan20
  11. # brctl addif brvlan20 eth0.20
  12. # brctl addif brvlan20 eth2
  13. # ifconfig brvlan10 up
  14. # ifconfig brvlan20 up
  15. # ifconfig eth1 up
  16. # ifconfig eth2 up
同样在switch2上做以上配置

给pc1 和 pc2 配上地址
# ifconfig eth0 192.168.1.2/24 up
# ifconfig eth0 192.168.1.3/24 up




我们知道在二层范围内,pc1与pc3,pc4 pc2与pc3,pc4之间是无法通信的,所以要让他们通信,必须使其中一台switch具有路由的功能,
选择switch1具有路由功能
配置如下:

点击(此处)折叠或打开

  1. # echo 1 >/pro/sys/net/ipv4/ip_forward
  2. # ifconfig brvlan10 192.168.1.1/24 up
  3. # ifconfig brvlan20 192.168.2.1/24 up
为pc1 和 pc3配上网关

点击(此处)折叠或打开

  1. pc1
  2. # ip route add default via 192.168.1.1

  3. pc3
  4. # ifconfig eth0 192.168.2.2/24 up
  5. # ip route add default via 192.168.2.1


vlan 实验到此结束,有很多人会在cisco 交换机上配置,确不会在linux上配置vlan,可能是对vlan的本质还是不是特别清楚吧
开源的东西能让我们明白事实的真相。

上一篇:Linux日志滚动的两种方法
下一篇:cobbler之quick start