本文档介绍无编号 IP 的概念,并提供几个配置示例以供参考。通过 ip unnumbered 配置命令,您可以在串行接口上启用 IP 处理,而无需为该接口分配明确的 IP 地址。无编号的 IP 接口可以“借用”路由器上已经配置的另一个接口的 IP 地址,以节约网络和地址空间。
本文档没有任何特定的要求。
本文档不限于特定的软件和硬件版本。
有关文档规则的详细信息,请参阅 Cisco 技术提示规则。
请考虑下面列出的网络。路由器 A 有一个串行接口 S0 和一个以太网接口 E0。
路由器 A 的 Ethernet 0 接口可以配置为下面显示的 IP 地址:
interface Ethernet0 ip address 172.16.10.254 255.255.255.0
从逻辑上来说,要在接口 S0 上启用 IP,您需要在此接口上配置一个唯一的 IP 地址。但是,也可以在串行接口上启用 IP 并启动它,而不为其分配唯一 IP 地址。这是通过借用路由器的其他某个接口上已配置的 IP 地址来实现的。为此,需要按照如下所示使用 ip unnumbered 接口模式命令。
interface Serial 0 ip unnumbered Ethernet 0
ip unnumbered <类型> <编号> 接口模式命令会从指定的接口将 IP 地址借用到已配置此命令的接口上。使用 ip unnumbered 命令会导致两个接口共享 IP 地址。因此,在我们的示例中,在以太网接口上配置的 IP 地址也分配给了串行接口,涉及到的两个接口均能正常运行。如下所示,可以使用 show ip interface brief 命令的输出进行验证:
RouterA# show ip interface brief Interface IP-Address OK? Method Status Protocol Ethernet0 172.16.10.254 YES manual up up Serial0 172.16.10.254 YES manual up up
正如您在上面的 show ip interface brief 命令输出中所看到的,串行接口有一个与以太网接口相同的 IP 地址,并且两个接口的功能都完全正常。从路由器的其他某个功能正常的接口借用地址的接口被称为“无编号接口”。 在我们的示例中,Serial 0 就是无编号接口。
无编号接口的唯一缺点就是无法进行远程测试和管理。您应该记得,无编号接口应当从正常运行的接口借用地址。如果无编号接口指向的接口无法正常工作(即,未显示“Interface status UP”、“Protocol UP”),则无编号接口也无法正常工作。这也是为什么我们建议将无编号接口指向环回接口,因为环回接口不会发生故障。最后,请记住,ip unnumbered 命令仅在点对点接口上起作用。当您在多路访问接口(即以太网)或环回接口上配置该命令时,会显示以下信息:
RouterA(config)# int e0 RouterA(config-if)# ip unnumbered serial 0 Point-to-point (non-multi-access) interfaces only RouterA(config-if)# ip unnumbered loopback 0 Point-to-point (non-multi-access) interfaces only
在 Cisco 路由器上,连接到一个网段的每个接口都必须属于一个唯一子网。直连的路由器具有连接到同一网段的接口,并从同一子网分配 IP 地址。如果路由器需要向非直连的网络发送数据,会在其路由表内查找,然后将数据包转发给通向目的地的直连下一跳。如果路由表中没有路由,路由器会将数据包转发给它的最后选用网关。当直接连接到最终目标的路由器收到数据包时,会将数据包直接发送给终端主机。
IP 路由表中包含子网路由或主要的网络路由。每条路由都有一个或多个直连下一跳地址。 默认情况下,子网路由在主网络边界处聚合或汇总,以便减小路由表的大小。
注:上面讨论的聚合方案假定使用传统距离矢量路由协议,如路由信息协议(RIP)或内部网关路由协议(IGRP)。
让我们考虑将 IP 地址分配给使用 B 类网络的路由器上的接口,该网络已经使用八位子网划分进行了子网划分。每个接口都要求一个唯一子网。尽管每个点对点串行连接只有两个端点需要编址,但如果我们为每个串行接口分配一整个子网,就会为每个只需要两个地址的接口使用 254 个可用的地址。如果我们为每个串行接口使用无编号 IP,就可以节省地址空间;LAN 接口的地址被“借用”,并作为路由来自串行接口的更新和数据包的源地址。这样就节省了地址空间。无编号 IP 只对点对点链路有意义。
接收路由更新的路由器将更新的源地址安装为其路由表中的下一跳。通常,下一跳是直连网络节点。但如果我们使用无编号 IP,就不是这样了。因为每个串行接口都从其他 LAN 接口、其他子网接口,或其他主要网络中的接口“借用”IP 地址。如果配置了无编号 IP,通过无编号 IP 接口获知的路由会将该接口,而不是路由更新的源地址作为下一跳。因此,由于路由更新的源来自非直连的下一跳,我们避免了无效的下一跳地址问题。
注意:这些配置示例中的信息基于Cisco IOS®软件版本12.2(10b),并在Cisco 2500系列路由器上进行了测试。
让我们看看有关无编号 IP 的四个不同的配置示例。
注意:我们可以使用环回接口而不是以太网接口。
图 1 显示,在串行链路的任一端,我们具备相同的主网,但子网不同。
图1 – 网络图
路由器 1.1.1.1 | 路由器 2.2.2.2 |
---|---|
Current configuration: interface Ethernet0 ip address 171.68.178.196 255.255.255.192 interface Serial0 ip unnumbered Ethernet0 router igrp 10 network 171.68.0.0 |
Current configuration: interface Ethernet 0 ip address 171.68.179.1 255.255.255.192 interface Serial 0 ip unnumbered Ethernet0 router igrp 10 network 171.68.0.0 |
Router 1.1.1.1# show ip route 171.68.0.0/26 is subnetted, 3 subnets I 171.68.179.0 [100/8976] via 171.68.179.1, 00:00:02, Serial0 C 171.68.178.192 is directly connected, Ethernet0 I 171.68.0.0 [100/8976] via 171.68.179.1, 00:00:02, Serial0 Router 1.1.1.1# ping 171.68.179.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 171.68.179.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 28/30/32 ms Router 2.2.2.2# show ip route 171.68.0.0/26 is subnetted, 3 subnets C 171.68.179.0 is directly connected, Ethernet0 I 171.68.178.192 [100/8976] via 171.68.178.196, 00:00:02, Serial0 I 171.68.0.0 [100/8976] via 171.68.178.196, 00:00:02, Serial0 Router 2.2.2.2# ping 171.68.178.196 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 171.68.178.196, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 32/32/32 ms
在此场景中,有关子网的路由信息被正确维护。
图 2 显示,在串行链路的任一端,我们具备不同的主网,没有子网。
图 2 – 网络图
路由器 1.1.1.1 | 路由器 2.2.2.2 |
---|---|
Current configuration: interface Ethernet0 ip address 171.68.178.196 255.255.0.0 interface Serial0 ip unnumbered Ethernet0 router igrp 10 network 171.68.0.0 |
Current configuration: interface Ethernet 0 ip address 172.68.1.1 255.255.0.0 interface Serial 0 ip unnumbered Ethernet0 router igrp 10 network 172.68.0.0 |
Router 1.1.1.1# show ip route C 171.68.0.0/16 is directly connected, Ethernet0 I 172.68.0.0/16 [100/8976] via 172.68.1.1, 00:01:26, Serial0 Router 1.1.1.1# ping 172.68.1.1 Sending 5, 100-byte ICMP Echos to 172.68.1.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 28/28/28 ms Router 2.2.2.2# show ip route I 171.68.0.0/16 [100/8976] via 171.68.178.196, 00:00:21, Serial0 C 172.68.0.0/16 is directly connected, Ethernet0 Router 2.2.2.2# ping 171.68.178.196 Sending 5, 100-byte ICMP Echos to 171.68.178.196, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 28/29/32 ms
图 3 显示,在串行链路的一端,我们具备带有子网的主网;在另一端,我们具备没有子网的主网。
图 3 – 网络图
路由器 1.1.1.1 | 路由器 2.2.2.2 |
---|---|
Current configuration: interface Ethernet0 ip address 171.68.178.196 255.255.255.192 interface Serial0 ip unnumbered Ethernet0 router igrp 10 network 171.68.0.0 |
Current configuration: interface Ethernet 0 ip address 172.68.1.1 255.255.0.0 interface Serial 0 ip unnumbered Ethernet0 router igrp 10 network 172.68.0.0 |
Router 1.1.1.1# show ip route 171.68.0.0/26 is subnetted, 1 subnets C 171.68.178.192 is directly connected, Ethernet0 I 172.68.0.0/16 [100/8976] via 172.68.1.1, 00:00:03, Serial0 Router 1.1.1.1# ping 172.68.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.68.1.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 28/31/32 ms Router 2.2.2.2# show ip route 171.68.0.0/16 is variably subnetted, 2 subnets, 2 masks I 171.68.178.192/32 [100/8976] via 171.68.178.196, 00:00:48, Serial0 I 171.68.0.0/16 [100/8976] via 171.68.178.196, 00:00:48, Serial0 C 172.68.0.0/16 is directly connected, Ethernet0 Router 2.2.2.2# ping 171.68.178.196 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 171.68.178.196, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 28/29/32 ms
注意:在Cisco IOS软件版本11.0(2)之前,您需要在路由器2.2.2.2中为主网171.68.0.0/16设置静态路由。
在此场景中,子网信息丢失,因为该信息被当做主机路由处理。在 Cisco IOS 软件版本 11.0(2) 及更高版本中,Interior Gateway Routing Protocol (IGRP) 和 Routing Information Protocol (RIP) 通过在未编号的点对点链路中发送主网的汇总路由来解决此问题。
图 4 显示,在串行链路的两端,我们具备两个不同的主网,两者都带有各自的子网。
图 4 – 网络图
路由器 1.1.1.1 | 路由器 2.2.2.2 |
---|---|
Current configuration: interface Ethernet0 ip address 171.68.178.196 255.255.255.192 interface Serial0 ip unnumbered Ethernet0 router igrp 10 network 171.68.0.0 |
Current configuration: interface Ethernet 0 ip address 172.68.1.1 255.255.255.192 interface Serial 0 ip unnumbered Ethernet0 router igrp 10 network 172.68.0.0 |
Router 1.1.1.1# show ip route 171.68.0.0/26 is subnetted, 1 subnets C 171.68.178.192 is directly connected, Ethernet0 172.68.0.0/16 is variably subnetted, 2 subnets, 2 masks I 172.68.0.0/16 [100/8976] via 172.68.1.1, 00:00:02, Serial0 I 172.68.1.0/32 [100/8976] via 172.68.1.1, 00:00:02, Serial0 Router 1.1.1.1# ping 172.68.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.68.1.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 32/81/280 ms Router 2.2.2.2# show ip route 171.68.0.0/16 is variably subnetted, 2 subnets, 2 masks I 171.68.178.192/32 [100/8976] via 171.68.178.196, 00:00:22, Serial0 I 171.68.0.0/16 [100/8976] via 171.68.178.196, 00:00:22, Serial0 172.68.0.0/26 is subnetted, 1 subnets C 172.68.1.0 is directly connected, Ethernet0 Router 2.2.2.2# ping 171.68.178.196 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 171.68.178.196, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 28/31/32 ms
注意:在11.0(2)之前的Cisco IOS软件版本中,您需要在路由器2.2.2.2中为主网171.68.0.0/16设置静态路由,在路由器1.1.1.1中为主网172.68.0.0/16设置静态路由。
在此场景中,子网信息丢失,因为该信息被当做主机路由处理。在 Cisco IOS 软件版本 11.0(2) 及更高版本中,IGRP 和 RIP 通过在未编号的点对点链路中发送主网的汇总路由来解决此问题。
版本 | 发布日期 | 备注 |
---|---|---|
1.0 |
26-Oct-2005 |
初始版本 |