成长值: 63400
|
为了实现VLAN之间的互通,可以在设备上配置Vlanif接口,并在设备上启用路由功能。
组网需求
如图1所示,USG通过二层以太网接口下挂PC1和PC2,交接机通过二层以太网接口下挂PC3和PC4,USG通过三层接口Ethernet 0/0/0和交换机的二层接口Ethernet 0/0/1互联。要求PC1、PC2、PC3、PC4能够相互通信。
配置思路
1在USG上创建VLAN2,将接口Ethernet 1/0/1和Ethernet 1/0/2加入VLAN2,并配置接口Vlanif2的IP地址。
2在USG上配置Ethernet 0/0/0的IP地址为1.1.1.1,并配置到PC3和PC4所在网段130.1.1.0/24的路由,下一跳指向1.1.1.2。
3在交换机上创建VLAN3,将接口Ethernet 0/0/2和Ethernet 0/0/3加入VLAN3,并配置接口Vlanif3的IP地址。
4在交换机上创建VLAN100,将接口Ethernet 0/0/1加入VLAN100,并配置接口Vlanif100的IP地址为1.1.1.2。并配置到PC1和PC2所在网段120.1.1.0/24的路由,下一跳指向1.1.1.1。
5将PC1和PC2的默认网关配置为120.1.1.1,将PC3和PC4的默认网关配置为130.1.1.1。
操作步骤
配置USG。
# 创建VLAN2,向VLAN2中加入二层以太网接口Ethernet 1/0/1和Ethernet 1/0/2。
<USG> system-view
[USG] vlan 2
[USG-vlan-2] port interface Ethernet 1/0/1
[USG-vlan-2] port interface Ethernet 1/0/2
[USG-vlan-2] quit
# 创建Vlanif2接口,并配置Vlanif2的IP地址。
[USG] interface vlanif 2[USG-Vlanif2] ip address 120.1.1.1 24[USG-Vlanif2] quit
# 将Vlanif2接口加入Trust区域。
[USG] firewall zone trust
[USG-zone-trust] add interface Vlanif2
[USG-zone-trust] quit
# 配置和交换机互联的三层以太网接口Ethernet 0/0/0的IP地址。
[USG] interface Ethernet 0/0/0[USG-Ethernet0/0/0] ip address 1.1.1.1 24[USG-Ethernet0/0/0] quit
# 将接口Ethernet 0/0/0加入Trust区域。
[USG] firewall zone trust
[USG-zone-trust] add interface Ethernet 0/0/0
[USG-zone-trust] quit
# 配置到PC3和PC4所在网段130.1.1.0/24的路由,下一跳指向1.1.1.2。
[USG] ip route-static 130.1.1.0 255.255.255.0 1.1.1.2
配置交换机。
说明:
以下配置以Quidway S2300为例进行说明,实际应用中请参考对应交换机的相关文档。
# 创建VLAN3,将Ethernet 0/0/2和将Ethernet 0/0/3加入VLAN3。
[Switch] vlan 3
[Switch-Vlan3] quit
[Switch] interface ethernet 0/0/2
[Switch-Ethernet0/0/2] port link-type access
[Switch-Ethernet0/0/2] port default vlan 3
[Switch-Ethernet0/0/2] quit
[Switch] interface ethernet 0/0/3
[Switch-Ethernet0/0/3] port link-type access
[Switch-Ethernet0/0/3] port default vlan 3
[Switch-Ethernet0/0/3] quit
# 创建Vlanif3接口,并配置Vlanif3的IP地址。
[Switch] interface vlanif 3[Switch-Vlanif3] ip address 130.1.1.1 24[Switch-Vlanif3] quit
# 创建VLAN100,将Ethernet 0/0/1加入VLAN100。
[Switch] vlan 100
[Switch-Vlan100] quit
[Switch] interface ethernet 0/0/1
[Switch-Ethernet0/0/1] port link-type access
[Switch-Ethernet0/0/1] port default vlan 100
[Switch-Ethernet0/0/1] quit
# 创建Vlanif100接口,并配置Vlanif100的IP地址。
[Switch] interface vlanif 100[Switch-Vlanif100] ip address 1.1.1.2 24[Switch-Vlanif100] quit
# 配置到PC1和PC2所在网段120.1.1.0/24的路由,下一跳指向1.1.1.1。
[Switch] ip route-static 120.1.1.0 255.255.255.0 1.1.1.1
配置PC的IP地址和网关,PC1和PC2的默认网关为120.1.1.1,PC3和PC4的默认网关为130.1.1.1。
结果验证
配置完成后,检查VLAN2内的主机是否能够同VLAN3内的主机相互通信。
假设PC1的地址为120.1.1.2/24,PC3的地址为130.1.1.2/24,查看PC1能否ping通PC3。
C:\>ping 130.1.1.2
Pinging 130.1.1.2 with 32 bytes of data:
Reply from 130.1.1.2: bytes=32 time<1ms TTL=128
Reply from 130.1.1.2: bytes=32 time<1ms TTL=128
Reply from 130.1.1.2: bytes=32 time<1ms TTL=128
Reply from 130.1.1.2: bytes=32 time<1ms TTL=128
Ping statistics for 130.1.1.2 :
Packets: Sent = 4,Received =4,Lost = 0 <0% loss>,
Approximates round trip times in milli-seconds:
Minimum =0ms,Maximum =0ms,Average =0ms
|
|