H3CIP地址配置举例

IP地址配置举例

1. 组网需求

Switch的端口(属于VLAN 1)连接一个局域网,局域网中的计算机分别属于2个网段:172.16.1.0/24和172.16.2.0/24。要求这两个网段的主机都可以通过Switch与外部网络通信,且这两个网段中的主机能够互通。

2. 组网图

图1-3 IP地址配置组网图

3. 配置步骤

针对上述的需求,如果在Switch的VLAN接口1上只配置一个IP地址,则只有一部分主机能够通过Switch与外部网络通信。为了使局域网内的所有主机都能够通过Switch访问外部网络,需要配置VLAN接口1的从IP地址。为了使两个网段中的主机能够互通,两个网段中的主机需要分别将Switch上VLAN接口1的主IP地址和从IP地址设置为网关。

# 配置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 # 在172.16.1.0/24网段中的主机上配置网关为172.16.1.1;在172.16.2.0/24网段中的主机上配置网关为172.16.2.1。

# 使用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 0.00% packet loss

round-trip min/avg/max = 25/25/26 ms

显示信息表示Switch与网络172.16.2.0/24内的主机可以互通。

# 使用ping命令检测网络172.16.1.0/24和网络172.16.2.0/24内主机的连通性。在Host A上可以ping通Host B。

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4