目录
基于华三设备的操作
sys
interface GigabitEthernet 0/0 #对千兆端口0操作
ip add 192.168.1.1 24 #设置ip为192.168.1.1、子网掩码24位
interface GigabitEthernet 0/1 #对千兆端口1操作
ip add 192.168.2.1 24
ip route-static 192.168.13.0 24 192.168.12.2 #将目的为13.0的传输至 下一个端口ip为12.2的路由器,掩码24位
ip route-static 0.0.0.0 0.0.0.0 192.168.12.2 #设置默认路由,当路由器找不到目的网络的具体路由时,最后采取的路由
rip #采用rip协议
version 2 #采用v2
undo summary #取消聚合
network 192.168.10.0 #指定该网段使用rip协议
network 192.168.20.0
network 192.168.1.0
ospf 1 router-id 1.1.1.1 #ospf第一个进程,路由id为1.1.1.1
area 0 #第一个区域
network 192.168.10.0 0.0.0.255 #公布192.168.10.0网段,子网反码0.0.0.255
network 10.0.0.0 0.0.0.255
undo area 1 #删除区域1
dhcp enable #启动DHCP服务
dhcp server ip-pool 0 #创建命名为0的DHCP地址池
network 192.168.10.0 24 #ip范围,子网掩码24位
gateway-list 192.168.10.2 #网关设置为192.168.10.2
dns-list 192.168.10.3 #域名解析设置为192.168.10.3
expierd day 1 #租期为1天
dhcp server forbidden-ip 192.168.10.2 #禁止分配网关的IP(根据设备)
dhcp server forbidden-ip 192.168.10.3 #禁止分配DNS的IP(根据设备)
display ip routing-table #查询路由表
- 直接路由
同一网段下。
- 静态路由
- 动态路由
-
RIP(V2)
(与上图无关的操作)
-
OSPF
(与上图无关)
- DHCP
(与上图无关)
基于思科模拟器
- 需要5个网络,所以子网划分成 255.255.255.224 即 8个1.8个1.8个1.3个1(1110 0000),对于一个C类地址,所以2^3 = 8(可以等分成8段【用到前5段】,每32一段(.0) 1-31,(.32) 33-63,(.64) 65-96,(.96) 97-127,(.128) 129-159,(.160) 161-191,(.192) 193-223,(.224) 225-255【去头掐尾】)
# 路由器使用双绞线
# 添加拓展端口
# 启动端口(默认是不启动的)
配置及信息
- # 静态(左)
# Router2(左)
(ip router 0.0.0.0 0.0.0.0 192.168.3.34)
# Router 3(中)
(ip router 网络号 掩码 下一跳端口IP)
# Router4(右)
# 路由列表
Router2#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 192.168.3.34 to network 0.0.0.0 192.168.3.0/27 is subnetted, 2 subnets C 192.168.3.0 is directly connected, FastEthernet0/0 C 192.168.3.32 is directly connected, FastEthernet0/1 S* 0.0.0.0/0 [1/0] via 192.168.3.34 ---------------------------------------------------------------------------------------- Router3#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 192.168.3.0/27 is subnetted, 5 subnets S 192.168.3.0 [1/0] via 192.168.3.33 C 192.168.3.32 is directly connected, FastEthernet0/0 C 192.168.3.64 is directly connected, FastEthernet0/1 C 192.168.3.96 is directly connected, FastEthernet1/0 S 192.168.3.128 [1/0] via 192.168.3.98 ---------------------------------------------------------------------------------------- Router4#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 192.168.3.97 to network 0.0.0.0 192.168.3.0/27 is subnetted, 2 subnets C 192.168.3.96 is directly connected, FastEthernet0/0 C 192.168.3.128 is directly connected, FastEthernet0/1 S* 0.0.0.0/0 [1/0] via 192.168.3.97
- # RIP (中)
# Router0(左。其它类同,需进入CLI进一步配置)
en
confi t
# 进入(config)#
router rip
# 进入(config-router)#
# 声明
network 192.168.3.0
network 192.168.3.32
# 版本2(针对VLSM可变长子网掩码,但都会被汇聚为同一个网络)
version 2
(no auto-summary 不汇聚)
# 路由列表
Router0#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 192.168.3.0/27 is subnetted, 5 subnets C 192.168.3.0 is directly connected, FastEthernet0/0 C 192.168.3.32 is directly connected, FastEthernet0/1 R 192.168.3.64 [120/1] via 192.168.3.34, 00:00:29, FastEthernet0/1 R 192.168.3.96 [120/1] via 192.168.3.34, 00:00:29, FastEthernet0/1 R 192.168.3.128 [120/2] via 192.168.3.34, 00:00:29, FastEthernet0/1 -------------------------------------------------------------------------------------- Router1#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 192.168.3.0/27 is subnetted, 5 subnets R 192.168.3.0 [120/1] via 192.168.3.33, 00:00:12, FastEthernet0/0 C 192.168.3.32 is directly connected, FastEthernet0/0 C 192.168.3.64 is directly connected, FastEthernet0/1 C 192.168.3.96 is directly connected, FastEthernet1/0 R 192.168.3.128 [120/1] via 192.168.3.98, 00:00:04, FastEthernet1/0 -------------------------------------------------------------------------------------- Router5#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 192.168.3.0/27 is subnetted, 5 subnets R 192.168.3.0 [120/2] via 192.168.3.97, 00:00:18, FastEthernet0/0 R 192.168.3.32 [120/1] via 192.168.3.97, 00:00:18, FastEthernet0/0 R 192.168.3.64 [120/1] via 192.168.3.97, 00:00:18, FastEthernet0/0 C 192.168.3.96 is directly connected, FastEthernet0/0 C 192.168.3.128 is directly connected, FastEthernet0/1
- # OSPF(右,在配置RIP前,提前复制)
# CpRouter0
en
confi t
# 进入(config)#
# 需要定义进程号(这是对于本地主机而言,不同主机自然也可以不同)
router ospf 3
# 进入(config-router)#
#(路由器所拥有的网络号,该网络号子网掩码的反码【255.255.255.224 五个子网下掩码 的 反码 255-224=31 故 0.0.0.31 且wildcard-mask只能为奇数】,区域 0为【主干】。当然相同直连网络需要相同area号)
network 192.168.3.0 0.0.0.31 area 0
network 192.168.3.32 0.0.0.31 area 0
# CpRouter1
router ospf 3
network 192.168.3.32 0.0.0.31 area 0
network 192.168.3.64 0.0.0.31 area 0
network 192.168.3.96 0.0.0.31 area 0
# CpRouter5
router ospf 3
network 192.168.3.96 0.0.0.31 area 0
network 192.168.3.128 0.0.0.31 area 0
# 路由列表
CpRouter0#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 192.168.3.0/27 is subnetted, 5 subnets C 192.168.3.0 is directly connected, FastEthernet0/0 C 192.168.3.32 is directly connected, FastEthernet0/1 O 192.168.3.64 [110/2] via 192.168.3.34, 00:49:06, FastEthernet0/1 O 192.168.3.96 [110/2] via 192.168.3.34, 00:49:06, FastEthernet0/1 O 192.168.3.128 [110/3] via 192.168.3.34, 00:49:06, FastEthernet0/1 --------------------------------------------------------------------------------------- CpRouter1#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 192.168.3.0/27 is subnetted, 5 subnets O 192.168.3.0 [110/2] via 192.168.3.33, 00:48:26, FastEthernet0/0 C 192.168.3.32 is directly connected, FastEthernet0/0 C 192.168.3.64 is directly connected, FastEthernet0/1 C 192.168.3.96 is directly connected, FastEthernet1/0 O 192.168.3.128 [110/2] via 192.168.3.98, 00:48:26, FastEthernet1/0 --------------------------------------------------------------------------------------- CpRouter5#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 192.168.3.0/27 is subnetted, 5 subnets O 192.168.3.0 [110/3] via 192.168.3.97, 00:45:57, FastEthernet0/0 O 192.168.3.32 [110/2] via 192.168.3.97, 00:45:57, FastEthernet0/0 O 192.168.3.64 [110/2] via 192.168.3.97, 00:45:57, FastEthernet0/0 C 192.168.3.96 is directly connected, FastEthernet0/0 C 192.168.3.128 is directly connected, FastEthernet0/1
PC配置IP和对应直连端口为网关。
如图,相同直连网络需要相同area号。
- 单臂路由
# 交换机划分vlan2、3,配置Router2 f0/0端口子端口0.1和0.2(对应vlan和网关),PC配置IP和网关
- SW0:
# 进入#
vlan database
vlan 2 name vlan2
vlan 3 name vlan3
ex
conf t
# 进入(config)#
# 端口加入vlan
in f0/1
switchport access vlan 2
ex
in f0/2
switchport access vlan 3
ex
in f0/3
switchport mode truk
in f0/4
switchport mode truk
- SW1类同
- Router2
# 进入(config)#
# 进入0/0.1子端口,封装协议于vlan2,设置IP及PC机网关
in f0/0.1
encapsulation dot1Q 2
ip address 192.168.3.1 255.255.255.192
ex
in f0/0.2
encapsulation dot1Q 3
ip address 192.168.3.129 255.255.255.192
ex
in f0/1
ip add 192.168.3.193 255.255.255.192
ex
# 使用RIP 2协议
router rip
network 192.168.3.0
version 2
# no auto-summary
- Router 5 同样也设置端口IP和路由协议