静态路由原理 及实验案例

静态路由原理 及实验案例

静态路由一、静态路由1、回顾

静态路由 由管理员手动配置,并且是单向的缺乏灵活性默认路由(缺省路由) 一种特殊的静态路由当路由器在路由表中找不到目标网络的路由条 目时,路由器把请求转发到默认路由接口默认路由一般应用于末节网络2、静态路由配置

在路由器上添加路由条目语法:

代码语言:javascript复制Router(config)# ip route network mask {address | interface}

#network:目标网段 mask:目标网段的子网掩码 address:下一跳地址(下一个路由器的接口的IP地址) interface:发往下一跳路由器的本地接口举例:

代码语言:javascript复制Router(config)# ip route 192.168.2.0 255.255.255.0 192.168.7.2

Router(config)# ip route 192.168.2.0 255.255.255.0 f0/13、默认路由配置

在路由器上添加路由条目语法:

代码语言:javascript复制Router(config)# ip route 0.0.0.0 0.0.0.0 {address | interface}

#0.0.0.0 0.0.0.0 代表任意网络举例:

代码语言:javascript复制Router(config)# ip route 0.0.0.0 0.0.0.0 192.168.7.2

Router(config)# ip route 0.0.0.0 0.0.0.0 f0/14、查看路由条目

命令:

代码语言:javascript复制Router# show ip route

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP

D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

* - candidate default, U - per-user static route, o - ODR

P - periodic downloaded static route

Gateway of last resort is not set

10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C 10.10.10.0/24 is directly connected, FastEthernet0/1

L 10.10.10.10/32 is directly connected, FastEthernet0/1

172.16.0.0/24 is subnetted, 1 subnets

S 172.16.20.0/24 [1/0] via 10.10.10.100

192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks

C 192.168.1.0/24 is directly connected, FastEthernet0/0

L 192.168.1.254/32 is directly connected, FastEthernet0/0

#(C代表直连路由,S代表静态路由)5、路由器上配置DHCP

命令:

代码语言:javascript复制Router(config)#ip dhcp pool woniu

#定义地址池

Router(dhcp-config)#network 192.168.1.0 255.255.255.0 #定义客户端网段

Router(dhcp-config)#default-router 192.168.1.254 #定义客户端网关

Router(dhcp-config)#dns-server 114.114.114.114 #定义客户端获取的DNS

Router(dhcp-config)#exit

Router(config)#ip dhcp excluded-address 192.168.1.1-192.168.1.10 #定义排除地址二、实验案例1、静态路由配置案例

实验拓扑

10001 (10)实验要求

配置 PC0 与 PC1 进行通信实验步骤

根据图上标示,配置 PC 的 IP 地址及网关, 配置路由器接口地址在路由器0上添加静态路由条目在路由器1上添加静态路由条目实验脚本

image-20240404165500945代码语言:javascript复制//Router0

interface FastEthernet0/0

ip address 192.168.1.254 255.255.255.0

!

interface FastEthernet0/1

ip address 192.168.10.10 255.255.255.0

!

ip route 192.168.3.0 255.255.255.0 192.168.10.100

//Router1

interface FastEthernet0/0

ip address 192.168.3.254 255.255.255.0

!

interface FastEthernet0/1

ip address 192.168.10.100 255.255.255.0

!

ip route 192.168.1.0 255.255.255.0 192.168.10.10 2、默认路由配置案例

实验拓扑

10002 (8)实验要求

根据图上标示,配置 PC 的 IP 地址及网关, 配置路由器接口地址在路由器0上添加默认路由条目在路由器1上添加默认路由条目实验脚本

image-20240404170044547代码语言:javascript复制//Router0

interface FastEthernet0/0

ip address 192.168.1.254 255.255.255.0

!

interface FastEthernet0/1

ip address 192.168.2.254 255.255.255.0

!

interface Ethernet1/0

ip address 192.168.3.254 255.255.255.0

!

interface Ethernet1/1

ip address 20.10.10.10 255.255.255.0

!

ip route 0.0.0.0 0.0.0.0 20.10.10.100

//Router1

interface FastEthernet0/0

ip address 172.16.10.254 255.255.255.0

!

interface FastEthernet0/1

ip address 20.10.10.100 255.255.255.0

!

ip route 0.0.0.0 0.0.0.0 FastEthernet0/1 3、路由交换综合配置案例

实验拓扑

实验要求

根据图上标示,配置 PC 和交换机的 IP 地址 及网关,配置路由器接口地址在路由器0上添加静态路由在路由器1上添加默认路由在交换机0上配置telnet,使 PC2 可以 telnet 管理交换机0在路由器1上配置 SSH,使 PC0 和 PC1 可以 管理路由器1在路由器0上配置DHCP,使PC0和PC1可以 自动获取IP地址及网关及DNS实验脚本

image-20240404170811506代码语言:javascript复制//Switch0

interface Vlan1

ip address 192.168.1.100 255.255.255.0

!

ip default-gateway 192.168.1.254

!

line vty 0 4

login local

transport input telnet

//Router0

ip dhcp pool 1

network 192.168.1.0 255.255.255.0

default-router 192.168.1.254

dns-server 192.168.1.254

!

interface FastEthernet0/0

ip address 192.168.1.254 255.255.255.0

!

interface FastEthernet0/1

ip address 10.10.10.10 255.255.255.0

!

ip route 172.16.20.0 255.255.255.0 10.10.10.100

//Router1

hostname R1

!

enable secret 5 $1$mERr$/Q/mbs3O9oHsKR7rNG4e81

!

username pc0 secret 5 $1$mERr$/Q/mbs3O9oHsKR7rNG4e81

username pc1 secret 5 $1$mERr$H7PDxl7VYMqaD3id4jJVK/

!

ip domain-name pc0andpc1

!

interface FastEthernet0/0

ip address 172.16.20.254 255.255.255.0

!

interface FastEthernet0/1

ip address 10.10.10.100 255.255.255.0

!

ip route 0.0.0.0 0.0.0.0 10.10.10.10

!

line vty 0 4

login local

transport input sshimage-20240404171457303image-20240404171632091image-20240404171727506课后作业:10004 (5)配置静态路由,指定线路进行配 置自行规划 IP 地址,需要注意的是路由器连接 的是不同网段PC0到PC1走路由器1→路由器0→路由器2PC0到PC2走路由器1→路由器2PC1和PC2到PC0走路由器2→路由器0→路由 器1在路由器1上配置默认路由配置脚本

image-20240404171951630代码语言:javascript复制//Router1

interface FastEthernet0/0

ip address 192.168.1.254 255.255.255.0

!

interface FastEthernet0/1

ip address 10.10.20.10 255.255.255.0

!

interface FastEthernet1/0

ip address 10.10.10.10 255.255.255.0

!

ip route 192.168.3.0 255.255.255.0 10.10.10.100

ip route 192.168.2.0 255.255.255.0 10.10.20.100

//Router0

interface FastEthernet0/0

ip address 10.10.20.100 255.255.255.0

!

interface FastEthernet0/1

ip address 10.10.30.10 255.255.255.0

!

ip route 192.168.1.0 255.255.255.0 10.10.20.10

ip route 192.168.2.0 255.255.255.0 10.10.30.100

!

//Router2

interface FastEthernet0/0

ip address 192.168.2.254 255.255.255.0

!

interface FastEthernet0/1

ip address 192.168.3.254 255.255.255.0

!

interface Ethernet1/0

ip address 10.10.10.100 255.255.255.0

!

interface Ethernet1/1

ip address 10.10.30.100 255.255.255.0

!

ip route 192.168.1.0 255.255.255.0 10.10.30.10

相关推荐

军棋军棋
体育投注英超和欧冠

军棋军棋

⏱️ 01-21 👁️ 6512
动漫·同·人Vol7:同人Galgame的快乐做法(入门篇)
365bet官网中文网

动漫·同·人Vol7:同人Galgame的快乐做法(入门篇)

⏱️ 08-12 👁️ 4684
聊透联通腾讯大王卡哪些软件免流量:免流清单+避坑指南,看完少花冤枉钱
世界杯:英格兰首战遭挫1
bt365无法登陆

世界杯:英格兰首战遭挫1

⏱️ 09-23 👁️ 2547
成本降了 剧组扎堆
365bet官网中文网

成本降了 剧组扎堆

⏱️ 02-05 👁️ 2104
正式服:考古学灵魂鹿坐骑获取攻略 错过等半年
体育投注英超和欧冠

正式服:考古学灵魂鹿坐骑获取攻略 错过等半年

⏱️ 10-11 👁️ 8823