'ip静态路由'
ip静态路由
网络拓扑图
基础
命令的格式一般是ip route-static 目的网络 掩码 网关 preference 优先级 。
报文传递流程:
R1路由端口ip配置
为GigabitEthernet0/0/0 端口配置ip:192.168.1.1
为GigabitEthernet0/0/1 端口配置ip:192.168.4.1
interface GigabitEthernet0/0/0
ip address 192.168.1.1 255.255.255.0
interface GigabitEthernet0/0/1
ip address 192.168.4.1 255.255.255.0
R1路由静态ip配置
ip route-static 192.168.2.0 255.255.255.0 192.168.4.2
ip route-static 192.168.3.0 255.255.255.0 192.168.4.2
解释:ip route-static 目的网段 子网掩码 下一跳地址
(我的理解就是 如果你要去找192.168.2.2这个ip,我应该发信息发送给192.168.4.2。而192.168.4.2这个ip就是路由R2 与R1路由相连端口的ip)
详细配置
sys后直接复制粘贴改代码就好了
R1路由的配置
interface GigabitEthernet0/0/0
ip address 192.168.1.1 255.255.255.0
quit
interface GigabitEthernet0/0/1
ip address 192.168.4.1 255.255.255.0
quit
ip route-static 192.168.2.0 255.255.255.0 192.168.4.2
ip route-static 192.168.3.0 255.255.255.0 192.168.4.2
R2路由的配置
interface GigabitEthernet0/0/0
ip address 192.168.4.2 255.255.255.0
quit
interface GigabitEthernet0/0/1
ip address 192.168.6.1 255.255.255.0
quit
interface GigabitEthernet0/0/2
ip address 192.168.5.1 255.255.255.0
quit
ip route-static 192.168.1.0 255.255.255.0 192.168.4.1
ip route-static 192.168.2.0 255.255.255.0 192.168.6.2
ip route-static 192.168.3.0 255.255.255.0 192.168.5.2
R4路由
interface GigabitEthernet0/0/1
ip address 192.168.5.2 255.255.255.0
quit
interface GigabitEthernet0/0/2
ip address 192.168.3.1 255.255.255.0
ip route-static 192.168.1.0 255.255.255.0 192.168.5.1
ip route-static 192.168.2.0 255.255.255.0 192.168.5.1