静态路由是指由用户或网络管理员手工配置的路由信息。当网络的拓扑结构或链路的状态发生变化时,网络管理员需要手工去修改路由表中相关的静态路由信息。静态路由信息在缺省情况下是私有的,不会传递给其他的路由器。当然,网管员也可以通过对路由器进行设置使之成为共享的。静态路由一般适用于比较简单的网络环境,在这样的环境中,网络管理员易于清楚地了解网络的拓扑结构,便于设置正确的路由信息。
实例
图:
目的:PC1与PC2通信
配置
R1:
1 2
| 添加PC3所在网段,以及下一条地址(下一条为对端接口地址) ip route-static 192.168.3.0 255.255.255.0 12.1.1.2
|
R2
1 2 3 4
| 添加PC3所在网段,以及下一条地址(下一条为对端接口地址) ip route-static 192.168.3.0 255.255.255.0 23.1.1.3 当然别忘了数据是双向的,需要有回包 ip route-static 192.168.1.0 255.255.255.0 12.1.1.1
|
R3
1 2
| 回包,PC1所在的网段,以及下一条地址 ip route-static 192.168.1.0 255.255.255.0 23.1.1.2
|
测试
热知识:在R1处 ping PC2 是不会通的 因为没有路由,需要指定源才能通
R1配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| [R1]dis cu [V200R003C00] # sysname R1 # snmp-agent local-engineid 800007DB03000000000000 snmp-agent # clock timezone China-Standard-Time minus 08:00:00 # portal local-server load flash:/portalpage.zip # drop illegal-mac alarm # wlan ac-global carrier id other ac id 0 # set cpu-usage threshold 80 restore 75 # aaa authentication-scheme default authorization-scheme default accounting-scheme default domain default domain default_admin local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$ local-user admin service-type http # firewall zone Local priority 15 # interface GigabitEthernet0/0/0 ip address 192.168.1.254 255.255.255.0 # interface GigabitEthernet0/0/1 ip address 12.1.1.1 255.255.255.0 # interface GigabitEthernet0/0/2 # interface NULL0 # ip route-static 192.168.3.0 255.255.255.0 12.1.1.2 # user-interface con 0 authentication-mode password user-interface vty 0 4 user-interface vty 16 20 # wlan ac # return
|
R2 配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| <R2>dis cu [V200R003C00] # sysname R2 # snmp-agent local-engineid 800007DB03000000000000 snmp-agent # clock timezone China-Standard-Time minus 08:00:00 # portal local-server load portalpage.zip # drop illegal-mac alarm # set cpu-usage threshold 80 restore 75 # aaa authentication-scheme default authorization-scheme default accounting-scheme default domain default domain default_admin local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$ local-user admin service-type http # firewall zone Local priority 15 # interface GigabitEthernet0/0/0 ip address 12.1.1.2 255.255.255.0 # interface GigabitEthernet0/0/1 ip address 23.1.1.2 255.255.255.0 # interface GigabitEthernet0/0/2 # interface NULL0 # ip route-static 192.168.1.0 255.255.255.0 12.1.1.1 ip route-static 192.168.3.0 255.255.255.0 23.1.1.3 # user-interface con 0 authentication-mode password user-interface vty 0 4 user-interface vty 16 20 # wlan ac # return
|
R3配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| <R3>dis cu [V200R003C00] # sysname R3 # snmp-agent local-engineid 800007DB03000000000000 snmp-agent # clock timezone China-Standard-Time minus 08:00:00 # portal local-server load portalpage.zip # drop illegal-mac alarm # set cpu-usage threshold 80 restore 75 # aaa authentication-scheme default authorization-scheme default accounting-scheme default domain default domain default_admin local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$ local-user admin service-type http # firewall zone Local priority 15 # interface GigabitEthernet0/0/0 ip address 23.1.1.3 255.255.255.0 # interface GigabitEthernet0/0/1 ip address 192.168.3.254 255.255.255.0 # interface GigabitEthernet0/0/2 # interface NULL0 # ip route-static 192.168.1.0 255.255.255.0 23.1.1.2 # user-interface con 0 authentication-mode password user-interface vty 0 4 user-interface vty 16 20 # wlan ac # return
|