ip相关命令很多,本实验主要对常用的IP相关命令进行练习。
1.实验目的
通过本实验。读者可以把握以下技能:
使用ip address和ip address secondary命令;
使用show interface、show ip interface和show ip interface brief命令;
使用ip subnet-zero命令;
使用arp相关命令;
使用ip domain-lookup、ipdomain-name、ip name-server命令;
使用terminal ip metmask-format。
2. 设备需求
本实验需要以下设备:
2台Cisco路由器,要求每台至少具有1个以太网接口;
1台Hub,2条双绞线;
1台终端服务器,如Cisco 2509路由器,及用于反向Telnet的相应线缆;
1台带有超级终端程序的PC机,以及Comsole电缆及转接器。
3.拓扑结构及配置说明
从本章开始,在实验中将以拓扑结构图代替设备连接图,以便明确参与实验的主要设备之间的关系。在实验中必须的PC机、终端服务器、Hub及相应线缆等在拓扑图中不再出现。
本实验的拓扑结构如图4.1所示,两台路由器通过Hub连接到一起。
两台路由器分别为R1和R2,用于与Hub连接的接口均为E0接口。R1路由器E0接口IP地址为172.16.1.1,R2路由器E0接口IP地址为172.16.1.2,子网掩码均为255.255.255.0。
4. 实验配置及监测结果
用PC机通过终端服务器访问R1和R2,开始进行实验。
第1部分:ip address。ip address secondary、show interface等命令
监测清单4-1记录了这部分实验的操作过程。
监测清单4-1 ip address、ip address secondary、show interface等命令
R1#
R1#conft
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int e0
R1(config-if)#ip addr 172.16.1.1255.255.255.0
R1(config-if)#no sh
R1(config-if)#end
R1#
00:51:18: %SYS-5-CONFIG_1: Configured from console by console
(键入组合键Ctrl+shift+6,x,切换回终端服务器)
Term_Server2
[Resuming connection 2 to R2 ... ]
R2#
R2#conft
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int eO
R2(config-if)#ip addr 172.16.1.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#end
R2#
00:52:58: %SYS-5-CG_I: Configured from console by console
R2#sh int eO
Ethernet0 is up, line PRotocol is up
Hardware is
Internet address is 172.16.1.2/24
MTU 1500 bytes,BW 1000 Kbit,DLY 1000 usec.
reliability 255/255,txload 1/255,rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
ARP type: ARPA, ARP Timeout 04:00:00
Last input 00:00:10, output 00:00:09, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0/0
Queueing strategy:fifo
Output queue :0/40 (size/max)
5 minute input rate Orbits/see, ;1:pactets/sec
5 minute output
203 packets input, 29123 bytes, 0 no buffer
Received 203 broadcasts, 0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
0 input packets with dribble condition detected
382 packets output, 37648 bytes, 0 underruns
0 output errors, 0 collisions, 18 interface resets
0 babbles, 0 late collision, 0 deferred
0 lost carrier, 0 no carrier
0 output buffer failures, 0 output buffers swapped out
R2#sh ip int eO
EthemetO is up, line protocol is up
Internet address is 172.16.1.2.2/24
Broadcast address is 255.255.255.255
Adress determined by setup command
MTU is 1500 bytes
Helper address is not set
Directed broadcast forwarding is desabled
lutgoing access list is not set
Inbound access list is not set
Proxy ARP is enabled
security level is default
split horion is enabled
ICMP redirects are always sent
ICMP unreachables are always sent
IP fast switching is enabled
IP fast switching on the same interface is disabled
IP Flow switching is disabled
IP Fast switching turbo vector
IP multicast fast switching is enabled
IP multicast distributed fast switching is disabled
IP route-cache flags are Fast
Router Discovery is disabled
IP output packet accounting is disabled
IP access violation accounting is disabled
TCP/IP header compression is disabled
RTP/IP header compression is disabled
Probe proxy name replies are disabled
Policy routing is disabled
Network address translation is disabled
WCCP Redirect outbound is disabled
WCCP Redirect exclude is disabled
BGP Policy Mapping is disabled
R2#SH IP int brief
interfaceIP-Addressok?Method statusprotocol
Ethernet0170.16.1.2YES manual upup
serial0unassignedYES NVRAMadministratively down down
serial1unassignedYES NVRAMadministratively down down
R2#ping 172.16.1.1
Type escape sequence to abort.
sending 5,100-byte ICMPEchos to 172.16.1.1,timeout is 2 seconds:
..!!!
sUCcess rate is 60 percent(3/5),round-trip min/avg/max=4/4/4 ms
R2#conft
Enter configuration commands,one per line.End winth CNTL/Z
R2(config)#ip subnet-zero
R2(config)#ing e0
R2(config-if)#ip addr 172.0.0.1 255.255.255.0
Bad mask/24 for address 172.0.0.1
R2(config-if)#exit
R2(config)#if subnet-zero
R2(config)#int e0
R2(config-if)#ip addr 172.0.0.1255.255.255.0
R2(config-if)#ip addr 172.1.0.1 255.255.255.0 secondary
R2(config-if)#ip addr 172.2.0.1 255.255.255.0 secondary
R2(config-if)#^Z
R2#
(1)在监测清单的开始部分,分别在Rl和R2路由器的EO接口上配置了相应的IP地址。注重配置好IP地址后立即发出了Ho shut命令激活接口,初学者往往忽视此命令。
(2)sh int e0命令即show interface e0,其运行结果显示了EO接口的配置信息和统计信息,其中大部分是统计信息。配置信息有MAC地址(0000。0c8e。cdd2)、IP地址、MTU(15OOBytes)、BW(带宽,lOMbMs)、DLY(延迟)。reliability(可靠性)以及负载 (txload和rxload)等信息;统计信息是关于队列(而putqueue、Output queue)、最近5min时间内的输入、输出速率及数据包数量等信息。
(3)show ip interface e0(sh ip int eo)命令显示了EO接口上有关IP的所有配置信息,包括IP地址、广播地址、MTU、访问列表。Proxy ARP等众多条目我们应主要关注与CCNA考试相关的条目。
(4),show ip interface e0(sh ip int brief)以简洁的形式列出了路由器所有接口有关IP地址的配置信息,包括接口IP地址、是否可用 (OK?)、IP地址获取的方式 (Method)。接口状态(Status)和协议状态(Protocol)。其中manual表示人工设置,NVRAM表示启动时从配置文件中获取。
(5)使用Ping命令测试Rl和R2的IP连通性,以确认配置是否生效。注重ping命令执行结果中的细节,即"..!!!",这表示前两个包没有ping通,这是因为开始时在R2的ARP表中还没有R1的EO接口相关的表项,即不知道172.16.1.1的MAC地址是什么,在下面关于ARP相关命令的实验中,这一点会非常清楚地显示出来。
(6)在IOS11.3以后的版本中,ip subnet-zero语句成为Cisco路由器的缺省配置。它使得零子网成为合法的网络号。在实验中,首先关闭了此功能,即发出命令no ip subnet-zero,当设置EO接口的IP地址为172.0.0.1时,路由器报错;当发出命令ip subnet-zero答应零子网存在时,对EO接口重复上述的配置命令时,IP地址被成功设置。
(7)ip addr 172.1.0.1.255.255.255.0 secondary命令为EO接