- Tracert每一次从1开始TTL递增,递增的过程中路径的所有路由器都会因为TTL超时回应路由器地址。
- Windows Tracert是通过ICMP实现的,Linux Tracert是通过UDP实现的。
- 10Mb/s(bit),10MB/s(Byte),8bit=1Byte
- 非屏蔽双绞线,屏蔽双绞线(线接地or贴墙,干扰小)
- 波长
- 单模光纤vs多模光纤
- 以太网媒介需求
- 直通线(平行线):用在不同层的网络设备之间
- 交叉线:用在同层的网络设备之间
- 直通线vs交叉线
- 登录设备:当第一次配置CISCO IOS设备时,通常我们通过console线登录设备。若主机没有console口,则需要通过USB转接线转换。
- 远程登陆:telnet 192.168.X.X
- 用户模式(User Mode)
- 特权模式
- 全局配置模式
- 上下文相关帮助
- 退出指令
Exit:逐层退出
Disable:特权模式退出到用户模式
End:特权模式以上的任意模式输入end直接退出到特权模式 - 设备预配
修改主机名
Switch(config)#hostname SW
SW(config)#
关闭域名解析
SW(config)#no ip domain-lookup
日志同步
SW(config)#line console 0
SW(config-line)#logging synchronous
永不超时
SW(config)#line console 0
SW(config-line)#exec-timeout 0 0
- 设备加密
Console口加密:
R1(config)#line console 0
R1(config-line)#password cisco
R1(config-line)#login
用户到特权模式加密:
R1(config)#enable password cisco123
推荐加密方式:
Console口加密:
R1(config)#username ccna privilege 1 secret cisco
R1(config)#line console 0
R1(config-line)#login local
用户到特权模式加密:
R1(config)#enable secret cisco
使用password加密在show running-config可以查看到用户名和密码
使用secret加密在show running-config无法查看到密码
20. 查看配置
使用copy running-config startup-config可以保存当前配置,或使用write指令。
-
网络组建步骤
A)拓扑设计----IP地址规划
B)配置
底层―所有设备的ip地址
路由
策略
安全
优化
C)测试
D)排错
E)维护 -
路由接口配置ip地址
Router>
Router>en
Router#
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#
Router(config)#hostname R1
R1(config)#
R1(config)#int g0/0
R1(config-if)#
R1(config-if)#ip address 12.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
R1(config-if)#
R1(config-if)#end
R1#show ip interface brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 12.1.1.1 YES manual up up
GigabitEthernet0/1 unassigned YES unset administratively down down
GigabitEthernet0/2 unassigned YES unset administratively down down
Vlan1 unassigned YES unset administratively down down -
接口状态 up up
-
DHCP工作过程的六个主要步骤
DHCP服务器提供三种IP分配方式:
A)自动分配(Automatic Allocation):自动分配是当DHCP客户端第一次成功地从DHCP服务器端分配到一个IP地址之后,就永远使用这个地址。
B)动态分配(Dynamic Allocation):动态分配是当DHCP客户端第一次从DHCP服务器分配到IP地址后,并非永久地使用该地址,每次使用完后,DHCP客户端就得释放这个IP地址,以给其他客户端使用。
C)手动分配:手动分配是由DHCP服务器管理员专门为客户端指定IP地址。
工作过程1:寻找DHCP服务器
当DHCP客户端第一次登录网络的时候,计算机发现本机上没有任何IP地址设定,将以广播方式发送DHCP discover发现信息来寻找DHCP服务器,即向255.255.255.255发送特定的广播信息。网络上每一台安装了TCP/IP协议的主机都会接收这个广播信息,但只有DHCP服务器才会做出响应。
工作过程2:分配IP地址
在网络中接收到DHCP discover发现信息的DHCP服务器就会做出响应,它从尚未分配的IP地址池中挑选一个分配给DHCP客户机,向DHCP客户机发送一个包含分配的IP地址和其他设置的DHCP offer提供信息。
工作过程3:接受IP地址
DHCP客户端接受到DHCP offer提供信息之后,选择第一个接收到的提供信息,然后以广播的方式回答一个DHCP request请求信息,该信息包含向它所选定的DHCP服务器请求IP地址的内容。
工作过程4:IP地址分配确认
当DHCP服务器收到DHCP客户端回答的DHCP request请求信息之后,便向DHCP客户端发送一个包含它所提供的IP地址和其他设置的DHCP ack确认信息,告诉DHCP客户端可以使用它提供的IP地址。然后,DHCP客户机便将其TCP/IP协议与网卡绑定,另外,除了DHCP客户机选中的DHCP服务器外,其他的DHCP服务器将收回曾经提供的IP地址。
工作过程5:重新登录
以后DHCP客户端每次重新登录网络时,就不需要再发送DHCP discover发现信息了,而是直接发送包含前一次所分配的IP地址的DHCP request请求信息。当DHCP服务器收到这一信息后,它会尝试让DHCP客户机继续使用原来的IP地址,并回答一个DHCP ack确认信息。如果此IP地址已无法再分配给原来的DHCP客户机使用时,则DHCP服务器给DHCP客户机回答一个DHCP nack否认信息。当原来的DHCP客户机收到此DHCP nack否认信息后,它就必须重新发送DHCP discover发现信息来请求新的IP地址。
客户端重新登录
如果客户端DHCP request 内的IP地址在服务器端没有被使用,DHCP服务器回复DHCP ACK继续使用IP。
如果客户端DHCP request 内的IP地址在服务器端已被使用,DHCP服务器回复DHCP NACK告诉客户端IP已被使用。
客户端重新开始DHCP流程。
工作过程6:更新租约
DHCP服务器向DHCP客户机出租的IP地址一般都有一个租借期限,期满后DHCP服务器便会收回出租的IP地址。如果DHCP客户机要延长其IP租约,则必须更新其IP租约。DHCP客户机启动时和IP租约期限到达租约的50%时,DHCP客户机都会自动向DHCP服务器发送更新其IP租约的信息。
配置路由器R1 int g0/1接口172.16.1.254,DHCP地址池为172.16.1.0,默认网关172.16.1.254, dns-server 8.8.8.8。
R1>
R1>en
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#
R1(config)#int g0/1
R1(config-if)#
R1(config-if)#ip add
R1(config-if)#ip address 172.16.1.254 255.255.255.0
R1(config-if)#no shut
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up
R1(config-if)#
R1(config-if)#exit
R1(config)#
R1(config)#
R1(config)#ip dhcp pool 172.16.1.0
R1(dhcp-config)#
R1(dhcp-config)#
R1(dhcp-config)#network 172.16.1.0 255.255.255.0
R1(dhcp-config)#def
R1(dhcp-config)#default-router 172.16.1.254
R1(dhcp-config)#
R1(dhcp-config)#dns
R1(dhcp-config)#dns-server 8.8.8.8
R1(dhcp-config)#
R1(dhcp-config)#
R1(dhcp-config)#end
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1#
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ip dhcp ex
R1(config)#ip dhcp excluded-address 172.16.1.200
R1(config)#
R1(config)#
R1(config)#ip dhcp excluded-address 172.16.1.210 172.16.1.250
R1(config)#
PC0选择DHCP获得IP地址,成功获取172.16.1.1,排除地址172.16.1.200和172.16.1.210-250
R1#
R1#show ip
R1#show ip route
R1#show ip route
Codes: L - local, 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, 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 - periodic downloaded static route
Gateway of last resort is not set
12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 12.1.1.0/24 is directly connected, GigabitEthernet0/0 通过0/0口连接了12.1.1.0/24的网段
L 12.1.1.1/32 is directly connected, GigabitEthernet0/0 本地接口IP
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.1.0/24 is directly connected, GigabitEthernet0/1 通过0/1口连接了172.16.1.0/24的网段
L 172.16.1.254/32 is directly connected, GigabitEthernet0/1 本地接口IP
R1#
R1#
R1#show ip int
R1#show ip interface br
R1#show ip interface brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 12.1.1.1 YES manual up up
GigabitEthernet0/1 172.16.1.254 YES manual up up
GigabitEthernet0/2 unassigned YES unset administratively down down
Vlan1 unassigned YES unset administratively down down
R1#
配置R1路由int g0/2接口ip地址172.16.2.254 255.255.255.0
R1#
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int g0/2
R1(config-if)#ip ad
R1(config-if)#ip address 172.16.2.254 255.255.255.0
R1(config-if)#no shu
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/2, changed state to up
R1(config-if)#
R1(config-if)#exit
R1(config)#
R1(config)#
R1(config)#end
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1#
R1#show ip in
R1#show ip interface br
R1#show ip interface brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 12.1.1.1 YES manual up up
GigabitEthernet0/1 172.16.1.254 YES manual up up
GigabitEthernet0/2 172.16.2.254 YES manual up up
Vlan1 unassigned YES unset administratively down down
R1#
配置R1 int g0/2接口地址池172.16.2.0,默认网关172.16.2.254, dns-server 8.8.8.8。
R1#
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ip dhcp pool 172.16.2.0
R1(dhcp-config)#net
R1(dhcp-config)#network 172.16.2.0 255.255.255.0
R1(dhcp-config)#de
R1(dhcp-config)#default-router 172.16.2.254
R1(dhcp-config)#dn
R1(dhcp-config)#dns-server 8.8.8.8
R1(dhcp-config)#
R1(dhcp-config)#
R1(dhcp-config)#exit
R1(config)#
R1(config)#
PC1选择DHCP获得IP地址,成功获取172.16.2.2。
PC2选择DHCP获得IP地址,成功获取172.16.2.3。
路由器show running-config可以看到有两个地址池
hostname R1
!
!
!
!
ip dhcp excluded-address 172.16.1.200
ip dhcp excluded-address 172.16.1.210 172.16.1.250
!
ip dhcp pool 172.16.1.0
network 172.16.1.0 255.255.255.0
default-router 172.16.1.254
dns-server 8.8.8.8
ip dhcp pool 172.16.2.0
network 172.16.2.0 255.255.255.0
default-router 172.16.2.254
dns-server 8.8.8.8
!
PC0可以ping通PC1(172.16.2.2)
- 路由器必须学习非直连路由
被路由的协议是IP吗?是
-
识别静态路由和动态路由
静态路由:网络管理员手工键入路由器的路由条目。
动态路由:通过动态路由协议自动学习到的路由条目。 -
写静态路由
将172.16.1.0 255.255.255.0网段写入路由R2接口g0/0
R2没有PC0所在的网段,告诉R2这个网段从哪个接口出,或这个网段的下一跳地址是谁
R2>
R2>en
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#ip route 172.16.1.0 255.255.255.0 ?
A.B.C.D Forwarding router’s address
Ethernet IEEE 802.3
FastEthernet FastEthernet IEEE 802.3
GigabitEthernet GigabitEthernet IEEE 802.3z
Loopback Loopback interface
Null Null interface
Serial Serial
Vlan Catalyst Vlans
R2(config)#ip route 172.16.1.0 255.255.255.0 g
R2(config)#ip route 172.16.1.0 255.255.255.0 gigabitEthernet 0/0
R2(config)#
R2(config)#
R2(config)#end
R2#
%SYS-5-CONFIG_I: Configured from console by console
R2#show ip route
Codes: L - local, 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, 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 - periodic downloaded static route
Gateway of last resort is not set
12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 12.1.1.0/24 is directly connected, GigabitEthernet0/0
L 12.1.1.2/32 is directly connected, GigabitEthernet0/0
172.16.0.0/24 is subnetted, 1 subnets
S 172.16.1.0/24 is directly connected, GigabitEthernet0/0
R2#
PC0 ping通路由R2(12.1.1.2)
- 路由器往出发包的原地址永远都是离这个网段最近的接口的地址(出接口的地址)。
路由器具有代理ARP(proxy arp)的功能,每一次地址有变化都会进行ARP查询,但是每一次结果都一样,都是这个接口的MAC,
下一跳写法,解决性能问题
R2>
R2>en
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#no ip route 172.16.1.0 255.255.255.0
R2(config)#
R2(config)#
R2(config)#ip route 172.16.1.0 255.255.255.0 12.1.1.1
R2(config)#
R2(config)#
R2(config)#end
R2#
%SYS-5-CONFIG_I: Configured from console by console
R2#
R2#show ip route
Codes: L - local, 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, 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 - periodic downloaded static route
Gateway of last resort is not set
12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 12.1.1.0/24 is directly connected, GigabitEthernet0/0
L 12.1.1.2/32 is directly connected, GigabitEthernet0/0
172.16.0.0/24 is subnetted, 1 subnets
S 172.16.1.0/24 [1/0] via 12.1.1.1
R2#
R2#show arp
Protocol Address Age (min) Hardware Addr Type Interface
Internet 12.1.1.1 130 0050.0F16.A801 ARPA GigabitEthernet0/0
Internet 12.1.1.2 - 0060.3E90.5101 ARPA GigabitEthernet0/0
Internet 172.16.1.1 19 0050.0F16.A801 ARPA GigabitEthernet0/0
R2#
-
最长匹配原则,如果都能匹配上,匹配掩码最长的。
-
负载均衡
当到达同一目的地,拥有多条开销相等的路径时,可以使数据拆分同时从多条路径传输。
将172.16.3.0 255.255.255.0写入R1,via 12.1.1.2
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ip route 172.16.3.0 255.255.255.0 12.1.1.2
R1(config)#end
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1#
R1#
R1#show ip route
Codes: C - connected, S - static, I - IGRP, 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, 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 - periodic downloaded static route
Gateway of last resort is not set
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0 出接口是Fa0/0
172.16.0.0/24 is subnetted, 3 subnets
C 172.16.1.0 is directly connected, FastEthernet0/1
C 172.16.2.0 is directly connected, FastEthernet1/0
S 172.16.3.0 [1/0] via 12.1.1.2
R1#
配置R1路由f1/1接口ip为21.1.1.1。
R1#
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#
R1(config)#int f1/1
R1(config-if)#ip ad
R1(config-if)#ip address 21.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface FastEthernet1/1, changed state to up
R1(config-if)#
R1(config-if)#
R1(config-if)#exit
R1(config)#
R1(config)#
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1#show ip route
Codes: C - connected, S - static, I - IGRP, 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, 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 - periodic downloaded static route
Gateway of last resort is not set
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
21.0.0.0/24 is subnetted, 1 subnets
C 21.1.1.0 is directly connected, FastEthernet1/1
172.16.0.0/24 is subnetted, 3 subnets
C 172.16.1.0 is directly connected, FastEthernet0/1
C 172.16.2.0 is directly connected, FastEthernet1/0
S 172.16.3.0 [1/0] via 12.1.1.2 只有一条路径
R1#
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#
R1(config)#
R1(config)#ip route 172.16.3.0 255.255.255.0 21.1.1.2 加路径
R1(config)#
R1(config)#
R1(config)#end
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1#
R1#show ip route
Codes: C - connected, S - static, I - IGRP, 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, 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 - periodic downloaded static route
Gateway of last resort is not set
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
21.0.0.0/24 is subnetted, 1 subnets
C 21.1.1.0 is directly connected, FastEthernet1/1
172.16.0.0/24 is subnetted, 3 subnets
C 172.16.1.0 is directly connected, FastEthernet0/1
C 172.16.2.0 is directly connected, FastEthernet1/0
S 172.16.3.0 [1/0] via 12.1.1.2
[1/0] via 21.1.1.2 R1两条路径
R1#
再写回来的包
R2#
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#
R2(config)#ip route 172.16.1.0 255.255.255.0 21.1.1.1
R2(config)#
R2(config)#end
R2#
%SYS-5-CONFIG_I: Configured from console by console
R2#
R2#show ip route
Codes: L - local, 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, 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 - periodic downloaded static route
Gateway of last resort is not set
12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 12.1.1.0/24 is directly connected, GigabitEthernet0/0
L 12.1.1.2/32 is directly connected, GigabitEthernet0/0
21.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 21.1.1.0/24 is directly connected, GigabitEthernet0/1
L 21.1.1.2/32 is directly connected, GigabitEthernet0/1
172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
S 172.16.1.0/24 [1/0] via 12.1.1.1
[1/0] via 21.1.1.1 R2也是两条路径
C 172.16.3.0/24 is directly connected, GigabitEthernet0/2
L 172.16.3.254/32 is directly connected, GigabitEthernet0/2
R2#
R2#
PC0 ping通R1 f1/0接口172.16.3.1,多路径负载均衡,一条路由通过多条路径转发最后抵达目的。
- 手工汇总
R2#
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#no ip route 172.16.1.0 255.255.255.0
R2(config)#no ip route 172.16.2.0 255.255.255.0
R2(config)#
R2(config)#ip route 172.16.0.0 255.255.252.0 12.1.1.1
R2(config)#
R2(config)#
R2(config)#end
R2#
%SYS-5-CONFIG_I: Configured from console by console
R2#
R2#show ip route
Codes: L - local, 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, 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 - periodic downloaded static route
Gateway of last resort is not set
12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 12.1.1.0/24 is directly connected, GigabitEthernet0/0
L 12.1.1.2/32 is directly connected, GigabitEthernet0/0
21.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 21.1.1.0/24 is directly connected, GigabitEthernet0/1
L 21.1.1.2/32 is directly connected, GigabitEthernet0/1
172.16.0.0/16 is variably subnetted, 3 subnets, 3 masks
S 172.16.0.0/22 [1/0] via 12.1.1.1 汇总
C 172.16.3.0/24 is directly connected, GigabitEthernet0/2
L 172.16.3.254/32 is directly connected, GigabitEthernet0/2
R2#
-
缺省路由
R1#Ip route 0.0.0.0 0.0.0.0 x.x.x.x -
空接口路由
R1#Ip route 172.16.0.0 255.255.252.0 null 0 配置在汇总网段的路由器上,防止一直转发出现环路。