一、基础拓朴图
这是上篇文章结束时的拓朴图,这次的配置也是基于这个拓扑进行配置的
二、配置内网DNS和HTTP服务器
使用:两台服务器,一台HTTP服务器,一台DNS服务器
为DNS服务器和HTTP服务器分配ip和网关,并把这两个对应的核心交换机上的端口划分到vlan70域中
先创建一个vlan70域,并把两个端口划分到vlan70域中
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 70
Switch(config-vlan)#int f0/3
Switch(config-if)#switchport access vlan 70
Switch(config-if)#int g0/1
Switch(config-if)#switchport access vlan 70
除去常规的为DNS和HTTP服务器配置IP和网关之外
这里需要在DNS服务器上为HTTP服务器只当一下ip地址和域名
并且打开DNS服务
在核心交换机上给vlan70一个网关地址
给完网关地址后查看一下路由表,多出了192.168.7.0/24这个网段就对了
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int vlan 70
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan70, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan70, changed state to up
Switch(config-if)#ip address 192.168.7.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#do 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
R 192.168.1.0/24 [120/1] via 192.168.5.1, 00:00:03, Vlan50
R 192.168.2.0/24 [120/1] via 192.168.5.1, 00:00:03, Vlan50
R 192.168.3.0/24 [120/1] via 192.168.6.1, 00:00:25, Vlan60
R 192.168.4.0/24 [120/1] via 192.168.6.1, 00:00:25, Vlan60
192.168.5.0/30 is subnetted, 1 subnets
C 192.168.5.0 is directly connected, Vlan50
192.168.6.0/30 is subnetted, 1 subnets
C 192.168.6.0 is directly connected, Vlan60
C 192.168.7.0/24 is directly connected, Vlan70
配置一下rip协议,把刚配置的vlan70对应的192.168.7.0这个网段加入到rip协议中
Switch(config-if)#router rip
Switch(config-router)#version 2
Switch(config-router)#network 192.168.7.0
Switch(config-router)#no auto-summary
测试一下:PC0 ping一下HTTP服务器(192.168.7.100)
可以ping通,说明配置完成
之后要对域名进行解析还需要配置一下PC机的DNS地址,否则就算ip可达,域名也无法解析
三、配置外网网络
使用:两台2911路由器、一台HTTP服务器、一台PC机
1、添加两台路由器
添加两台2911路由器,并为其各添加一个HWIC-2T模块,使其多出两个串口以供使用
关闭电源——>选中模块——>将模块拖到图中所示位置——>打开电源
2、连线并进行基本配置
添加完模块之后按如图所示连线
接下来可以看到图中的连线的灯都是红的,说明线路不通
路由器的接口开关需要手动打开,类似下面这样
依次打开所有开关,线路就通了
按照如图所示为其各部分配置ip地址和网关等信息
首先是在核心交换机上为g0/2进行配置
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int g0/2
Switch(config-if)#no switchport
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/2, changed state to up
Switch(config-if)#ip address 192.168.15.1 255.255.255.252
Switch(config-if)#no shutdown
第一个路由器的g0/0端口
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int g0/0
Router(config-if)#ip address 192.168.15.2 255.255.255.252
Router(config-if)#no shutdown
第一个路由器的s0/3/0端口
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int s0/3/0
Router(config-if)#ip address 192.168.16.2 255.255.255.252
Router(config-if)#no shutdown
第二个路由器的s0/3/0端口
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int s0/3/0
Router(config-if)#ip address 192.168.16.1 255.255.255.252
Router(config-if)#no shutdown
第二个路由器的g0/0端口
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int g0/0
Router(config-if)#ip address 192.167.100.1 255.255.255.0
Router(config-if)#no shutdown
第二个路由器的g0/1端口
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int g0/1
Router(config-if)#ip address 192.169.100.1 255.255.255.0
Router(config-if)#no shutdown
3、路由器跳转配置
首先配置外网即右边那个路由器
配置走向内网的流量全部下一跳为192.168.16.2
内网的网段计算是20位子网掩码的192.168.0.0网段
此网段ip为(192.168.0.1-192.168.15.254,共4094个可用ip)
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#ip route 192.168.0.0 255.255.240.0 192.168.16.2
Router(config)#do 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
192.167.100.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.167.100.0/24 is directly connected, GigabitEthernet0/0
L 192.167.100.1/32 is directly connected, GigabitEthernet0/0
S 192.168.0.0/20 [1/0] via 192.168.16.2 //有了这个就说明配置成功了
192.168.16.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.16.0/30 is directly connected, Serial0/3/0
L 192.168.16.1/32 is directly connected, Serial0/3/0
192.169.100.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.169.100.0/24 is directly connected, GigabitEthernet0/1
L 192.169.100.1/32 is directly connected, GigabitEthernet0/1
配置内网路由器,即左边这个路由器
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#ip route 0.0.0.0 0.0.0.0 192.168.16.1
Router(config)#do 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 192.168.16.1 to network 0.0.0.0
192.168.15.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.15.0/30 is directly connected, GigabitEthernet0/0
L 192.168.15.2/32 is directly connected, GigabitEthernet0/0
192.168.16.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.16.0/30 is directly connected, Serial0/3/0
L 192.168.16.2/32 is directly connected, Serial0/3/0
S* 0.0.0.0/0 [1/0] via 192.168.16.1 //出现这个就说明配置成功了
配置一下核心交换机的路由转发
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#ip route 0.0.0.0 0.0.0.0 192.168.15.2
Switch(config)#do 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.15.2 to network 0.0.0.0
R 192.168.1.0/24 [120/1] via 192.168.5.1, 00:00:20, Vlan50
R 192.168.2.0/24 [120/1] via 192.168.5.1, 00:00:20, Vlan50
R 192.168.3.0/24 [120/1] via 192.168.6.1, 00:00:03, Vlan60
R 192.168.4.0/24 [120/1] via 192.168.6.1, 00:00:03, Vlan60
192.168.5.0/30 is subnetted, 1 subnets
C 192.168.5.0 is directly connected, Vlan50
192.168.6.0/30 is subnetted, 1 subnets
C 192.168.6.0 is directly connected, Vlan60
C 192.168.7.0/24 is directly connected, Vlan70
192.168.15.0/30 is subnetted, 1 subnets
C 192.168.15.0 is directly connected, GigabitEthernet0/2
S* 0.0.0.0/0 [1/0] via 192.168.15.2 //出现这个就代表配置成功了
除去这三个之外,还要配置一下下面两个三层交换机
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#ip route 0.0.0.0 0.0.0.0 192.168.15.2
Switch(config)#do 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.15.2 to network 0.0.0.0
C 192.168.1.0/24 is directly connected, Vlan10
C 192.168.2.0/24 is directly connected, Vlan20
R 192.168.3.0/24 [120/2] via 192.168.5.2, 00:00:27, Vlan50
R 192.168.4.0/24 [120/2] via 192.168.5.2, 00:00:27, Vlan50
192.168.5.0/30 is subnetted, 1 subnets
C 192.168.5.0 is directly connected, Vlan50
192.168.6.0/30 is subnetted, 1 subnets
R 192.168.6.0 [120/1] via 192.168.5.2, 00:00:27, Vlan50
R 192.168.7.0/24 [120/1] via 192.168.5.2, 00:00:27, Vlan50
192.168.15.0/30 is subnetted, 1 subnets
R 192.168.15.0 [120/1] via 192.168.5.2, 00:00:27, Vlan50
192.168.16.0/30 is subnetted, 1 subnets
R 192.168.16.0 [120/2] via 192.168.5.2, 00:00:27, Vlan50
S* 0.0.0.0/0 [1/0] via 192.168.15.2 //出现这个就是配置成功了
4、RIP协议配置
配置核心交换机的RIP协议
添加两个网段(内网和外网)
Switch#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.15.2 to network 0.0.0.0
R 192.168.1.0/24 [120/1] via 192.168.5.1, 00:00:24, Vlan50
R 192.168.2.0/24 [120/1] via 192.168.5.1, 00:00:24, Vlan50
R 192.168.3.0/24 [120/1] via 192.168.6.1, 00:00:04, Vlan60
R 192.168.4.0/24 [120/1] via 192.168.6.1, 00:00:04, Vlan60
192.168.5.0/30 is subnetted, 1 subnets
C 192.168.5.0 is directly connected, Vlan50
192.168.6.0/30 is subnetted, 1 subnets
C 192.168.6.0 is directly connected, Vlan60
C 192.168.7.0/24 is directly connected, Vlan70
192.168.15.0/30 is subnetted, 1 subnets
C 192.168.15.0 is directly connected, GigabitEthernet0/2
192.168.16.0/30 is subnetted, 1 subnets
R 192.168.16.0 [120/1] via 192.168.15.2, 00:00:45, GigabitEthernet0/2
S* 0.0.0.0/0 [1/0] via 192.168.15.2
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#router rip
Switch(config-router)#version 2
Switch(config-router)#network 192.168.15.0
Switch(config-router)#network 192.168.16.0
Switch(config-router)#no auto-summary
配置内网路由器的RIP协议
Router#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 192.168.16.1 to network 0.0.0.0
R 192.168.1.0/24 [120/2] via 192.168.15.1, 00:02:57, GigabitEthernet0/0
R 192.168.2.0/24 [120/2] via 192.168.15.1, 00:02:57, GigabitEthernet0/0
R 192.168.3.0/24 [120/2] via 192.168.15.1, 00:02:57, GigabitEthernet0/0
R 192.168.4.0/24 [120/2] via 192.168.15.1, 00:02:57, GigabitEthernet0/0
192.168.5.0/30 is subnetted, 1 subnets
R 192.168.5.0/30 [120/1] via 192.168.15.1, 00:02:57, GigabitEthernet0/0
192.168.6.0/30 is subnetted, 1 subnets
R 192.168.6.0/30 [120/1] via 192.168.15.1, 00:02:57, GigabitEthernet0/0
R 192.168.7.0/24 [120/1] via 192.168.15.1, 00:02:57, GigabitEthernet0/0
192.168.15.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.15.0/30 is directly connected, GigabitEthernet0/0
L 192.168.15.2/32 is directly connected, GigabitEthernet0/0
192.168.16.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.16.0/30 is directly connected, Serial0/3/0
L 192.168.16.2/32 is directly connected, Serial0/3/0
S* 0.0.0.0/0 [1/0] via 192.168.16.1
Router#
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#router rip
Router(config-router)#version 2
Router(config-router)#network 192.168.15.0
Router(config-router)#network 192.168.16.0
Router(config-router)#no auto-summary
外网路由器是不需要配置RIP协议的
这时,内外网所有ip都是互通的了
5、添加外网服务器DNS解析
在DNS服务器上再添加一条DNS解析信息
四、验证整体网络的连通性
1、外网互相访问
2、内网互相访问