学习路由表(静态路由)
如下图的拓扑图;
设置各个路由的ip地址
R1: eth0:192.168.0.2
R2: eth0:192.168.0.3
R2:eth1:10.10.10.1
R5:eth0:10.10.10.2
谁要ping通谁,地址设置:
要求:
(1)登录到R1:ping 10.10.10.2
(2)登录到 R5: ping 192.168.0.2
写路由表:
R1:192.168.0.0/24 192.168.0.3/32
R2:192.168.0.0/24 192.168.0.2/32 10.10.10.0/24 10.10.10.2/32
R3:10.10.10.0/24 10.10.10.1/32
问题:网络路由是寻找下一跳的,那么我们怎么设置ip route-static呢! IP route=static 目的地址,32,网关
其中的网关就是根据路由表来设置的。
R1设置
[Huawei]display this
#
sysname Huawei
#
ip route-static 10.10.10.2 255.255.255.255 192.168.0.3
#
return
[Huawei]in
[Huawei]inter
[Huawei]interface Eth
[Huawei]interface Ethernet0/0/0
[Huawei-Ethernet0/0/0]
[Huawei-Ethernet0/0/0]dis
[Huawei-Ethernet0/0/0]display th
[Huawei-Ethernet0/0/0]display this
#
interface Ethernet0/0/0
ip address 192.168.0.2 255.255.255.0
#
return
[Huawei-Ethernet0/0/0]
[Huawei-Ethernet0/0/0]q
[Huawei]
[Huawei]
[Huawei]ping 10.10.10.2
PING 10.10.10.2: 56 data bytes, press CTRL_C to break
Reply from 10.10.10.2: bytes=56 Sequence=1 ttl=254 time=60 ms
Reply from 10.10.10.2: bytes=56 Sequence=2 ttl=254 time=30 ms
Reply from 10.10.10.2: bytes=56 Sequence=3 ttl=254 time=50 ms
Reply from 10.10.10.2: bytes=56 Sequence=4 ttl=254 time=60 ms
Reply from 10.10.10.2: bytes=56 Sequence=5 ttl=254 time=70 ms
--- 10.10.10.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/54/70 ms
R2 设置
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]
[Huawei]inter
[Huawei]interface Ether
[Huawei]interface Ethernet0/0/0
[Huawei-Ethernet0/0/0]displ
[Huawei-Ethernet0/0/0]display thi
[Huawei-Ethernet0/0/0]display this
#
interface Ethernet0/0/0
ip address 192.168.0.3 255.255.255.0
#
return
[Huawei-Ethernet0/0/0]q
[Huawei]interface Ethernet0/0/1
[Huawei-Ethernet0/0/1]display this
#
interface Ethernet0/0/1
ip address 10.10.10.1 255.255.255.0
#
return
[Huawei-Ethernet0/0/1]
R5 设置:
-
<Huawei>system-view Enter system view, return user view with Ctrl+Z. [Huawei]display this # sysname Huawei # ip route-static 192.168.0.2 255.255.255.255 10.10.10.1 # return [Huawei]interface Ether [Huawei]interface Ethernet0/0/0 [Huawei-Ethernet0/0/0]display th [Huawei-Ethernet0/0/0]display this # interface Ethernet0/0/0 ip address 10.10.10.2 255.255.255.0 # return [Huawei-Ethernet0/0/0]q [Huawei]ping 192.168.0.2 PING 192.168.0.2: 56 data bytes, press CTRL_C to break Reply from 192.168.0.2: bytes=56 Sequence=1 ttl=254 time=80 ms Reply from 192.168.0.2: bytes=56 Sequence=2 ttl=254 time=60 ms Reply from 192.168.0.2: bytes=56 Sequence=3 ttl=254 time=60 ms Reply from 192.168.0.2: bytes=56 Sequence=4 ttl=254 time=60 ms Reply from 192.168.0.2: bytes=56 Sequence=5 ttl=254 time=40 ms --- 192.168.0.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 40/60/80 ms [Huawei]
写路由表:
R1:Ethernet0/0/0 192.168.0.2
R2:Ethernet0/0/0 192.168.0.4
R2:Ethernet0/0/1 10.10.10.1
R5:Ethernet0/0/0 10.10.10.3
R5:Ethernet0/0/1 1.1.1.2
R7:Ethernet0/0/1 1.1.1.5
根据上面的ip 写出上面图的路由表以及他的路由设置。
R1:192.168.0.0/24 192.168.0.3/32
R2:192.168.0.0/24 192.168.0.2/24 10.10.10.2/32 10.10.10.0/24
R5:10.10.10.0/24 10.10.10.1/32 1.1.1.4/32 1.1.1.0/24
R7:1.1.1.0/24 1.1.1.2/32
设置路由:
r1设置:
ip route-static 192.168.0.3 255.255.255.255 1.1.1.4
r2:设置:
ip route-static 10.10.10.2 255.255.255.255 1.1.1.4
r5设置:
ip route-static 10.10.10.1 255.255.255.255 192.168.0.2
r7设置:
ip route-static 1.1.1.2 255.255.255.255 192.168.0.2