H3C交换机配置-如何实现两个网段主机与外部通信1 下载本文

内容发布更新时间 : 2024/5/24 1:08:35星期一 下面是文章的全部内容请认真阅读。

H3C交换机配置-如何实现两个网段主机与外部通信

很多朋友多次提到交换机的配置,提到如何实现两个网段主机与外部通信,这个是非常常见的交换机配置,这里面我们就用H3C的配置来了解下这个过程。

如图1所示,在两个网络中的主机上采用交换机配置的主IP地址和从IP地址作为网关,实现两个网段的主机都可以通过Switch与外部网络通信。

图1 IP地址配置组网图

一、配置方法步骤

1. Switch的配置

# 配置VLAN接口1的主IP地址和从IP地址。

system-view

[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

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

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