思科模拟简单校园网

模拟简单校园网络

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-it5LR9FA-1657337630104)(C:\Users\DHX83\AppData\Roaming\Typora\typora-user-images\image-20220709111503164.png)]

一、二层交换机配置,划分vlan

宿舍vlan10,教学楼vlan20,宿舍网为1.1.1.0/24网段,教学楼网段为2.2.2.0/24网段

1.DHCP服务器配置

桌面–>IP配置–>配置相关vlan网段的网关,子网掩码

DHCP(宿舍)

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-8tJ4Wrlq-1657337391387)(C:\Users\DHX83\AppData\Roaming\Typora\typora-user-images\image-20220709111035411.png)]

2.宿舍交换机配置

fa0/2 vlan 10
fa0/1 trunk

Switch#config
Switch#configure t
Switch#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname sw1
sw1(config)#vlan 10
sw1(config-vlan)#exit
sw1(config)#int
sw1(config)#interface f
sw1(config)#interface fastEthernet 0/2
sw1(config-if)#sw
sw1(config-if)#switchport a
sw1(config-if)#switchport access v
sw1(config-if)#switchport access vlan 10
sw1(config-if)#exit
sw1(config)#in
sw1(config)#interface f
sw1(config)#interface fastEthernet 0/1
sw1(config-if)#sw
sw1(config-if)#switchport m
sw1(config-if)#switchport mode t
sw1(config-if)#switchport mode trunk 

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

sw1(config-if)#
sw1(config-if)#exit
sw1(config)#

同理配置两个教室交换机sw1、sw2,配置vlan 20

3.交换机sw0配置

分别给DHCP(宿舍)、DHCP(教学楼)划分vlan,用于各个网段的DHCP配置,其他接口设置为trunk模式

Switch>
Switch>
Switch>en
Switch#conf
Switch#configure t
Switch#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#
Switch(config)#h
Switch(config)#hostname sw0
sw0(config)#vlan 10
sw0(config-vlan)#vlan 20
sw0(config-vlan)#exit
sw0(config)#int
sw0(config)#interface f
sw0(config)#interface fastEthernet 0/1
sw0(config-if)#sw
sw0(config-if)#switchport m
sw0(config-if)#switchport mode t
sw0(config-if)#switchport mode trunk 
sw0(config-if)#exit
sw0(config)#int
sw0(config)#interface f
sw0(config)#interface fastEthernet 0/2
sw0(config-if)#sw
sw0(config-if)#switchport a
sw0(config-if)#switchport access v
sw0(config-if)#switchport access vlan 10
sw0(config-if)#exit
sw0(config)#int
sw0(config)#interface f
sw0(config)#interface fastEthernet 0/3
sw0(config-if)#sw
sw0(config-if)#switchport m
sw0(config-if)#switchport mode t
sw0(config-if)#switchport mode trunk 
sw0(config-if)#exit
sw0(config)#int
sw0(config)#interface f
sw0(config)#interface fastEthernet 0/4
sw0(config-if)#sw
sw0(config-if)#switchport m
sw0(config-if)#switchport mode t
sw0(config-if)#switchport mode trunk 
sw0(config-if)#exit
sw0(config)#
sw0(config)#int
sw0(config)#interface f
sw0(config)#interface fastEthernet 0/5
sw0(config-if)#sw
sw0(config-if)#switchport m
sw0(config-if)#switchport mode t
sw0(config-if)#switchport mode trunk 
sw0(config-if)#exit
sw0(config)#int
sw0(config)#interface f
sw0(config)#interface fastEthernet 0/6
sw0(config-if)#sw
sw0(config-if)#switchport a
sw0(config-if)#switchport access v
sw0(config-if)#switchport access vlan 20
sw0(config-if)#exit
sw0(config)#int
sw0(config)#interface f
sw0(config)#interface fastEthernet 0/7
sw0(config-if)#sw
sw0(config-if)#switchport m
sw0(config-if)#switchport mode t
sw0(config-if)#switchport mode trunk 

sw0(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/7, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/7, changed state to up

sw0(config-if)#exit
sw0(config)#

DHCP配置成功,终端自动获取ip信息
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-zrxAfUzT-1657337391387)(C:\Users\DHX83\AppData\Roaming\Typora\typora-user-images\image-20220709111057905.png)]

此时相同vlan的设备可ping通,不同vlan设备不可通

4.三层交换机配置

首先配置设备4三层交换机的vlan功能,实现交换机的功能

Switch>
Switch>
Switch>en
Switch#conf
Switch#configure t
Switch#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#h
Switch(config)#hostname 4
4(config)#vlan 20
4(config-vlan)#exit
4(config)#int
4(config)#interface vl
4(config)#interface vlan 20

%LINK-5-CHANGED: Interface Vlan20, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
4(config-if)#ad
4(config-if)#ip
4(config-if)#ip ad
4(config-if)#ip address 2.2.2.254 255.255.255.0
4(config-if)#no sh
4(config-if)#no shutdown 
4(config-if)#exit

ping测试:此时相同vlan内的设备可以相互ping通

扫描二维码关注公众号,回复: 15398132 查看本文章

5.宿舍vlan的路由设置(内网2设置)

Router>
Router>en
Router#conf
Router#configure t
Router#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#h
Router(config)#hostname 2
2(config)#int
2(config)#interface f
2(config)#interface fastEthernet 0/0
2(config-if)#no sh
2(config-if)#no shutdown 

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

2(config-if)#exit
2(config)#int
2(config)#interface f
2(config)#interface fastEthernet 0/0.10

%LINK-5-CHANGED: Interface FastEthernet0/0.10, changed state to up
2(config-subif)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.10, changed state to up

2(config-subif)#e
2(config-subif)#e
2(config-subif)#e
2(config-subif)#en
2(config-subif)#encapsulation 
2(config-subif)#encapsulation dot1Q 10
2(config-subif)#ip ad
2(config-subif)#ip address 1.1.1.254 255.255.255.0
2(config-subif)#exit
2(config)#ro
2(config)#router r
2(config)#router rip 
2(config-router)#ne
2(config-router)#network 1.1.1.0
2(config-router)#exit

和终端宿舍1ping测试:可以通

二、路由ospf设置

内网1路由器设置

二层—>三层

Router>en
Router#conf
Router#configure t
Router#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#h
Router(config)#hostname 1
1(config)#int
1(config)#interface fa
1(config)#interface fastEthernet 0/0
1(config-if)#ip ad
1(config-if)#ip address 12.12.12.1 255.255.255.0
1(config-if)#no s
1(config-if)#no sh
1(config-if)#no shutdown 

1(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

1(config-if)#fa
1(config-if)#int
1(config-if)#exit
1(config)#int
1(config)#interface f
1(config)#interface fastEthernet 0/1
1(config-if)#ip ad
1(config-if)#ip address 13.13.13.1 255.255.255.0
1(config-if)#no sh
1(config-if)#no shutdown 

1(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up

1(config-if)#exit
1(config)#int
1(config)#interface f
1(config)#interface e
1(config)#interface ethernet 0/1/0
1(config-if)#ip ad
1(config-if)#ip address 15.15.15.1 255.255.255.0
1(config-if)#no sh
1(config-if)#no shutdown 

1(config-if)#
%LINK-5-CHANGED: Interface Ethernet0/1/0, changed state to up
exit
1(config)#ro
1(config)#router o
1(config)#router ospf 1
1(config-router)#ro
1(config-router)#router-id 1.1.1.1
1(config-router)#network 12.12.12.0 0.0.0.255 area 1
1(config-router)#network 13.13.13.0 0.0.0.255 area 1
1(config-router)#ne
1(config-router)#network 15.15.15.0 0.0.0.255 a
1(config-router)#network 15.15.15.0 0.0.0.255 area 0
1(config-router)#exit

内网2路由设置

2>
2>en
2#conf
2#configure t
2#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
2(config)#int
2(config)#interface f
2(config)#interface fastEthernet 0/1
2(config-if)#ip ad
2(config-if)#ip address 12.12.12.2 255.255.255.0
2(config-if)#no sh
2(config-if)#no shutdown 

%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

2(config-if)#exit
2(config)#int
2(config)#interface e
2(config)#interface ethernet 0/1/0
2(config-if)#ip ad
2(config-if)#ip address 24.24.24.1 255.255.255.0
2(config-if)#no sh
2(config-if)#no shutdown 

%LINK-5-CHANGED: Interface Ethernet0/1/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1/0, changed state to up

2(config-if)#exit
2(config)#ro
2(config)#router o
2(config)#router ospf 1
2(config-router)#ro
2(config-router)#router-id 2.2.2.2
2(config-router)#do show ip osp
2(config-router)#do show ip osp
 Routing Process "ospf 1" with ID 2.2.2.2
 Supports only single TOS(TOS0) routes
 Supports opaque LSA
 SPF schedule delay 5 secs, Hold time between two SPFs 10 secs
 Minimum LSA interval 5 secs. Minimum LSA arrival 1 secs
 Number of external LSA 0. Checksum Sum 0x000000
 Number of opaque AS LSA 0. Checksum Sum 0x000000
 Number of DCbitless external and opaque AS LSA 0
 Number of DoNotAge external and opaque AS LSA 0
 Number of areas in this router is 0. 0 normal 0 stub 0 nssa
 External flood list length 0

2(config-router)#do show ip rou
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

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, FastEthernet0/0.10
     12.0.0.0/24 is subnetted, 1 subnets
C       12.12.12.0 is directly connected, FastEthernet0/1
     24.0.0.0/24 is subnetted, 1 subnets
C       24.24.24.0 is directly connected, Ethernet0/1/0
2(config-router)#ne
2(config-router)#network 1.1.1.0 0.0.0.255 a
2(config-router)#network 1.1.1.0 0.0.0.255 area 1
2(config-router)#ne
2(config-router)#network 12.12.12.0 0.0.0.255 a
2(config-router)#network 12.12.12.0 0.0.0.255 area 1
2(config-router)#ne
2(config-router)#network 24.24.24.0 00.
2(config-router)#network 24.24.24.0 0.0.0.255 a
2(config-router)#network 24.24.24.0 0.0.0.255 area 1
2(config-router)#exit
2(config)#

此时,从内网1路由器到宿舍可以ping通

内网3路由设置

Router>
Router>en
Router#conf
Router#configure t
Router#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#h
Router(config)#hostname 3
3(config)#int
3(config)#interface f
3(config)#interface fastEthernet 0/0
3(config-if)#ip a
3(config-if)#ip ad
3(config-if)#ip address 13.13.13.2 255.255.255.0
3(config-if)#no sh
3(config-if)#no shutdown 

3(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
exit
3(config)#int
3(config)#interface f
3(config)#interface fastEthernet 0/1
3(config-if)#ip ad
3(config-if)#ip address 34.34.34.0 255.255.255.0
Bad mask /24 for address 34.34.34.0
3(config-if)#ip address 34.34.34.1 255.255.255.0
3(config-if)#no sh
3(config-if)#no shutdown 

%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

3(config-if)#exit
3(config)#int
3(config)#interface e
3(config)#interface ethernet 0/1/0
3(config-if)#ip ad
3(config-if)#ip address 3.3.3.254 255.255.255.0
3(config-if)#no sh
3(config-if)#no shutdown 

%LINK-5-CHANGED: Interface Ethernet0/1/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1/0, changed state to up

3(config-if)#exit
3(config)#rou
3(config)#router o
3(config)#router ospf 1
3(config-router)#ro
3(config-router)#router-id 3.3.3.3
3(config-router)#do show ip rou
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

     3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Ethernet0/1/0
     13.0.0.0/24 is subnetted, 1 subnets
C       13.13.13.0 is directly connected, FastEthernet0/0
     34.0.0.0/24 is subnetted, 1 subnets
C       34.34.34.0 is directly connected, FastEthernet0/1
3(config-router)#ne
3(config-router)#network 3.3.3.3 0.0.0.255 a
3(config-router)#network 3.3.3.3 0.0.0.255 area 1
3(config-router)#ne
3(config-router)#network 13.13.13.0 0.0.0.255 a
3(config-router)#network 13.13.13.0 0.0.0.255 area 1
3(config-router)#n
3(config-router)#ne
3(config-router)#network 34.34.34
01:18:03: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on FastEthernet0/0 from LOADING to FULL, Loading Done
.0
3(config-router)#network 34.34.34.0 0.0.0.255 a
3(config-router)#network 34.34.34.0 0.0.0.255 area 1
3(config-router)#exit
3(config)#

三层交换机路由配置

4>en
4#conf
4#configure t
4#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
4(config)#int
4(config)#interface f
4(config)#interface fastEthernet 0/2
4(config-if)#ip ad
4(config-if)#ip ad
4(config-if)#ip ad
4(config-if)#no sw
4(config-if)#no switchport 

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
4(config-if)#ip ad
4(config-if)#ip address 24.24.24.2 255.255.255.0
4(config-if)#no sh
4(config-if)#no shutdown 
4(config-if)#exit
4(config)#int
4(config)#interface f
4(config)#interface fastEthernet 0/3
4(config-if)#no s
4(config-if)#no sw
4(config-if)#no switchport 
4(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up

4(config-if)#ip ad
4(config-if)#ip address 34.34.34.2 255.255.255.0
4(config-if)#no sh
4(config-if)#no shutdown 
4(config-if)#exit
4(config)#rou
4(config)#router o
4(config)#router ospf 1
4(config-router)#rou
4(config-router)#router-id 4.4.4.4
4(config-router)#net
4(config-router)#do show ip rou
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

     2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Vlan20
     24.0.0.0/24 is subnetted, 1 subnets
C       24.24.24.0 is directly connected, FastEthernet0/2
     34.0.0.0/24 is subnetted, 1 subnets
C       34.34.34.0 is directly connected, FastEthernet0/3
4(config-router)#net
4(config-router)#network 2.2.2.0 0.0.0.255 a
4(config-router)#network 2.2.2.0 0.0.0.255 area 1
4(config-router)#ne
4(config-router)#network 24.24.24.0 0.0.0.255 a
4(config-router)#network 24.24.24.0 0.0.0.255 area 1
4(config-router)#ne
4(config-router)#network 34.34.34.0
00:46:31: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on FastEthernet0/2 from LOADING to FULL, Loading Done
4(config-router)#network 34.34.34.0 0.0.0.255 a
4(config-router)#network 34.34.34.0 0.0.0.255 area 1
4(config-router)#exit
4(config)#
00:46:53: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on FastEthernet0/3 from EXCHANGE to FULL, Exchange Done
^Z
4#
%SYS-5-CONFIG_I: Configured from console by console

4#w
4#write 
Building configuration...
[OK]

此时左边都能ping通

校区2路由设置


Router>
Router>en
Router#conf
Router#configure t
Router#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#h
Router(config)#hostname 5
5(config)#int
5(config)#interface f
5(config)#interface fastEthernet 0/0
5(config-if)#ip ad
5(config-if)#ip address 15.15.15.2 255.255.255.0
5(config-if)#no sh
5(config-if)#no shutdown 

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

5(config-if)#exit
5(config)#rou
5(config)#router o
5(config)#router ospf 1
5(config-router)#rou
5(config-router)#router-id 5.5.5.5
5(config-router)#ne
5(config-router)#network 15.15.15.0 0.0.0.255 a
5(config-router)#network 15.15.15.0 0.0.0.255 area 0
5(config-router)#^Z
5#
%SYS-5-CONFIG_I: Configured from console by console
w
5#write 
Building configuration...
[OK]

此时所有终端都能通

三、DNS、HTTP设置

DNS服务器设置

设置静态IP

在配置界面添加HTTP服务器的域名和地址

路由器设置

2>en
2#conf
2#configure t
2#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
2(config)#int
2(config)#interface e
2(config)#interface ethernet 0/0/0
2(config-if)#ip ad
2(config-if)#ip address 100.100.100.254 255.255.255.0
2(config-if)#no sh
2(config-if)#no shutdown 

%LINK-5-CHANGED: Interface Ethernet0/0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0/0, changed state to up

2(config-if)#^Z
2#
%SYS-5-CONFIG_I: Configured from console by console


2#w
2#write 
Building configuration...
[OK]

HTTP设置

设置静态路由3.3.3.254

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-gRFiZ5ec-1657337391387)(C:\Users\DHX83\AppData\Roaming\Typora\typora-user-images\image-20220709110613238.png)]

四、测试

1.ping测试

宿舍–教室

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ykL94cni-1657337391388)(C:\Users\DHX83\AppData\Roaming\Typora\typora-user-images\image-20220709111321977.png)]

宿舍----图书馆

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-fKvWXqHa-1657337391388)(C:\Users\DHX83\AppData\Roaming\Typora\typora-user-images\image-20220709111408224.png)]

内网5–宿舍

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-fa7wVms7-1657337391389)(C:\Users\DHX83\AppData\Roaming\Typora\typora-user-images\image-20220709111557879.png)]

内网5–教室1

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-fra3mNWk-1657337391389)(C:\Users\DHX83\AppData\Roaming\Typora\typora-user-images\image-20220709111624755.png)]

内网5–图书馆

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-KpzCHiMT-1657337391389)(C:\Users\DHX83\AppData\Roaming\Typora\typora-user-images\image-20220709111646648.png)]

2.DNS测试

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-JlqezOxK-1657337391390)(C:\Users\DHX83\AppData\Roaming\Typora\typora-user-images\image-20220709110732043.png)]

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/m0_52064995/article/details/125691393