网络拓扑图如下所示:
由上图可知,现在交换机上划分四个VLAN ,每个VLAN的接口地址如上图所示,现将交换机VLAN1接口与海蜘蛛路由LAN口相连,各VLAN通过VLAN1上网。
添加静态路由
“网络设置”->“静态路由”,添加静态路由如下图所示:
为VLAN网络加入NAT上网支持
默认情况下,只有和路由局域网IP在同一网段的机器才能上网。进入“网络设置”->“局域网 (LAN)”,在VLAN网络地址栏里添加三层交换上所划分的VLAN网络,如下:
此时,三层交换下的各VLAN网络里的客户机都可以通过路由联入互联网了。
注意 | |
---|---|
使用这种方法划分VLAN时,客户机的网关地址设置三层交换机上的VLAN接口IP地址。 |
重要 | |
---|---|
用此种方式划分内网VLAN,内网主机无论是否配置本地IP网关地址,都无法使用PPPoE拨号穿透三层交换机到路由。如果要PPPoE拨号穿透三层交换机,请参考在路由器上划分VLAN的解决方案参考 路由上划分VLAN |
这里以华为s3526c为例,配置如下:
# vlan 1 # vlan 2 # vlan 3 # vlan 4 # interface Vlan-interface1 ip address 172.16.1.1 255.255.255.0 # interface Vlan-interface2 ip address 172.16.2.1 255.255.255.0 # interface Vlan-interface3 ip address 172.16.3.1 255.255.255.0 # interface Vlan-interface4 ip address 172.16.4.1 255.255.255.0 # interface Aux0/0 # interface Ethernet0/1 flow-control # interface Ethernet0/2 flow-control # interface Ethernet0/3 # interface Ethernet0/4 # interface Ethernet0/5 # interface Ethernet0/6 # interface Ethernet0/7 port access vlan 2 # interface Ethernet0/8 port access vlan 2 # interface Ethernet0/9 port access vlan 2 # interface Ethernet0/10 port access vlan 2 # interface Ethernet0/11 port access vlan 2 # interface Ethernet0/12 port access vlan 2 # interface Ethernet0/13 port access vlan 3 # interface Ethernet0/14 port access vlan 3 # interface Ethernet0/15 port access vlan 3 # interface Ethernet0/16 port access vlan 3 # interface Ethernet0/17 port access vlan 3 # interface Ethernet0/18 port access vlan 3 # interface Ethernet0/19 port access vlan 4 # interface Ethernet0/20 port access vlan 4 # interface Ethernet0/21 port access vlan 4 # interface Ethernet0/22 port access vlan 4 # interface Ethernet0/23 port access vlan 4 # interface Ethernet0/24 port access vlan 4 # interface GigabitEthernet1/1 # interface NULL0 # ip route-static 0.0.0.0 0.0.0.0 172.16.1.2 preference 60