H3C交换机配置-如何实现两个网段主机与外部通信
很多朋友多次提到交换机的配置,提到如何实现两个网段主机与外部通信,这个是非常常见的交换机配置,这里面我们就用H3C的配置来了解下这个过程。
如图1所示,在两个网络中的主机上采用交换机配置的主IP地址和从IP地址作为网关,实现两个网段的主机都可以通过Switch与外部网络通信。
图1 IP地址配置组网图
一、配置方法步骤
1. Switch的配置
# 配置VLAN接口1的主IP地址和从IP地址。
[Switch] interface vlan-interface 1
[Switch-Vlan-interface1] ip address 172.16.1.1 255.255.255.0 [Switch-Vlan-interface1] ip address 172.16.2.1 255.255.255.0 sub [Switch-Vlan-interface1] return
2. 主机的配置
# 在172.16.1.0/24网段中的主机上配置网关为172.16.1.1;在172.16.2.0/24网段中的主机上配置网关为172.16.2.1。
3、验证配置
# 使用ping命令检测Switch与网络172.16.1.0/24内主机的连通性。
PING 172.16.1.2: 56 data bytes, press CTRL_C to break
Reply from 172.16.1.2: bytes=56 Sequence=1 ttl=255 time=25 ms Reply from 172.16.1.2: bytes=56 Sequence=2 ttl=255 time=27 ms Reply from 172.16.1.2: bytes=56 Sequence=3 ttl=255 time=26 ms Reply from 172.16.1.2: bytes=56 Sequence=4 ttl=255 time=26 ms
Reply from 172.16.1.2: bytes=56 Sequence=5 ttl=255 time=26 ms
--- 172.16.1.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss
round-trip min/avg/max = 25/26/27 ms
显示信息表示Switch与网络172.16.1.0/24内的主机可以互通。
# 使用ping命令检测Switch与网络172.16.2.0/24内主机的连通性。
PING 172.16.2.2: 56 data bytes, press CTRL_C to break
Reply from 172.16.2.2: bytes=56 Sequence=1 ttl=255 time=25 ms Reply from 172.16.2.2: bytes=56 Sequence=2 ttl=255 time=26 ms Reply from 172.16.2.2: bytes=56 Sequence=3 ttl=255 time=26 ms Reply from 172.16.2.2: bytes=56 Sequence=4 ttl=255 time=26 ms Reply from 172.16.2.2: bytes=56 Sequence=5 ttl=255 time=26 ms
--- 172.16.2.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 25/25/26 ms
显示信息表示Switch与网络172.16.2.0/24内的主机可以互通。
4、配置文件
#
interface Vlan-interface1
ip address 172.16.1.1 255.255.255.0 ip address 172.16.2.1 255.255.255.0 sub #
二、举例
允许发送定向广播报文典型配置举例
如图2所示,Host通过网关Switch,将定向广播发往Server所在的网段,通过在交换机上配置允许发送定向广播报文,使得Server可以收到报文。
图2 允许发送定向广播报文配置组网图
配置步骤
1、配置Switch的配置
# 创建VLAN2,并将端口GigabitEthernet1/0/1加入到VLAN2中。
[Switch-vlan2] port GigabitEthernet 1/0/1 [Switch-Vlan2] quit
# 创建VLAN3,并将端口GigabitEthernet1/0/2加入到VLAN3中。 [Switch] Vlan 3
[Switch-vlan3] port GigabitEthernet 1/0/2 [Switch–Vlan3] quit
# 配置VLAN接口3和VLAN接口2的IP地址。 [Switch] interface vlan-interface 3
[Switch-Vlan-interface3] ip address 1.1.1.2 24 [Switch-Vlan-interface3] quit [Switch] interface vlan-interface 2
[Switch-Vlan-interface2] ip address 2.2.2.2 24
H3C交换机配置-如何实现两个网段主机与外部通信1



