Branch#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Branch(config)#clock timezone BJS +8 Nov 21 16:03:33.660: %SYS-6-CLOCKUPDATE: System clock has been updated from 16:03:33 UTC Fri Nov 21 1997 to 00:03:33 BJS Sat Nov 22 1997, configured from console by console. Branch(config)#end Nov 21 16:03:57.150: %SYS-5-CONFIG_I: Configured from console by console Branch#show clock 00:04:03.333 BJS Sat Nov 22 1997
OK, 接下来来进行时间的调整吧:
1 2 3 4
Branch#clock set 13:28:00 15 Sep 2017 Sep 15 05:28:00.000: %SYS-6-CLOCKUPDATE: System clock has been updated from 00:04:52 BJS Sat Nov 22 1997 to 13:28:00 BJS Fri Sep 15 2017, configured from console by console. Branch#show clock 13:28:06.507 BJS Fri Sep 15 2017
这样就完成了时区的调整.
第一次的Ping
实验拓扑: (两台三层路由, 都通过Ethernet0/1接口进行连接)
要做的事情很简单, 打开接口, 设置IP, Ping!
首先打开HQ的终端:
1 2 3 4 5 6 7 8 9
HQ#configure terminal Enter configuration commands, one per line. End with CNTL/Z. HQ(config)#interface e0/1 HQ(config-if)#no shutdown *Sep 15 05:39:15.873: %LINK-3-UPDOWN: Interface Ethernet0/1, changed state to up *Sep 15 05:39:16.877: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to up HQ(config-if)#ip address 192.168.1.2 255.255.255.0 HQ(config-if)#end *Sep 15 05:39:32.875: %SYS-5-CONFIG_I: Configured from console by console
Branch#ping 192.168.1.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds: .!!!! Success rate is 80 percent (4/5), round-trip min/avg/max = 5/5/6 ms
HQ这边:
1 2 3 4 5
HQ#ping 192.168.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 4/5/6 ms
其中 ! 表示通, 而 . 表示不通.
这里补充一个更改主机名:
1 2 3 4 5 6
HQ#configure terminal Enter configuration commands, one per line. End with CNTL/Z. HQ(config)#hostname HQ HQ(config)#hostname Test Test(config)#hostname HQ HQ(config)#
HQ#conf ter Enter configuration commands, one per line. End with CNTL/Z. HQ(config)#enable password justin HQ(config)#enable secret justin The enable secret you have chosen is the same as your enable password. This is not recommended. Re-enter the enable secret.
HQ(config)#enable secret bieber HQ(config)#
配置远程管理虚拟线缆
我们在Branch端进行设置, 接着通过HQ端进行连接 (他们已经是能够Ping通的了)
1 2 3 4 5 6 7 8
Branch#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Branch(config)#line vty 4 Branch(config-line)#password justin Branch(config-line)#transport input all Branch(config-line)#end Branch# Sep 15 10:28:11.083: %SYS-5-CONFIG_I: Configured from console by console
HQ#show clock *18:38:16.862 BJS Fri Sep 15 2017 HQ#configure terminal Enter configuration commands, one per line. End with CNTL/Z. HQ(config)#end HQ# *Sep 15 10:38:36.749: %SYS-5-CONFIG_I: Configured from console by console HQ#show running-config Building configuration...
Current configuration : 1991 bytes ! ! Last configuration change at 18:38:36 BJS Fri Sep 15 2017 ! HQ#show startup-config Using 1991 out of 32768 bytes ! ! Last configuration change at 18:37:44 BJS Fri Sep 15 2017 ! HQ#write Building configuration... [OK] HQ#show startup-config Using 1991 out of 32768 bytes ! ! Last configuration change at 18:38:36 BJS Fri Sep 15 2017 !
HQ#write erase Erasing the nvram filesystem will remove all configuration files! Continue? [confirm] [OK] Erase of nvram: complete *Sep 15 10:52:17.132: %SYS-7-NV_BLOCK_INIT: Initialized the geometry of nvram HQ#show startup-config startup-config is not present
System configuration has been modified. Save? [yes/no]:
这个问题的其实就是问你是否进行保存. 看自己了吧.
IOS的中断测试很奇怪, 是CTRL+SHIFT+6 而CTRL+C是指退出到特权模式.
其他
设置旗标
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
HQ#config terminal Enter configuration commands, one per line. End with CNTL/Z. HQ(config)#banner motd X This is my HQ router! X # 第一种方法 HQ(config)#banner motd X # 第二种方法 Enter TEXT message. End with the character 'X'. This is my HQ router! X HQ(config)#end HQ# *Sep 17 02:22:51.397: %SYS-5-CONFIG_I: Configured from console by console HQ#logout # 当再次建立连接的时候: HQ con0 is now available
Press RETURN to get started.
This is my HQ router!
HQ#
历史
1 2 3 4 5 6
HQ#show history ping 192.168.1.1 ping 192.168.1.2 ping 192.168.1.3 show history HQ#terminal history size 100
终端长度
1 2
HQ#terminal length ? <0-512> Number of lines on screen (0 for no pausing)
管道
1 2 3 4 5 6 7 8 9 10 11
HQ#show history | include show # 包含show的 show history show history show history show history | include show HQ#show history | section conf # 显示所有和conf有关的 configure configure configure terminal configure ter show history | section conf
密码加密
什么意思? 我们刚刚不是使用了secret吗? 请看:
1 2 3 4 5 6 7 8
HQ#show run ...(omitted) enable secret 5 $1$l86G$JudkPOGyI5PrPlv0/3zeI1 enable password justin ...(omitted) line vty 0 password justin login
HQ#conf ter Enter configuration commands, one per line. End with CNTL/Z. HQ(config)#service password-encryption HQ(config)#end HQ#show run ... enable secret 5 $1$l86G$JudkPOGyI5PrPlv0/3zeI1 enable password 7 0501131C354540 ... line vty 0 password 7 0705345F5A0017 login
局域网
查看MAC表: (仅用于交换机[或者说二层设备, 并且这个MAC表是只有二层设备才具有的.])
1 2 3 4 5 6
Switch#show mac address-table Mac Address Table -------------------------------------------
Vlan Mac Address Type Ports ---- ----------- -------- -----
Branch#conf terminal Enter configuration commands, one per line. End with CNTL/Z. Branch(config)#interface e0/0 Branch(config-if)#no shu *Sep 16 07:50:30.459: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up *Sep 16 07:50:31.468: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up Branch(config-if)#ip address 10.1.10.254 255.255.255.0 Branch(config-if)#end Branch# *Sep 16 07:50:55.772: %SYS-5-CONFIG_I: Configured from console by console
主机:
1 2 3 4 5 6 7 8 9
PC1#conf ter Enter configuration commands, one per line. End with CNTL/Z. PC1(config)#interface e0/1 PC1(config-if)#no shu *Sep 16 07:51:38.765: %LINK-3-UPDOWN: Interface Ethernet0/1, changed state to up *Sep 16 07:51:39.774: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to up PC1(config-if)#ip address 10.1.10.100 255.255.255.0 PC1(config-if)#exi PC1(config)#ip default-gateway 10.1.10.254
# 首先我们查看一下MAC地址表, 后面的小彩蛋会用到 SW1#show mac address-table Mac Address Table -------------------------------------------
Vlan Mac Address Type Ports ---- ----------- -------- ----- SW1#conf ter Enter configuration commands, one per line. End with CNTL/Z. SW1(config)#interface vlan 1 SW1(config-if)#no shut SW1(config-if)#ip address *Sep 16 07:57:12.448: %LINK-3-UPDOWN: Interface Vlan1, changed state to up *Sep 16 07:57:13.450: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up SW1(config-if)#ip address 10.1.10.99 255.255.255.0 SW1(config-if)#exi SW1(config)#ip default-gateway 10.1.10.254 SW1(config)#end SW1# *Sep 16 07:57:50.319: %SYS-5-CONFIG_I: Configured from console by console
Ping测试:
1 2 3 4 5 6 7 8 9 10
SW1#ping 10.1.10.254 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.10.254, timeout is 2 seconds: .!!!! Success rate is 80 percent (4/5), round-trip min/avg/max = 5/5/6 ms SW1#ping 10.1.10.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.10.100, timeout is 2 seconds: .!!!! Success rate is 80 percent (4/5), round-trip min/avg/max = 2/4/5 ms
成功, 接下来进行远程telnet:
主机:
1 2 3 4 5 6 7
PC1#telnet 10.1.10.99 Trying 10.1.10.99 ... Open
Password required, but none set
[Connection to 10.1.10.99 closed by foreign host]
出现了问题. 原来是虚拟线缆的密码没有设置:
1 2 3 4 5 6 7
SW1#conf ter Enter configuration commands, one per line. End with CNTL/Z. SW1(config)#line vty 0 4 SW1(config-line)#password justin SW1(config-line)#end SW1# *Sep 16 08:04:17.977: %SYS-5-CONFIG_I: Configured from console by console
再次尝试:
1 2 3 4 5 6 7
PC1#telnet 10.1.10.99 Trying 10.1.10.99 ... Open
User Access Verification
Password: SW1>
使用路由器也能够进行远程管理. 实验结束.
小彩蛋:
1 2 3 4 5 6 7 8 9
SW1#show mac address-table Mac Address Table -------------------------------------------
Vlan Mac Address Type Ports ---- ----------- -------- ----- 1 aabb.cc00.0100 DYNAMIC Et0/0 1 aabb.cc00.0410 DYNAMIC Et0/1 Total Mac Addresses for this criterion: 2
SW1#conf ter Enter configuration commands, one per line. End with CNTL/Z. SW1(config)#end
另外一边:
1
*Sep 17 03:58:42.057: %SYS-5-CONFIG_I: Configured from console by vty0 (10.1.10.254)
现在我们开启:
1 2 3 4 5 6
SW1#terminal monitor SW1#conf ter Enter configuration commands, one per line. End with CNTL/Z. SW1(config)#end SW1# *Sep 17 03:59:31.949: %SYS-5-CONFIG_I: Configured from console by vty0 (10.1.10.254)
子网与简单静态路由
实验拓扑:
和上面一样, 还是先进行IP地址和接口的配置:
HQ:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
HQ#conf ter Enter configuration commands, one per line. End with CNTL/Z. HQ(config)#inte e0/1 HQ(config-if)#no shut *Sep 17 03:17:47.514: %LINK-3-UPDOWN: Interface Ethernet0/1, changed state to up *Sep 17 03:17:48.519: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to up HQ(config-if)#ip address 192.168.1.1 255.255.255.0 HQ(config-if)#exi HQ(config)#inter e0/0 HQ(config-if)#no shut *Sep 17 03:18:13.821: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up *Sep 17 03:18:14.827: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up HQ(config-if)#ip address 10.1.10.23 255.255.255.240 HQ(config-if)#end HQ# *Sep 17 03:19:13.905: %SYS-5-CONFIG_I: Configured from console by console
Branch:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Branch#conf ter Enter configuration commands, one per line. End with CNTL/Z. Branch(config)#inter e0/1 Branch(config-if)#no shut Branch(config-if)#ip address 192.1 *Sep 17 03:20:51.347: %LINK-3-UPDOWN: Interface Ethernet0/1, changed state to up *Sep 17 03:20:52.349: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to up Branch(config-if)#ip address 192.168.1.2 255.255.255.252 Branch(config-if)#exi Branch(config)#inter e0/0 Branch(config-if)#ip address 172.16.1.100 255.255.255.248 Branch(config-if)#end Branch# *Sep 17 03:22:30.740: %SYS-5-CONFIG_I: Configured from console by console
在进行ping测试之前, 先来观察一下双方的路由表:
HQ:
1 2 3 4 5 6 7 8
HQ#show ip rou ...(omitted) 10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 10.1.10.16/28 is directly connected, Ethernet0/0 L 10.1.10.23/32 is directly connected, Ethernet0/0 192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.1.0/24 is directly connected, Ethernet0/1 L 192.168.1.1/32 is directly connected, Ethernet0/1
Branch:
1 2 3 4 5 6 7 8
Branch#show ip rou ...(omitted) 172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks C 172.16.1.96/29 is directly connected, Ethernet0/0 L 172.16.1.100/32 is directly connected, Ethernet0/0 192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.1.0/30 is directly connected, Ethernet0/1 L 192.168.1.2/32 is directly connected, Ethernet0/1
那么, 问题来了, 两台路由器现在可以直接进行通信吗?
我们来测试一下:
1 2 3 4 5 6
HQ#ping 192.168.1.2 source e0/1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds: Packet sent with a source address of 192.168.1.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 5/5/5 m
另外一边:
1 2 3 4 5 6
Branch#ping 192.168.1.1 source e0/1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds: Packet sent with a source address of 192.168.1.2 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 5/5/5 ms
HQ(config)#ip route 172.16.1.96 255.255.255.248 e0/1 HQ(config)#end HQ# *Sep 17 03:33:43.157: %SYS-5-CONFIG_I: Configured from console by console HQ#ping 172.16.1.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.16.1.100, timeout is 2 seconds: .!!!! Success rate is 80 percent (4/5), round-trip min/avg/max = 6/6/6 ms
Branch:
1 2 3 4 5 6 7 8 9
Branch(config)#ip route 10.1.10.16 255.255.255.240 e0/1 Branch(config)#end Branch# *Sep 17 03:36:40.131: %SYS-5-CONFIG_I: Configured from console by console Branch#ping 10.1.10.23 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.10.23, timeout is 2 seconds: .!!!! Success rate is 80 percent (4/5), round-trip min/avg/max = 5/6/8 ms
现在我们再来观察一下他们的路由:
1 2 3 4 5 6 7 8 9 10
HQ#show ip route ...(omitted) 10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 10.1.10.16/28 is directly connected, Ethernet0/0 L 10.1.10.23/32 is directly connected, Ethernet0/0 172.16.0.0/29 is subnetted, 1 subnets S 172.16.1.96 is directly connected, Ethernet0/1 192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.1.0/24 is directly connected, Ethernet0/1 L 192.168.1.1/32 is directly connected, Ethernet0/1
其中S就是指该路由为静态路由:
也可以直接指明:
1 2 3 4
Branch#show ip route static ...(omitted) 10.0.0.0/28 is subnetted, 1 subnets S 10.1.10.16 is directly connected, Ethernet0/1
实验结束.
附赠大礼包:
报文与分片
默认的MTU是1500, 我们可以通过查看接口来获得值:
1 2 3 4 5 6
HQ#show inter e0/1 Ethernet0/1 is up, line protocol is up Hardware is AmdP2, address is aabb.cc00.0110 (bia aabb.cc00.0110) Internet address is 192.168.1.1/24 MTU 1500 bytes, BW 10000 Kbit/sec, DLY 1000 usec, ...(omitted)
另外我们的Branch也是这样:
1 2 3 4 5 6
Branch#show inter e0/1 Ethernet0/1 is up, line protocol is up Hardware is AmdP2, address is aabb.cc00.0310 (bia aabb.cc00.0310) Internet address is 192.168.1.2/24 MTU 1500 bytes, BW 10000 Kbit/sec, DLY 1000 usec, ...(omitted)
接下来还是进行熟悉的Ping操作:
1 2 3 4 5 6
Branch#ping 192.168.1.1 df-bit Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds: Packet sent with the DF bit set !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 5/5/6 ms
Branch#ping 192.168.1.1 df-bit size 1501 Type escape sequence to abort. Sending 5, 1501-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds: Packet sent with the DF bit set ..... Success rate is 0 percent (0/5)
发不过去了. 移除DF标志位:
1 2 3 4 5
Branch#ping 192.168.1.1 size 1501 Type escape sequence to abort. Sending 5, 1501-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 5/5/6 ms
顺利发送.
玩上瘾了, 再来一个子网广播小实验:
1 2 3 4 5 6 7 8
HQ#ping 192.168.1.255 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.255, timeout is 2 seconds:
Reply to request 0 from 192.168.1.2, 6 ms Reply to request 1 from 192.168.1.2, 5 ms Reply to request 2 from 192.168.1.2, 5 ms Reply to request 3 from 192.168.1.2, 5 ms
嘿嘿, 收到了Branch的回信, 接着在试试Branch的那一端:
1 2 3 4 5
Branch#ping 192.168.1.155 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.155, timeout is 2 seconds: ..... Success rate is 0 percent (0/5)
HQ#ping 172.16.1.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.16.1.100, timeout is 2 seconds: .!!!! Success rate is 80 percent (4/5), round-trip min/avg/max = 1/4/5 ms
是通的, 接着我们进行Branch的Ping测试:
1 2 3 4 5
Branch#ping 10.1.10.16 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.10.16, timeout is 2 seconds: ..... Success rate is 0 percent (0/5)
不同了, 但是HQ->Branch是通的啊. 现在我们查看一下Branch的ARP表:
1 2 3 4 5 6
Branch#sh arp Protocol Address Age (min) Hardware Addr Type Interface Internet 10.1.10.16 0 Incomplete ARPA Internet 172.16.1.100 - aabb.cc00.0300 ARPA Ethernet0/0 Internet 192.168.1.1 1 aabb.cc00.0110 ARPA Ethernet0/1 Internet 192.168.1.2 - aabb.cc00.0310 ARPA Ethernet0/1
HQ#conf ter Enter configuration commands, one per line. End with CNTL/Z. HQ(config)#inter e0/1 HQ(config-if)#ip proxy-arp HQ(config-if)#end
Branch:
1 2 3 4 5
Branch#ping 10.1.10.16 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.10.16, timeout is 2 seconds: .!!!! Success rate is 80 percent (4/5), round-trip min/avg/max = 5/5/5 ms
HQ#conf ter Enter configuration commands, one per line. End with CNTL/Z. HQ(config)#inter e0/1 HQ(config-if)#no ip proxy-arp HQ(config-if)#end HQ# *Sep 17 08:38:08.122: %SYS-5-CONFIG_I: Configured from console by console
Branch:
1 2 3 4 5 6
Branch#clear ip arp 10.1.10.16 Branch#sh arp Protocol Address Age (min) Hardware Addr Type Interface Internet 172.16.1.100 - aabb.cc00.0300 ARPA Ethernet0/0 Internet 192.168.1.1 23 aabb.cc00.0110 ARPA Ethernet0/1 Internet 192.168.1.2 - aabb.cc00.0310 ARPA Ethernet0/1
激动人心的时候到了:
1 2 3 4 5
Branch#ping 10.1.10.16 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.10.16, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/4/5 ms
超级顺畅.
1 2 3 4 5
Branch#sh arp Protocol Address Age (min) Hardware Addr Type Interface Internet 172.16.1.100 - aabb.cc00.0300 ARPA Ethernet0/0 Internet 192.168.1.1 0 aabb.cc00.0110 ARPA Ethernet0/1 Internet 192.168.1.2 - aabb.cc00.0310 ARPA Ethernet0/1
ARP解析项也没了, 所以这样的好处还有节约性能.
另外,为了保险, 其实可以接口和下一跳一起写的. 最后配置的结果就是:
1 2 3 4 5 6
Branch(config)#ip route 10.1.10.16 255.255.255.240 e0/1 192.168.1.1 Branch(config)#do sh ip rou ...(omitted) 10.0.0.0/28 is subnetted, 1 subnets S 10.1.10.16 [1/0] via 192.168.1.1, Ethernet0/1 ...(omitted)
HQ#sh ip rou ...(omitted) 10.0.0.0/24 is subnetted, 1 subnets S 10.1.10.0 [1/0] via 192.168.1.1, Ethernet0/1
接着给Branch配一个默认路由, 默认路由其实就是0.0.0.0/0了.
1 2 3 4 5 6
Branch#conf ter Enter configuration commands, one per line. End with CNTL/Z. Branch(config)#ip route 0.0.0.0 0.0.0.0 e0/1 %Default route without gateway, if not a point-to-point interface, may impact performance Branch(config)#no ip route 0.0.0.0 0.0.0.0 e0/1 Branch(config)#ip route 0.0.0.0 0.0.0.0 e0/1 192.168.1.2
上面第一次的设置有警告了, 如果你不在一个点对点网络中, 这样做会影响性能.
当然了, 总不能所有的包都从一个出口出去了, 这样岂不是会把我们的Branch累死.
所以最好的方法就是综合设置下一跳和出接口.
配置完成了, 那么现在我们就来看一下路由表吧:
1 2 3
Branch#sh ip ro S* 0.0.0.0/0 [1/0] via 192.168.1.2, Ethernet0/1 10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
这个S*是什么呢? 这被称为候选默认路由.
从这个实验我们引出浮动路由的实验:
静态默认路由和路由负载均衡的实验
实验拓扑:
( 妈呀, 画图累死了.
先按照实验拓扑中的状态进行配置.
我现在配置的越来越熟练了哈哈哈.
你可以参考下面的配置, 当然是建议自己动手啦~
PC1 [路由模拟]:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
PC1#conf ter Enter configuration commands, one per line. End with CNTL/Z. PC1(config)#inter e0/1 PC1(config-if)#no sh PC1(config-if)#ip addr 10.1. *Sep 17 13:33:43.877: %LINK-3-UPDOWN: Interface Ethernet0/1, changed state to up *Sep 17 13:33:44.882: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to up PC1(config-if)#ip addr 10.1.10.100 255.255.255.0 PC1(config-if)#exi PC1(config)#ip default-gateway 10.1.10.254 PC1(config)#no ip routing PC1(config)#end PC1# *Sep 17 13:34:18.742: %SYS-5-CONFIG_I: Configured from console by console
Branch#conf ter Enter configuration commands, one per line. End with CNTL/Z. Branch(config)#inter e0/0 Branch(config-if)#no sh Branch(config-if)#ip address *Sep 17 13:36:02.132: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up *Sep 17 13:36:03.139: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up Branch(config-if)#ip address 10.1.10.254 255.255.255.0 Branch(config-if)#exi Branch(config)#inte e0/1 Branch(config-if)#no sh Branch(config-if)#ip addre 1 *Sep 17 13:36:24.959: %LINK-3-UPDOWN: Interface Ethernet0/1, changed state to up *Sep 17 13:36:25.965: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to up Branch(config-if)#ip addre 192.168.1.1 255.255.255.0 Branch(config-if)#exi Branch(config)#ip route 0.0.0.0 0.0.0.0 e0/1 192.168.1.2 Branch(config)#end Branch# *Sep 17 13:36:36.208: %SYS-5-CONFIG_I: Configured from console by console
HQ:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
HQ#conf ter Enter configuration commands, one per line. End with CNTL/Z. HQ(config)#inte e0/1 HQ(config-if)#no sh HQ(config-if)#ip addr 192.168.1 *Sep 17 13:37:21.008: %LINK-3-UPDOWN: Interface Ethernet0/1, changed state to up *Sep 17 13:37:22.013: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to up HQ(config-if)#ip addr 192.168.1.2 255.255.255.0 HQ(config-if)#exi HQ(config)#inte e0/0 HQ(config-if)#no sh HQ(config-if)#ip addr *Sep 17 13:37:33.536: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up *Sep 17 13:37:34.537: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up HQ(config-if)#ip addr 172.16.1.1 255.255.255.0 HQ(config-if)#exi HQ(config)#ip route 0.0.0.0 0.0.0.0 e0/1 192.168.1.1 HQ(config)#end *Sep 17 13:37:53.594: %SYS-5-CONFIG_I: Configured from console by console
Server [路由模拟]:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Server#conf ter Enter configuration commands, one per line. End with CNTL/Z. Server(config)#inte e0/0 Server(config-if)#no sh Server(config-if)#ip address 172.1 *Sep 17 13:38:18.541: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up *Sep 17 13:38:19.547: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up Server(config-if)#ip address 172.16.1.2 255.255.255.0 Server(config-if)#exi Server(config)#no ip routing Server(config)#ip default-gateway 172.16.1.1 Server(config)#end Server# *Sep 17 13:38:54.270: %SYS-5-CONFIG_I: Configured from console by console
进行Ping测试:
PC1 –> Server:
1 2 3 4 5
PC1#ping 172.16.1.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.16.1.2, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
Server –> PC1:
1 2 3 4 5
Server#ping 10.1.10.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.10.100, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
HQ#conf ter Enter configuration commands, one per line. End with CNTL/Z. HQ(config)#inter s2/0 HQ(config-if)#no sh HQ(config-if)#ip address 200. *Sep 17 14:14:05.632: %LINK-3-UPDOWN: Interface Serial2/0, changed state to up *Sep 17 14:14:06.633: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up HQ(config-if)#ip address 200.202.100.2 255.255.255.0 HQ(config-if)#end HQ#ping *Sep 17 14:14:15.225: %SYS-5-CONFIG_I: Configured from console by console HQ#ping 200.202.100.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 200.202.100.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 8/9/10 ms
Branch同理.
1 2 3 4 5 6
Branch#conf ter Enter configuration commands, one per line. End with CNTL/Z. Branch(config)#ip route 0.0.0.0 0.0.0.0 s2/0 Branch(config)#end Branch# *Sep 17 14:15:14.748: %SYS-5-CONFIG_I: Configured from console by console
Branch#conf ter Enter configuration commands, one per line. End with CNTL/Z. Branch(config)#ip route 0.0.0.0 0.0.0.0 s2/0 10 Branch(config)#end Branch#sh i *Sep 17 14:23:15.496: %SYS-5-CONFIG_I: Configured from console by console Branch#sh ip rou S* 0.0.0.0/0 [1/0] via 192.168.1.2, Ethernet0/1 10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 10.1.10.0/24 is directly connected, Ethernet0/0 L 10.1.10.254/32 is directly connected, Ethernet0/0 192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.1.0/24 is directly connected, Ethernet0/1 L 192.168.1.1/32 is directly connected, Ethernet0/1 200.202.100.0/24 is variably subnetted, 2 subnets, 2 masks C 200.202.100.0/24 is directly connected, Serial2/0 L 200.202.100.1/32 is directly connected, Serial2/0 Branch#
看到没, 原本的哪一个默认路由已经看不到了. 测试一下吧:
首先先给HQ加上路由:
1 2 3 4 5 6
HQ#conf ter Enter configuration commands, one per line. End with CNTL/Z. HQ(config)#ip route 10.1.10.0 255.255.255.0 s2/0 HQ(config)#end HQ# *Sep 17 14:25:26.060: %SYS-5-CONFIG_I: Configured from console by console
接着, 关闭接口:
1 2 3 4 5 6 7 8 9 10
Branch#conf ter Enter configuration commands, one per line. End with CNTL/Z. Branch(config)#inte e0/1 Branch(config-if)#sh Branch(config-if)#end Branch# *Sep 17 14:26:19.050: %SYS-5-CONFIG_I: Configured from console by console Branch# *Sep 17 14:26:20.541: %LINK-5-CHANGED: Interface Ethernet0/1, changed state to administratively down *Sep 17 14:26:21.545: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to down
HQ#conf te Enter configuration commands, one per line. End with CNTL/Z. HQ(config)#inte e0/1 HQ(config-if)#sh HQ(config-if)#end HQ# *Sep 17 14:26:45.056: %SYS-5-CONFIG_I: Configured from console by console HQ# HQ# *Sep 17 14:26:46.287: %LINK-5-CHANGED: Interface Ethernet0/1, changed state to administratively down *Sep 17 14:26:47.292: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to down
现在再使用PC1去Ping Server:
1 2 3 4 5
PC1#ping 172.16.1.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.16.1.2, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 9/9/10 ms
Server也可和PC1正常通信.
这个时候查看路由表就可以看到s2/0这一条了.
浮动路由实验结束.
小彩蛋:
这个时候如果你进行大量的Ping测试, 会明显看出速率的降低.
1 2 3 4 5 6 7 8 9 10 11 12 13
PC1#ping 172.16.1.2 repeat 100 Type escape sequence to abort. Sending 100, 100-byte ICMP Echos to 172.16.1.2, timeout is 2 seconds: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Success rate is 100 percent (100/100), round-trip min/avg/max = 1/1/6 ms -------关闭接口前后的分割线----------- PC1#ping 172.16.1.2 repeat 100 Type escape sequence to abort. Sending 100, 100-byte ICMP Echos to 172.16.1.2, timeout is 2 seconds: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Success rate is 100 percent (100/100), round-trip min/avg/max = 6/9/12 ms
PC1#ping 172.16.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds: UUUUU Success rate is 0 percent (0/5)
目标不可达.
接着我们再给Branch增加一条更更精确的正确路由:
1 2 3 4 5 6
Branch(config)#ip route 172.16.1.1 255.255.255.255 e0/1 192.168.1.2 Branch#sh ip rou sta S* 0.0.0.0/0 is directly connected, Ethernet0/1 172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks S 172.16.1.0/24 is directly connected, Null0 S 172.16.1.1/32 [1/0] via 192.168.1.2, Ethernet0/1
再试试:
1 2 3 4 5
PC1#ping 172.16.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
通了, 这就是最长匹配原则.
VLAN技术
实验一: 简单vlan的配置, 初次尝试简单vlan划分
实验拓扑:
配置完成之后, 我们查看一下SW1当前的VLAN信息:
1 2 3 4 5 6 7 8
SW1#sh vlan
VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Et0/0, Et0/1, Et0/2, Et0/3 Et1/0, Et1/1, Et1/2, Et1/3 Et2/0, Et2/1, Et2/2, Et2/3 Et3/0, Et3/1, Et3/2, Et3/3
SW1#conf ter Enter configuration commands, one per line. End with CNTL/Z. SW1(config)#interface range e0/0 -1 SW1(config-if-range)#switchport mode access SW1(config-if-range)#switchport access vlan 10
查看一下vlan10的信息:
1 2 3 4 5 6
SW1#sh vlan id 10
VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 10 507a active Et0/0, Et0/1 ....(omitted)
测试一下数据包是否是通的:
1 2 3 4 5
PC1#ping 10.1.10.254 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.10.254, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 5/5/6 ms
实验二: access模式vlan, 交换机之间的vlan划分
这里使用的交换机都是三层交换机. 继续沿用我们上面的拓扑, 但是稍微升级一下:
这里省略PC2的配置, 因为和PC1几乎一样.
首先我们配置一下SW1的vlan20的模式:
1 2 3 4 5 6 7 8
SW1#conf ter Enter configuration commands, one per line. End with CNTL/Z. SW1(config)#int e0/2 SW1(config-if)#switchport mo acc SW1(config-if)#switchport acc vlan 20 SW1(config-if)#end SW1# *Sep 18 12:45:36.057: %SYS-5-CONFIG_I: Configured from console by console
SW2#conf ter Enter configuration commands, one per line. End with CNTL/Z. SW2(config)#int e0/2 SW2(config-if)#switchport mo acc SW2(config-if)#switchport acc vlan 20 SW2(config-if)#end
SW1(config)#int vlan 20 SW1(config-if)#no sh SW1(config-if)# *Sep 18 13:02:23.072: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to down SW1(config-if)#ip add *Sep 18 13:02:25.643: %LINK-3-UPDOWN: Interface Vlan20, changed state to up *Sep 18 13:02:26.650: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up SW1(config-if)#ip addr 10.1.20.254 255.255.255.0
接着我们测试连通性:
1 2 3 4 5
PC2#ping 10.1.20.254 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.20.254, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 5/5/6 ms
我觉得OK.
第三个实验: trunk vlan的实现, 首先要加一个e0/3的网线:
现在开始配置SW1的trunk:
1 2 3 4 5 6 7
Enter configuration commands, one per line. End with CNTL/Z. SW1(config)#int range e0/2 -3 SW1(config-if-range)#switch SW1(config-if-range)#switchport mode trunk Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode. % Range command terminated because it failed on Ethernet0/2
SW1(config-if-range)#switchport trunk encapsulation dot1q SW1(config-if-range)#switchport mode tru
SW2同理. 配置完成之后 我们查看一下trunk情况:
1 2 3 4 5
SW2#sh int tru
Port Mode Encapsulation Status Native vlan Et0/2 on 802.1q trunking 1 Et0/3 on 802.1q trunking 1
两端一样的配置才可以.
现在, PC2还可以Ping通网关吗?
1 2 3 4 5
PC2#ping 10.1.20.254 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.20.254, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Router#conf ter Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname router router(config)#ip domain-name yaoxuannn.com router(config)#username router password justin13wyx router(config)#crypto key generate rsa general-keys modulus 2048 The name for the keys will be: router.yaoxuannn.com
% The key modulus size is 2048 bits % Generating 2048 bit RSA keys, keys will be non-exportable... [OK] (elapsed time was 2 seconds)
router(config)# *Sep 19 05:01:11.887: %SSH-5-ENABLED: SSH 1.99 has been enabled router(config)#line vty 0 4 router(config-line)#transport input ssh telnet
IOU1#sh ip int b Interface IP-Address OK? Method Status Protocol Ethernet0/0 unassigned YES NVRAM administratively down down Ethernet0/1 192.168.1.2 YES manual up up Ethernet0/2 unassigned YES NVRAM administratively down down Ethernet0/3 unassigned YES NVRAM administratively down down Ethernet1/0 unassigned YES NVRAM administratively down down Ethernet1/1 unassigned YES NVRAM administratively down down Ethernet1/2 unassigned YES NVRAM administratively down down Ethernet1/3 unassigned YES NVRAM administratively down down Serial2/0 unassigned YES NVRAM administratively down down Serial2/1 unassigned YES NVRAM administratively down down Serial2/2 unassigned YES NVRAM administratively down down IOU1#conf ter Enter configuration commands, one per line. End with CNTL/Z. IOU1(config)#sh ip int b ^ % Invalid input detected at '^' marker.
IOU1(config)#do sh ip int b Interface IP-Address OK? Method Status Protocol Ethernet0/0 unassigned YES NVRAM administratively down down Ethernet0/1 192.168.1.2 YES manual up up Ethernet0/2 unassigned YES NVRAM administratively down down Ethernet0/3 unassigned YES NVRAM administratively down down Ethernet1/0 unassigned YES NVRAM administratively down down Ethernet1/1 unassigned YES NVRAM administratively down down Ethernet1/2 unassigned YES NVRAM administratively down down Ethernet1/3 unassigned YES NVRAM administratively down down Serial2/0 unassigned YES NVRAM administratively down down Serial2/1 unassigned YES NVRAM administratively down down Serial2/2 unassigned YES NVRAM administratively down down
查看当前的会话:
1 2 3 4 5 6
Router#sh users Line User Host(s) Idle Location * 0 con 0 idle 00:00:00 2 vty 0 idle 00:00:10 192.168.1.2
SW1#conf ter Enter configuration commands, one per line. End with CNTL/Z. SW1(config)#vlan 10 SW1(config-vlan)#name 507a SW1(config-vlan)#vlan 20 SW1(config-vlan)#name 507b SW1(config-vlan)#int e0/1 SW1(config-if)#sw mo acc SW1(config-if)#sw acc vlan 10 SW1(config-if)#int e0/2 SW1(config-if)#sw mo acc SW1(config-if)#sw acc vlan 20 SW1(config-if)#end SW1# *Sep 19 15:08:02.531: %SYS-5-CONFIG_I: Configured from console by console SW1#
SW2几乎和SW1一样的配置, 所以也省略了.
1 2 3 4 5 6
SW1#conf ter Enter configuration commands, one per line. End with CNTL/Z. SW1(config)#int e0/0 SW1(config-if)#sw tr en do SW1(config-if)#sw mo tru SW1(config-if)#end
同上, SW2也是这样. 现在进行Ping测试:
1 2 3 4 5
PC1#ping 192.168.1.3 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.3, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
PC1#ping 192.168.1.4 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.4, timeout is 2 seconds: ..... Success rate is 0 percent (0/5)
SW2(config)#int e0/0 SW2(config-if)#sw tr *Sep 19 15:21:23.782: %CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on Ethernet0/0 (1), with SW1 Ethernet0/0 (10). SW2(config-if)#sw tr na vlan 20 SW2(config-if)#end
刚刚配好SW1的时候你会发现有报错, 也就是本征VLAN不匹配的报错, 不用管它.
这个报错会一直跟随着你,但是:
1 2 3 4 5
PC1#ping 192.168.1.4 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.4, timeout is 2 seconds: .!!!! Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/1 ms
啊哈哈哈, 竟然通了! 真神奇!
但是遗憾的是:
1 2 3 4 5
PC1#ping 192.168.1.3 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.3, timeout is 2 seconds: ..... Success rate is 0 percent (0/5)
PC1#ping 192.168.1.200 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.200, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 5/5/6 ms
没问题!和你想的是否一样呢?
哈哈哈你是不是觉得就算通了, 其实效率很低呢? 我们再来试试:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
PC1#ping 192.168.1.200 repeat 1000 Type escape sequence to abort. Sending 1000, 100-byte ICMP Echos to 192.168.1.200, timeout is 2 seconds: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!! Success rate is 100 percent (1000/1000), round-trip min/avg/max = 1/2/21 ms
VLAN0010 Spanning tree enabled protocol rstp Root ID Priority 10 Address aabb.cc00.0200 Cost 100 Port 2 (Ethernet0/1) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10) Address aabb.cc00.0100 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 sec
SW1#sh ip int b Interface IP-Address OK? Method Status Protocol Ethernet0/0 unassigned YES unset up up Ethernet0/1 unassigned YES unset up up Ethernet0/2 unassigned YES unset up up
VLAN0010 Spanning tree enabled protocol rstp Root ID Priority 10 Address aabb.cc00.0200 Cost 100 Port 2 (Ethernet0/1) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10) Address aabb.cc00.0100 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 sec
VLAN0010 Spanning tree enabled protocol rstp Root ID Priority 10 Address aabb.cc00.0200 Cost 100 Port 2 (Ethernet0/1) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10) Address aabb.cc00.0100 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 sec
VLAN0010 Spanning tree enabled protocol rstp Root ID Priority 32778 Address aabb.cc00.0100 This bridge is the root Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10) Address aabb.cc00.0100 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 sec
VLAN0010 Spanning tree enabled protocol rstp Root ID Priority 10 Address aabb.cc00.0200 This bridge is the root Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 10 (priority 4096 sys-id-ext 10) Address aabb.cc00.0200 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 sec
VLAN0010 Spanning tree enabled protocol rstp Root ID Priority 10 Address aabb.cc00.0200 Cost 100 Port 2 (Ethernet0/1) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10) Address aabb.cc00.0100 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 sec
VLAN0010 Spanning tree enabled protocol rstp Root ID Priority 10 Address aabb.cc00.0200 Cost 100 Port 2 (Ethernet0/1) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10) Address aabb.cc00.0100 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 sec
SW1(config-if)#spanning-tree portfast %Warning: portfast should only be enabled on ports connected to a single host. Connecting hubs, concentrators, switches, bridges, etc... to this interface when portfast is enabled, can cause temporary bridging loops. Use with CAUTION
%Portfast has been configured on Ethernet0/0 but will only have effect when the interface is in a non-trunking mode.
SW1(config)#int e0/1 SW1(config-if)#span bpdug enab SW1(config-if)#end SW1# *Sep 20 12:29:53.672: %SPANTREE-2-BLOCK_BPDUGUARD: Received BPDU on port Et0/1 with BPDU Guard enabled. Disabling port. *Sep 20 12:29:53.672: %PM-4-ERR_DISABLE: bpduguard error detected on Et0/1, putting Et0/1 in err-disable state SW1# *Sep 20 12:29:54.248: %SYS-5-CONFIG_I: Configured from console by console *Sep 20 12:29:54.683: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to down SW1# *Sep 20 12:29:55.684: %LINK-3-UPDOWN: Interface Ethernet0/1, changed state to down
直接就被关闭了. 现在查看端口显示:
1 2
SW1#sh int e0/1 Ethernet0/1 is down, line protocol is down (err-disabled)
这里的err-disable可以进行自动回复, 还可以一定间隔自动回复:
1 2
SW1(config)#errdisable recovery cause bpduguard SW1(config)#errdisable recovery interval 30
VLAN0010 Spanning tree enabled protocol rstp Root ID Priority 32778 Address aabb.cc00.0300 Cost 100 Port 2 (Ethernet0/1) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10) Address aabb.cc00.0500 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 sec
VLAN0010 Spanning tree enabled protocol rstp Root ID Priority 32778 Address aabb.cc00.0300 This bridge is the root Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10) Address aabb.cc00.0300 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 sec
SW1(config-if-range)#channel-group 1 mode active Creating a port-channel interface Port-channel 1
SW1(config-if-range)# *Sep 21 04:00:19.927: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to down *Sep 21 04:00:19.927: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/2, changed state to down SW1(config-if-range)# *Sep 21 04:00:21.192: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/2, changed state to up *Sep 21 04:00:21.192: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to up SW1(config-if-range)# *Sep 21 04:00:27.353: %EC-5-L3DONTBNDL2: Et0/1 suspended: LACP currently not enabled on the remote port. *Sep 21 04:00:27.374: %EC-5-L3DONTBNDL2: Et0/2 suspended: LACP currently not enabled on the remote port. SW1(config-if-range)#
SW1#sh etherchannel summary Flags: D - down P - bundled in port-channel I - stand-alone s - suspended H - Hot-standby (LACP only) R - Layer3 S - Layer2 U - in use N - not in use, no aggregation f - failed to allocate aggregator
M - not in use, minimum links not met m - not in use, port not aggregated due to minimum links not met u - unsuitable for bundling w - waiting to be aggregated d - default port
A - formed by Auto LAG
Number of channel-groups in use: 1 Number of aggregators: 1
Group Port-channel Protocol Ports ------+-------------+-----------+----------------------------------------------- 1 Po1(SU) LACP Et0/1(P) Et0/2(P)
U即表示已经在使用.
那么这个时候我们的生成树会变成什么样的呢? 很好奇吧, 我们来看一下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
SW2#sh span vlan 10
VLAN0010 Spanning tree enabled protocol rstp Root ID Priority 32778 Address aabb.cc00.0300 This bridge is the root Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10) Address aabb.cc00.0300 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 sec
SW2#sh int Po1 Port-channel1 is up, line protocol is up (connected) Hardware is EtherChannel, address is aabb.cc00.0310 (bia aabb.cc00.0310) MTU 1500 bytes, BW 20000 Kbit/sec, DLY 1000 usec, ...(omitted)
SW#sh vtp status VTP Version capable : 1 to 3 VTP version running : 1 VTP Domain Name : VTP Pruning Mode : Disabled VTP Traps Generation : Disabled Device ID : aabb.cc80.0200 Configuration last modified by 0.0.0.0 at 0-0-00 00:00:00 Local updater ID is 0.0.0.0 (no valid interface found)
SW1#sh vtp status VTP Version capable : 1 to 3 VTP version running : 2 VTP Domain Name : jky VTP Pruning Mode : Disabled VTP Traps Generation : Disabled Device ID : aabb.cc80.0100 Configuration last modified by 0.0.0.0 at 9-21-17 05:23:53 Local updater ID is 0.0.0.0 (no valid interface found)
SW2(config)#vtp pas jky507 Setting device VTP password to jky507 SW2(config)#end SW2#sh vlan *Sep 21 05:31:32.763: %SYS-5-CONFIG_I: Configured from console by console SW2#sh vlan b
VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Et0/0, Et0/2, Et0/3, Et1/0 Et1/1, Et1/2, Et1/3, Et2/0 Et2/1, Et2/2, Et2/3, Et3/0 Et3/1, Et3/2, Et3/3 1002 fddi-default act/unsup 1003 trcrf-default act/unsup 1004 fddinet-default act/unsup 1005 trbrf-default act/unsup SW2#sh vtp status VTP Version capable : 1 to 3 VTP version running : 2 VTP Domain Name : jky VTP Pruning Mode : Disabled VTP Traps Generation : Disabled Device ID : aabb.cc80.0500 Configuration last modified by 0.0.0.0 at 9-21-17 05:23:53 Local updater ID is 0.0.0.0 (no valid interface found)
SW3(config)#int e0/0 SW3(config-if)#sw tr en do SW3(config-if)#sw mo tr SW3(config-if)#end
接着我们尝试一下client模式.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
SW3(config)#vtp mode client Setting device to VTP Client mode for VLANS. SW3(config)#do sh vtp status VTP Version capable : 1 to 3 VTP version running : 1 VTP Domain Name : VTP Pruning Mode : Disabled VTP Traps Generation : Disabled Device ID : aabb.cc80.0300 Configuration last modified by 0.0.0.0 at 0-0-00 00:00:00
SW3(config)#vtp password jky507 Setting device VTP password to jky507 SW3(config)#vtp version 2 Cannot modify version in VTP client mode unless the system is in VTP version 3 SW3(config)#vtp domain jky Changing VTP domain name from NULL to jky
HQ(config)#int e0/0 HQ(config-if)#standby 1 ip 192.168.1.254 HQ(config-if)#^Z ...(omitted) *Sep 21 06:53:11.122: %HSRP-5-STATECHANGE: Ethernet0/0 Grp 1 state Standby -> Active
看到输出, e0/0的第一组状态变成了Active.
我们把Branch也设置成同样的.
1 2 3 4 5 6 7
Branch(config)#int e0/0 Branch(config-if)#standby 1 ip 192.168.1.254 Branch(config-if)#^Z Branch# *Sep 21 06:54:43.377: %SYS-5-CONFIG_I: Configured from console by console Branch# *Sep 21 06:55:06.347: %HSRP-5-STATECHANGE: Ethernet0/0 Grp 1 state Speak -> Standby
此时的Branch就相当是一台热备路由了. 我们来观察一下standby的状态:
1 2 3 4 5
Branch#sh standby b P indicates configured to preempt. | Interface Grp Pri P State Active Standby Virtual IP Et0/0 1 100 Standby 192.168.1.20 local 192.168.1.254
Branch#sh standby b P indicates configured to preempt. | Interface Grp Pri P State Active Standby Virtual IP Et0/0 1 125 Standby 192.168.1.20 local 192.168.1.254
改是改过来了, 但是就没有切换状态呀.
这个时候, 就需要Branch主动发出请求了, 也就是需要进行一个属性的调用:
1 2 3 4
Branch(config-if)#standby 1 preempt Branch(config-if)#^Z Branch# *Sep 21 07:01:11.706: %HSRP-5-STATECHANGE: Ethernet0/0 Grp 1 state Standby -> Active
同时, HQ那边也还会有提示:
1 2 3 4
HQ# *Sep 21 07:01:11.707: %HSRP-5-STATECHANGE: Ethernet0/0 Grp 1 state Active -> Speak HQ# *Sep 21 07:01:22.034: %HSRP-5-STATECHANGE: Ethernet0/0 Grp 1 state Speak -> Standby
最后我们来Ping这虚拟IP试试吧:
1 2 3 4 5
HQ#ping 192.168.1.254 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.254, timeout is 2 seconds: .!!!! Success rate is 80 percent (4/5), round-trip min/avg/max = 1/3/6 ms
Branch#conf ter Enter configuration commands, one per line. End with CNTL/Z. Branch(config)#int e0/0.10 Branch(config-subif)#en Branch(config-subif)#encapsulation do Branch(config-subif)#encapsulation dot1Q 10 Branch(config-subif)#ip addr 10.1.10.254 255.255.255.0 Branch(config-subif)#exi Branch(config)#int e0/0.20 Branch(config-subif)#en do 20 Branch(config-subif)#ip addr 10.1.20.254 255.255.255.0 Branch(config-subif)#exi Branch(config)#int e0/0 Branch(config-if)#no sh Branch(config-if)#^Z Branch# *Sep 21 08:47:44.945: %SYS-5-CONFIG_I: Configured from console by console Branch# *Sep 21 08:47:46.257: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up *Sep 21 08:47:47.266: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up
好, 进行测试. 激动人心的时刻到了:
1 2 3 4 5
PC2#ping 10.1.10.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.10.100, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
太好了:
1 2 3 4 5
PC1#ping 10.1.20.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.20.100, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
SW#sh ip rout S* 0.0.0.0/0 [1/0] via 192.168.3.254, Vlan30 192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.1.0/24 is directly connected, Vlan10 L 192.168.1.100/32 is directly connected, Vlan10 192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.2.0/24 is directly connected, Vlan20 L 192.168.2.100/32 is directly connected, Vlan20 192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.3.0/24 is directly connected, Vlan30 L 192.168.3.100/32 is directly connected, Vlan30
SW#sh run int e0/1 Building configuration...
Current configuration : 80 bytes ! interface Ethernet0/1 switchport access vlan 10 switchport mode access end
SW#sh spanning-tree vlan 10
VLAN0010 Spanning tree enabled protocol rstp Root ID Priority 32778 Address aabb.cc00.0100 This bridge is the root Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10) Address aabb.cc00.0100 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type ------------------- ---- --- --------- -------- -------------------------------- Et0/1 Desg FWD 100 128.2 Shr Edge
interface Vlan1 no ip address shutdown ! interface Vlan10 ip address 192.168.1.100 255.255.255.0 ! interface Vlan20 ip address 192.168.2.100 255.255.255.0 ! interface Vlan30 ip address 192.168.3.100 255.255.255.0 ! ip forward-protocol nd
Branch#sh ip dhcp conflict IP address Detection method Detection time VRF Branch#clear ip dhcp conflict ? * Clear all address conflicts A.B.C.D Clear a specific conflict vrf DHCP vrf conflicts
Pool VLAN10 : Utilization mark (high/low) : 100 / 0 Subnet size (first/next) : 0 / 0 Total addresses : 254 Leased addresses : 1 Pending event : none 1 subnet is currently in the pool : Current index IP address range Leased addresses 10.1.10.2 10.1.10.1 - 10.1.10.254 1
Pool VLAN20 : Utilization mark (high/low) : 100 / 0 Subnet size (first/next) : 0 / 0 Total addresses : 254 Leased addresses : 1 Pending event : none 1 subnet is currently in the pool : 10.1.20.2 10.1.20.1 - 10.1.20.254 1
如果是更想知道IP分配给了谁, 这样看:
1 2 3 4 5 6 7 8 9 10 11 12 13
Branch#sh ip dhcp binding Bindings from all pools not associated with VRF: IP address Client-ID/ Lease expiration Type Hardware address/ User name 10.1.10.1 0063.6973.636f.2d61. Sep 23 2017 01:40 AM Automatic 6162.622e.6363.3030. 2e30.3531.302d.4574. 302f.31 10.1.20.1 0063.6973.636f.2d61. Sep 23 2017 01:40 AM Automatic 6162.622e.6363.3030. 2e30.3431.302d.4574. 302f.31
Pool Branch : Utilization mark (high/low) : 100 / 0 Subnet size (first/next) : 0 / 0 Total addresses : 254 Leased addresses : 1 Pending event : none 1 subnet is currently in the pool : Current index IP address range Leased addresses 192.168.1.2 192.168.1.1 - 192.168.1.254 1 ---------------------- HQ#sh ip dhcp pool HQ
Pool HQ : Utilization mark (high/low) : 100 / 0 Subnet size (first/next) : 0 / 0 Total addresses : 254 Leased addresses : 1 Pending event : none 1 subnet is currently in the pool : Current index IP address range Leased addresses 192.168.2.2 192.168.2.1 - 192.168.2.254 1
还是惯例, Ping一下试试:
1 2 3 4 5
Branch#ping 172.16.2.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.16.2.100, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 5/5/6 ms
好啦 开始设置我们的BGP, 这样来:
1 2 3 4 5
Branch(config)#router bgp 100 Branch(config-router)#neighbor 172.16.2.100 remote-as 200 Branch(config-router)#end Branch# *Sep 22 11:57:34.347: %SYS-5-CONFIG_I: Configured from console by console
对面也这么设置, 过一小会就会有BGP的邻居up的消息:
1 2
Branch# *Sep 22 11:58:12.494: %BGP-5-ADJCHANGE: neighbor 172.16.2.100 Up
激动人心的时候到啦, 我!要!通!信!
1 2 3 4 5
PC1#ping 192.168.2.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.16.2.100, timeout is 2 seconds: ..... Success rate is 0 percent (0/5)
PC1#ping 192.168.2.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 5/5/5 ms
建议, 在发布前, 中, 后经常查看一下路由表, 以及使用:
1 2 3 4 5 6 7 8 9 10 11 12 13
Branch#sh ip bgp BGP table version is 6, local router ID is 192.168.1.100 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, x best-external, a additional-path, c RIB-compressed, Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path * 172.16.0.0 172.16.2.100 0 0 200 i *> 0.0.0.0 0 32768 i *> 192.168.1.0 0.0.0.0 0 32768 i *> 192.168.2.0 172.16.2.100 0 0 200 i
你会有很多发现, 对BGP发布也会更理解.
OSPF
不想打字.
配置完成之后, 我们直接进行OSPF路由的设置:
1 2 3 4 5 6 7 8 9 10 11
Branch#conf ter Enter configuration commands, one per line. End with CNTL/Z. Branch(config)#router ospf 1 Branch(config-router)#router-id 1.1.1.1 Branch(config-router)#exi Branch(config)#int e0/0 Branch(config-if)#ip ospf 1 area 0 Branch(config-if)#exi Branch(config)#int e0/1 Branch(config-if)#ip ospf 1 area 0 Branch(config-if)#end
Branch# *Sep 22 13:30:02.975: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on Ethernet0/0 from LOADING to FULL, Loading Done Branch#sh ip ospf nei
Neighbor ID Pri State Dead Time Address Interface 2.2.2.2 1 FULL/BDR 00:00:35 172.16.1.2 Ethernet0/0
好了, 这样就行了. 比BGP要容易多了!
1 2 3 4 5
PC1#ping 192.168.2.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.2.100, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 5/5/6 ms
接着, 没完. 你会发现有个东西不对劲:
1 2 3 4 5 6 7 8 9 10 11 12
Branch#sh ip ospf nei
Neighbor ID Pri State Dead Time Address Interface 2.2.2.2 1 FULL/DR 00:00:37 172.16.1.2 Ethernet0/0 Branch#sh ip ospf nei
Neighbor ID Pri State Dead Time Address Interface 2.2.2.2 1 FULL/DR 00:00:34 172.16.1.2 Ethernet0/0 Branch#sh ip ospf nei
Neighbor ID Pri State Dead Time Address Interface 2.2.2.2 1 FULL/DR 00:00:33 172.16.1.2 Ethernet0/0
Neighbor ID Pri State Dead Time Address Interface 1.1.1.1 1 FULL/BDR 00:00:00 172.16.1.1 Ethernet0/0 HQ#sh ip ospf nei HQ# *Sep 22 14:10:11.105: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on Ethernet0/0 from FULL to DOWN, Neighbor Down: Dead timer expired
Branch(config-if)# *Sep 22 14:16:46.466: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on Ethernet0/0 from FULL to DOWN, Neighbor Down: Dead timer expired
这个Hello时间, 要求必须一致. 所以一端改了, 另一端也是需要进行更改的.
1 2 3 4 5 6 7 8
HQ(config)#int e0/0 HQ(config-if)#ip ospf hello-interval 15 HQ(config-if)#end *Sep 22 14:18:07.735: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on Ethernet0/0 from LOADING to FULL, Loading Done HQ#sh ip ospf nei
Neighbor ID Pri State Dead Time Address Interface 1.1.1.1 1 FULL/BDR 00:00:58 172.16.1.1 Ethernet0/0
PC1#ping 192.168.2.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.2.100, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 5/5/6 ms
Branch#sh ip protocols ...(omitted) Routing Protocol is "rip" Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Sending updates every 30 seconds, next due in 3 seconds Invalid after 180 seconds, hold down 180, flushed after 240 Redistributing: rip Neighbor(s): 172.16.1.2 Default version control: send version 2, receive version 2 Interface Send Recv Triggered RIP Key-chain Ethernet0/0 2 2 Ethernet0/1 2 2 ..(omitted)
Branch(config)#int r e0/0 -1 Branch(config-if-range)#ip rip send version 1 2 Branch(config-if-range)#ip rip re version 1 2
现在其实已经通了. 因为由一方是两种版本都可使用的.
我们在实验时关闭了自动汇总功能, 这个汇总其实就是我们说的路由汇总啦.
PAP认证
实验拓扑异常简单:
其实只是为了展示一下PPP而已嘛
HQ一端做这样的处理:
1 2 3 4 5 6 7 8 9 10 11 12 13
HQ#conf ter Enter configuration commands, one per line. End with CNTL/Z. HQ(config)#int s2/0 HQ(config-if)#no sh HQ(config-if)#ip addr 202.10.100.10 255.255.255.0 HQ(config-if)#encapsulation ppp HQ(config-if)# *Sep 23 05:45:18.209: %LINK-3-UPDOWN: Interface Serial2/0, changed state to up HQ(config-if)#ppp authentication pap HQ(config-if)#exi HQ(config)#username justin password justin HQ(config)#service password-encryption HQ(config)#end
接着另外一端:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Branch(config)#in s2/0 Branch(config-if)#no sh Branch(config-if)#ip addr 202.102 *Sep 23 05:47:05.729: %LINK-3-UPDOWN: Interface Serial2/0, changed state to up *Sep 23 05:47:06.729: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up Branch(config-if)#ip addr 202.10.100.20 255.255.255.0 Branch(config-if)#en Branch(config-if)#encapsulation ppp *Sep 23 05:47:23.553: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to down Branch(config-if)#ppp pap sent-username justin password justi # 这里我故意输错密码 Branch(config-if)#ppp pap sent-username justin password justin Branch(config-if)# *Sep 23 05:48:32.410: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up Branch(config-if)#end Branch# *Sep 23 05:48:48.907: %SYS-5-CONFIG_I: Configured from console by console Branch#
我在另外一端打开了debug调试, 于是在收到了错误的密码之后, 信息:
1 2 3 4 5 6 7 8
*Sep 23 05:48:30.334: Se2/0 PPP: Using default call direction *Sep 23 05:48:30.334: Se2/0 PPP: Treating connection as a dedicated line *Sep 23 05:48:30.334: Se2/0 PPP: Session handle[3400000F] Session id[15] *Sep 23 05:48:30.354: Se2/0 PAP: I AUTH-REQ id 1 len 17 from "justin" *Sep 23 05:48:30.354: Se2/0 PAP: Authenticating peer justin *Sep 23 05:48:30.354: Se2/0 PPP: Sent PAP LOGIN Request *Sep 23 05:48:30.354: Se2/0 PPP: Received LOGIN Response FAIL *Sep 23 05:48:30.354: Se2/0 PAP: O AUTH-NAK id 1 len 26 msg is "Authentication failed"
密码正确之后, 双方都显示接口up, 并且:
1 2 3 4 5 6 7 8
*Sep 23 05:48:32.386: Se2/0 PPP: Using default call direction *Sep 23 05:48:32.386: Se2/0 PPP: Treating connection as a dedicated line *Sep 23 05:48:32.386: Se2/0 PPP: Session handle[39000010] Session id[16] *Sep 23 05:48:32.402: Se2/0 PAP: I AUTH-REQ id 1 len 18 from "justin" *Sep 23 05:48:32.402: Se2/0 PAP: Authenticating peer justin *Sep 23 05:48:32.403: Se2/0 PPP: Sent PAP LOGIN Request *Sep 23 05:48:32.403: Se2/0 PPP: Received LOGIN Response PASS *Sep 23 05:48:32.409: Se2/0 PAP: O AUTH-ACK id 1 len 5
CHAP
先来搞一个单向认证的, 十分简单:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Router1(config)#int s2/0 Router1(config-if)#no sh Router1(config-if)#ip add *Sep 23 06:07:37.658: %LINK-3-UPDOWN: Interface Serial2/0, changed state to up *Sep 23 06:07:38.666: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up Router1(config-if)#ip addr 202.10.100.10 255.255.255.0 Router1(config-if)#encapsulation ppp Router1(config-if)#ppp authn *Sep 23 06:07:56.329: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to down Router1(config-if)#ppp authen chap Router1(config-if)#exi Router1(config)#username justin password justin Router1(config)#service password-encryption Router1(config)#end
同样这个时候我打开了debug, 可以看到.
在我们为Router2设置的时候, router1一直在尝试进行挑战:
1 2 3 4
*Sep 23 06:11:13.788: Se2/0 PPP: Using default call direction *Sep 23 06:11:13.788: Se2/0 PPP: Treating connection as a dedicated line *Sep 23 06:11:13.788: Se2/0 PPP: Session handle[72000027] Session id[39] *Sep 23 06:11:13.822: Se2/0 CHAP: O CHALLENGE id 1 len 28 from "Router1"
接着当我们设置了正确的主机名和密码之后:
1 2 3 4 5 6 7 8 9 10
*Sep 23 06:14:23.736: Se2/0 PPP: Using default call direction *Sep 23 06:14:23.736: Se2/0 PPP: Treating connection as a dedicated line *Sep 23 06:14:23.736: Se2/0 PPP: Session handle[BE000047] Session id[70] *Sep 23 06:14:23.773: Se2/0 CHAP: O CHALLENGE id 1 len 28 from "Router1" *Sep 23 06:14:23.784: Se2/0 CHAP: I RESPONSE id 1 len 27 from "justin" *Sep 23 06:14:23.784: Se2/0 PPP: Sent CHAP LOGIN Request *Sep 23 06:14:23.784: Se2/0 PPP: Received LOGIN Response PASS *Sep 23 06:14:23.790: Se2/0 CHAP: O SUCCESS id 1 len 4 Router1# *Sep 23 06:14:23.790: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up
Router1(config-if)# *Sep 23 06:18:58.433: Se2/0 AUTH: Timeout 8 *Sep 23 06:18:58.433: Se2/0 CHAP: O CHALLENGE id 9 len 27 from "justin" *Sep 23 06:18:58.450: Se2/0 CHAP: I CHALLENGE id 9 len 27 from "justin" *Sep 23 06:18:58.450: Se2/0 CHAP: Ignoring Challenge with local name
另外一边:
1 2 3 4 5
Router2(config-if)# *Sep 23 06:19:08.457: Se2/0 AUTH: Timeout 9 *Sep 23 06:19:08.457: Se2/0 CHAP: O CHALLENGE id 10 len 27 from "justin" *Sep 23 06:19:08.457: Se2/0 CHAP: I CHALLENGE id 10 len 27 from "justin" *Sep 23 06:19:08.457: Se2/0 CHAP: Ignoring Challenge with local name
Current configuration : 197 bytes ! interface Serial2/0 ip address 202.10.100.10 255.255.255.0 encapsulation ppp ppp authentication chap ppp chap hostname justin ppp chap password 0 justin serial restart-delay 0 end --------- Router2#sh run int s2/0 Building configuration...
Current configuration : 197 bytes ! interface Serial2/0 ip address 202.10.100.20 255.255.255.0 encapsulation ppp ppp authentication chap ppp chap hostname justin ppp chap password 0 justin serial restart-delay 0 end
奇怪, 确认了也没有问题, 难道是用户名不能一样吗?
1
Router2(config)#username bieber password justin
接着:
1
Router1(config-if)#ppp chap hostname bieber
突然之间:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
*Sep 23 06:28:19.557: Se2/0 CHAP: O CHALLENGE id 9 len 27 from "justin" *Sep 23 06:28:19.558: Se2/0 CHAP: I CHALLENGE id 9 len 27 from "bieber" *Sep 23 06:28:19.558: Se2/0 PPP: Sent CHAP SENDAUTH Request *Sep 23 06:28:19.558: Se2/0 PPP: Received SENDAUTH Response PASS *Sep 23 06:28:19.558: Se2/0 CHAP: Using hostname from interface CHAP *Sep 23 06:28:19.558: Se2/0 CHAP: Using password from AAA *Sep 23 06:28:19.558: Se2/0 CHAP: O RESPONSE id 9 len 27 from "justin" *Sep 23 06:28:19.564: Se2/0 CHAP: I RESPONSE id 9 len 27 from "bieber" *Sep 23 06:28:19.564: Se2/0 PPP: Sent CHAP LOGIN Request *Sep 23 06:28:19.564: Se2/0 PPP: Received LOGIN Response PASS *Sep 23 06:28:19.570: Se2/0 CHAP: O SUCCESS id 9 len 4 *Sep 23 06:28:19.575: Se2/0 CHAP: I SUCCESS id 9 len 4 Router2# *Sep 23 06:28:19.576: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up