Ip unnumbered 命令、配置
“借用IP地址”实际就是:一个接口上没有配置IP地址,但是还想使用该接口。就向其它有IP地
址的接口借一个IP地址来。如果被借用接口有多个IP地址,只能借来主IP地址。如果被借用接口没有
IP地址,则借用接口的IP地址为0.0.0.0。该功能通过Ip unnumbered命令来实现。
例子:
loopback0 1.1.1.1/24<------>R1<-s2/1--------PPP----------s2/1->R2<---------->loopback0 2.2.2.2/24
实验说明:
通过二层PPP封装可以实现地址借用,地址借用可节省可用IP地址,本实验R1,R2 串口不配地址,通过ppp封装,可借用内网IP地址,loopback口模拟内网。
实验要求:
通过借用地址让两台路由器之间可正常通信。
实验过程:
第一步:配置R1R2预配置
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hos R1
R1(config)#no ip domain-loo
R1(config)#line con 0
R1(config-line)#no exec-t
R1(config-line)#logg syn
R1(config-line)#end
R1#
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hos R2
R2(config)#no ip domain-loo
R2(config)#line con 0
R2(config-line)#no exec-t
R2(config-line)#logg syn
R2(config-line)#end
R2#
第二步:配置内网接口地址and封装串口与地址借用
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int loo 0
R1(config-if)#
R1(config-if)#ip add 1.1.1.1 255.255.255.0 //模拟内网地址
R1(config-if)#exi
R1(config)#int s 2/1
R1(config-if)#en ppp //封装接口地址ppp
R1(config-if)#
R1(config-if)#ip unn
R1(config-if)#ip unnumbered loo 0 //借用内网loopback地址
R1(config-if)#no sh
R1(config-if)#end
R1#
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int loo 0
R2(config-if)#ip add 2.2.2.2 255.255.255.0
R2(config-if)#exi
R2(config)#int s 2/1
R2(config-if)#en ppp
R2(config-if)#ip unn
R2(config-if)#ip unnumbered l
*Jul 18 14:38:00.579: %LINEPROTO-5-UPDOWN: Line protocol on interface Serial2/1, changed state to up
R2(config-if)#ip unnumbered loo 0
R2(config-if)#
第三步:查看接口并测试
R1#sh run int s 2/1
Building configuration...
Current configuration : 95 bytes
!
interface Serial2/1
ip unnumbered Loopback0
encapsulation ppp
serial restart-delay 0
end
R2#sh run int s 2/1
Building configuration...
Current configuration : 95 bytes
!
interface Serial2/1
ip unnumbered Loopback0
encapsulation ppp
serial restart-delay 0
end
R1#sh ip int b
Interface IP-Address OK? Method Status Protocol FastEthernet0/0 unassigned YES unset administratively down down Serial2/0 unassigned YES unset administratively down down Serial2/1 1.1.1.1 YES TFTP up up Serial2/2 unassigned YES unset administratively down down Serial2/3 unassigned YES unset administratively down down Serial3/0 unassigned YES unset administratively down down Serial3/1 unassigned YES unset administratively down down Serial3/2 unassigned YES unset administratively down down Serial3/3 unassigned YES unset administratively down down Loopback0 1.1.1.1 YES manual up up
//可以看出串口地址借用的是内网loopback地址
第四步:ping测试R1 R2之间的连通性
R1#ping 2.2.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 40/72/116 ms
//连通性正常
IP unnumbered配置
一般而言,每个逻辑接口都要配置一个独立的IP,然而IOS是支持在串行接口(点到点)配置IP unnumbered 命令,这个命令的作用可以使串行接口,“借用”另外一个接口的IP,作用是节省IP地址分配,在实际中,见于拨号网络的接入设备,因访问服务器同时给很多个用户拨入,如果每个用户对应的接口都要IP地址的话,配置管理任务较多,而且需耗费较多IP地址。
R2 (config)#interface loopback 0
R2 (config-if)#ip address 2.2.2.2 255.255.255.0
R2 (config-if)#no shut
R2 (config-if)#interface serial 1
R2 (config-if)#ip unnumbered loopback 0
R1(config)#interface loopback 0
R1(config-if)#ip add
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R1(config-if)#interface serial 1
R1(config-if)#ip unnumbered loopback 0
R1(config-if)#clock rate 64000
以上配置已经使R1和R2连接同步串行接口借用了各自环回口IP地址,注意,以太网接口时无法借用IP的:
R1(config)#interface ethernet 0
R1(config-if)#ip unnumbered loopback 0
Point-to-point (non-multi-access) interfaces only
在这种配置下,可以查看接口IP情况如下:
Serial1 is up, line protocol is up
Hardware is HD64570
Interface is unnumbered. Using address of Loopback0 (1.1.1.1)
R2#show interfaces serial 1
Serial1 is up, line protocol is up
Hardware is HD64570
Interface is unnumbered. Using address of Loopback0 (2.2.2.2)
接下来,我们验证在,无编号(ip unnumbered)接口运行路由
协议
离婚协议模板下载合伙人协议 下载渠道分销协议免费下载敬业协议下载授课协议下载
的情况:
(1)RIP
R1(config)#router rip
R1(config-router)#network 1.0.0.0
R2#show ip route
Codes: 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