首页 > 编程知识 正文

2个路由器静态路由配置,策略路由和静态路由的区别

时间:2023-05-05 14:33:14 阅读:56321 作者:163

静态路由1,相关概念

1 .静态路由的优点(1) .不需要动态路由协议,减少了路由器的日常开销; )2) .在小型网络中容易配置(3) .可以控制路由; )4) .安全性高,网络管理员可以指定有限的网络划分中哪些可以公开,哪些可以隐藏。

二、简单例子

1、拓扑:

2、设置主机IP地址

这是PC0设置,其他主机也是如此

34 .配置路由

路由器1(R1)

Routeren

Router#conf t

Enter configuration commands,one per line. End with CNTL/Z。

router (配置) #host

(router(config ) #hostname R1 )改名: R1 ) ) ) ) ) ) ) ) )

R1 (配置) #int

R1 (配置) #接口G0/1

R1 (配置- if ) # iip添加

R1 (配置- if ) #ip addr

R1 (配置- if ) # IP地址192.168.1.254255.255.255.0

R1(config-if ) #no shut

R1(config-if ) #no shutdown

R1 (配置- if ) #

% link-5-changed :接口千兆以太网0/1,changed state to up

% line proto-5-up down : lineprotocoloninterfacegigabitethernet0/1,changed state to up

R1 (配置- if ) #exit

R1(config ) #int g

R1 (配置) # int千兆以太网0/0

R1 (配置- if ) # IP添加

R1 (配置- if ) # IP地址192.168.12.1255.255.255.0

R1(config-if ) #否s

R1 (配置- if ) #no sh

R1(config-if ) #no shutdown

R1 (配置- if ) #

% link-5-changed :接口千兆以太网0/0,changed state to up

R1 (配置- if ) #exit

路由器2(R1):

Routeren

Router#conf t

Enter configuration commands,one per line. End with CNTL/Z。

router (配置) #host

路由器(config ) #hostname R2

R2(config ) #int g

R2 (配置) # int千兆以太网0/1

R2 (配置- if ) # IP添加

R2 (配置- if ) # IP地址192.168.2.254255.255.255.0

R2 (配置- if ) #否墅

R2(config-if ) #no shutdown

R2 (配置- if ) #

% link-5-changed :接口千兆以太网0/1,changed state to up

% line proto-5-up down : lineprotocoloninterfacegigabitethernet0/1,changed state to up

R2 (配置- if ) #ex

R2 (配置- if ) #exit

R2(config ) #int g

R2 (配置) # int千兆以太网0/0

R2 (配置- if ) # IP添加

配置# IP地址192.168.12.2255.255.255.0

R2 (配置- if ) #no sh

R2(config-if ) #no shutdown

R2 (配置- if ) #

% link-5-changed :接口千兆以太网0/0,changed state to up

% line proto-5-up down : lineprotocoloninterfacegigabitethernet0/0,changed state to up

R2 (配置- if ) #ex

R2 (配置- if ) #exit

4、配置静态路由(简单拓扑) ) ) )。

R1 (配置) # IP路由192.168.2.0255.255.0192.168.12.2

第一个ip地址是目标网段,第二个掩码第三个是下一跳

R2 (配置) # IP route 192.168.1.0255.255.0192.168.12.1

即使现在准备好了,也可以在命令: show ip route中显示路由信息

R1#show ip route (必须处于特权用户模式) ) ) ) ) ) ) )。

代码: l-local,C - connected,S - static,R - RIP,M - mobile,B - BGP

D - EIGRP,D - EIGRP外部,O - OSPF,IA - OSPF inter area

n1-OSPF nssa外部类型1,N2-OSPF nssa外部类型2

E1-OSPF外部类型1,E2-OSPF外部类型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-periodicdownloadedstaticroute

网关of last resort is not set

192.168.1.0/24 isvariablysubnetted,2 subnets,2 masks6

c 192.168.1.0/24 isdirectlyconnected,千兆以太网0/1

l 192.168.1.254/32 isdirectlyconnected,千兆以太网0/1

s 192.168.2.0/24 [1/0] via 192.168.12.265http://www.Sina.com/)

192.168.12.0/24 isvariablysubnetted,2 subnets,2 masks

c 192.168.12.0/24 isdirectlyconnected,千兆以太网0/0

l 192.168.12.1/32 isdirectlyconnected,千兆以太网0/0

5、验证结果

ping到不同网段的主机

如图所示ping pc0 (192.168.1.1 ) PC0(192.168.1.1 )

开始丢两个包是很正常的

结果,配置正确,萍通了!

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。