实验拓扑图
实验要求:
利用OSPF协议实现全网互通。
实验步骤:
1、用Visio画出拓扑图
2、规划IP地址
3、用Packet Tracer5.0进行模拟实验
具体配置如下:
SW1
Switch>en
Switch#conf t
//进行基础的安全配置
Switch(config)#enable secret xiaowu
Switch(config)#line vty 0 15
Switch(config-line)#password xiaowu
Switch(config-line)#exit
Switch(config)#line console 0
Switch(config-line)#password xiaowu
Switch(config-line)#exit
Switch(config)#hostname SW1
SW1(config)#no ip domain-lookup
//设置VTP客户端
SW1(config)#vtp domain xiaowu
Domain name already set to xiaowu.
SW1(config)#vtp mode client
Setting device to VTP CLIENT mode.
SW1(config)#vtp password xiaowu
Setting device VLAN database password to xiaowu
//设置Trnk链路
SW1(config)#int f0/24
SW1(config-if)#switchport mode trunk
SW1(config-if)#exit
SW1(config)#end
%SYS-5-CONFIG_I: Configured from console by console
SW1#show vlan
SW1#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/3, Fa0/4, Fa0/5
Fa0/6, Fa0/7, Fa0/8, Fa0/9
Fa0/10, Fa0/11, Fa0/12, Fa0/13
Fa0/14, Fa0/15, Fa0/16, Fa0/17
Fa0/18, Fa0/19, Fa0/20, Fa0/21
Fa0/22, Fa0/23
2 vlan2 active Fa0/2
3 vlan3 active
4 vlan4 active
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
2 enet 100002 1500 - - - - - 0 0
3 enet 100003 1500 - - - - - 0 0
4 enet 100004 1500 - - - - - 0 0
1002 enet 101002 1500 - - - - - 0 0
1003 enet 101003 1500 - - - - - 0 0
1004 enet 101004 1500 - - - - - 0 0
1005 enet 101005 1500 - - - - - 0 0
SW1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
//划分指定端口到指定Vlan
SW1(config)#int f0/2
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 2
SW1(config-if)#exit
SW1(config)#int f0/3
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 3
SW1(config-if)#exit
SW1(config)#swi
SW1(config)#int f0/4
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 4
SW1(config-if)#exit
SW1(config)#exit
%SYS-5-CONFIG_I: Configured from console by console
SW1#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/5, Fa0/6, Fa0/7
Fa0/8, Fa0/9, Fa0/10, Fa0/11
Fa0/12, Fa0/13, Fa0/14, Fa0/15
Fa0/16, Fa0/17, Fa0/18, Fa0/19
Fa0/20, Fa0/21, Fa0/22, Fa0/23
2 vlan2 active Fa0/2
3 vlan3 active Fa0/3
4 vlan4 active Fa0/4
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
2 enet 100002 1500 - - - - - 0 0
3 enet 100003 1500 - - - - - 0 0
4 enet 100004 1500 - - - - - 0 0
SW1#write
Building configuration...
[OK]
SW2
Switch>en
Switch#conf t
//交换机基本配置
Switch(config)#hostname SW2
SW2(config)#enable password xiaowu
SW2(config)#line vty 0 15
SW2(config-line)#password xiaowu
SW2(config-line)#exit
SW2(config)#line console 0
SW2(config-line)#password xiaowu
SW2(config-line)#exit
SW2(config)#no ip domain-lookup
//设置VTP客户端
SW2(config)#vtp domain xiaowu
Domain name already set to xiaowu.
SW2(config)#vtp mode client
Setting device to VTP CLIENT mode.
SW2(config)#vtp password xiaowu
Setting device VLAN database password to xiaowu
/设置Trunk链路
SW2(config)#int f0/24
SW2(config-if)#switchport mode trunk
SW2(config-if)#exit
SW2(config)#exit
%SYS-5-CONFIG_I: Configured from console by console
SW2#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/13, Fa0/14, Fa0/15, Fa0/16
Fa0/17, Fa0/18, Fa0/19, Fa0/20
Fa0/21, Fa0/22, Fa0/23
5 vlan5 active
6 vlan6 active
7 vlan7 active
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
5 enet 100005 1500 - - - - - 0 0
6 enet 100006 1500 - - - - - 0 0
//划分指定端口到指定Vlan
SW2(config)#int f0/5
SW2(config-if)#switchport mode access
SW2(config-if)#switchport access vlan 5
SW2(config-if)#exit
SW2(config)#int f0/6
SW2(config-if)#switchport mode access
SW2(config-if)#switchport access vlan 6
SW2(config-if)#exit
SW2(config)#int f0/7
SW2(config-if)#switchport mode access
SW2(config-if)#switchport access vlan 7
SW2(config-if)#exit
SW2(config)#exit
%SYS-5-CONFIG_I: Configured from console by console
SW2#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/8, Fa0/9, Fa0/10, Fa0/11
Fa0/12, Fa0/13, Fa0/14, Fa0/15
Fa0/16, Fa0/17, Fa0/18, Fa0/19
Fa0/20, Fa0/21, Fa0/22, Fa0/23
5 vlan5 active Fa0/5
6 vlan6 active Fa0/6
7 vlan7 active Fa0/7
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
5 enet 100005 1500 - - - - - 0 0
6 enet 100006 1500 - - - - - 0 0
7 enet 100007 1500 - - - - - 0 0
1002 enet 101002 1500 - - - - - 0 0
1003 enet 101003 1500 - - - - - 0 0
1004 enet 101004 1500 - - - - - 0 0
1005 enet 101005 1500 - - - - - 0 0
SW2#write
Building configuration...
[OK]
SW2#
3SW1
Switch>en
Switch#conf t
//交换机基本配置
Switch(config)#enable secret xiaowu
Switch(config)#line vty 0 15
Switch(config-line)#password xiaowu
Switch(config)#line console 0
Switch(config-line)#password xiaowu
Switch(config-line)#exit
Switch(config)#hostname 3SW1
//设置VTP服务器端
3SW1(config)#vtp domain xiaowu
Changing VTP domain name from NULL to xiaowu
3SW1(config)#vtp mode server
Device mode already VTP SERVER.
3SW1(config)#vtp password xiaowu
Setting device VLAN database password to xiaowu
3SW1(config)#exit
//创建Vlan
3SW1#vlan database
3SW1(vlan)#vlan 2 name vlan2
VLAN 2 added:
Name: vlan2
3SW1(vlan)#vlan 3 name vlan3
VLAN 3 added:
Name: vlan3
3SW1(vlan)#vlan 4 name vlan4
VLAN 4 added:
Name: vlan4
3SW1(vlan)#exit
APPLY completed.
Exiting....
3SW1#conf t
//设置Trunk链路
3SW1(config)#int f0/24
3SW1(config-if)#switchport mode trunk
//启用路由功能
3SW1(config)#ip routing
//为每个Vlan配置IP地址
3SW1(config)#int vlan 2
3SW1(config-if)#ip address 192.168.20.254 255.255.255.0
3SW1(config-if)#no shut
3SW1(config-if)#exit
3SW1(config)#int vlan 3
3SW1(config-if)#ip address 192.168.30.254 255.255.255.0
3SW1(config-if)#no shut
3SW1(config-if)#exit
3SW1(config)#int vlan 4
3SW1(config-if)#ip address 192.168.40.254 255.255.255.0
3SW1(config-if)#no shut
3SW1(config-if)#exit
3SW1(config)#exit
3SW1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
3SW1(config)#vt
3SW1(config)#vtp p
3SW1(config)#vtp pu
3SW1(config)#vtp ?
domain Set the name of the VTP administrative domain.
mode Configure VTP device mode
password Set the password for the VTP administrative domain
version Set the adminstrative domain to VTP version
3SW1(config)#vtp mo
3SW1(config)#vtp mode ?
client Set the device to client mode.
server Set the device to server mode.
transparent Set the device to transparent mode.
//启用一个三层接口与路由器相连的
3SW1(config)#int f0/1
3SW1(config-if)#no switchport
3SW1(config-if)#ip address 172.16.100.20 255.255.255.0
3SW1(config-if)#no shut
//启用OSPF协议
3SW1(config)#router ospf 100
3SW1(config-router)#network 172.16.100.0 0.0.0.255 area 10
3SW1(config-router)#network 192.168.20.0 0.0.0.255 area 10
3SW1(config-router)#network 192.168.30.0 0.0.0.255 area 10
3SW1(config-router)#network 192.168.40.0 0.0.0.255 area 10
3SW1(config-router)#end
3SW1#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
172.16.0.0/24 is subnetted, 7 subnets
O 172.16.10.0 [110/129] via 172.16.100.10, 00:02:18, FastEthernet0/1
O 172.16.20.0 [110/129] via 172.16.100.10, 00:02:18, FastEthernet0/1
O 172.16.30.0 [110/65] via 172.16.100.10, 00:02:18, FastEthernet0/1
O 172.16.40.0 [110/65] via 172.16.100.10, 00:02:18, FastEthernet0/1
O 172.16.50.0 [110/193] via 172.16.100.10, 00:02:18, FastEthernet0/1
C 172.16.100.0 is directly connected, FastEthernet0/1
O 172.16.200.0 [110/130] via 172.16.100.10, 00:02:18, FastEthernet0/1
C 192.168.20.0/24 is directly connected, Vlan2
C 192.168.30.0/24 is directly connected, Vlan3
C 192.168.40.0/24 is directly connected, Vlan4
3SW1#
3SW2
Switch>en
Switch#conf t
//交换机基本配置
Switch(config)#hostname 3SW2
3SW2(config)#enable secret xiaowu
3SW2(config)#line vty 0 15
3SW2(config-line)#password xiaowu
3SW2(config)#line console 0
3SW2(config-line)#password xiaowu
3SW2(config-line)#exit
//设置VTP服务端
3SW2(config)#vtp domain xiaowu
Changing VTP domain name from NULL to xiaowu
3SW2(config)#vtp password xiaowu
Setting device VLAN database password to xiaowu
3SW2(config)#vtp mode server
Device mode already VTP SERVER.
//设置Trunk链路
3SW2(config)#int f0/24
3SW2(config-if)#switchport mode trunk
//创建Vlan
3SW2#vlan database
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
3SW2(vlan)#vlan 5 name vlan5
VLAN 5 added:
Name: vlan5
3SW2(vlan)#vlan 6 name vlan6
VLAN 6 added:
Name: vlan6
3SW2(vlan)#vlan 7 name vlan7
VLAN 7 added:
Name: vlan7
3SW2(vlan)#exit
APPLY completed.
Exiting....
3SW2#conf t
//启用路由功能
3SW2(config)#ip routing
//为每个Vlan配置IP地址
3SW2(config)#int vlan 5
3SW2(config-if)#ip address 192.168.50.254 255.255.255.0
3SW2(config-if)#no shut
3SW2(config-if)#exit
3SW2(config)#int vlan 6
3SW2(config-if)#ip address 192.168.60.254 255.255.255.0
3SW2(config-if)#no shut
3SW2(config-if)#exit
3SW2(config)#int vlan 7
3SW2(config-if)#ip address 192.168.70.254 255.255.255.0
3SW2(config-if)#no shut
3SW2(config-if)#exit
3SW2(config)#end
%SYS-5-CONFIG_I: Configured from console by console
//启用三层接口
3SW2(config)#int f0/1
3SW2(config-if)#no switchport
3SW2(config-if)#ip address 172.16.200.20 255.255.255.0
//启用OSPF协议
3SW2(config)#router ospf 100
3SW2(config-router)#network 172.16.200.0 0.0.0.255 area 10
3SW2(config-router)#network 192.168.50.0 0.0.0.255 area 10
3SW2(config-router)#network 192.168.60.0 0.0.0.255 area 10
3SW2(config-router)#network 192.168.70.0 0.0.0.255 area 10
3SW2(config-router)#end
3SW2#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
172.16.0.0/24 is subnetted, 7 subnets
O 172.16.10.0 [110/129] via 172.16.200.10, 00:00:04, FastEthernet0/1
O 172.16.20.0 [110/65] via 172.16.200.10, 00:00:04, FastEthernet0/1
O 172.16.30.0 [110/129] via 172.16.200.10, 00:00:04, FastEthernet0/1
O 172.16.40.0 [110/193] via 172.16.200.10, 00:00:04, FastEthernet0/1
O 172.16.50.0 [110/65] via 172.16.200.10, 00:00:04, FastEthernet0/1
O 172.16.100.0 [110/130] via 172.16.200.10, 00:00:04, FastEthernet0/1
C 172.16.200.0 is directly connected, FastEthernet0/1
O 192.168.20.0/24 [110/131] via 172.16.200.10, 00:00:04, FastEthernet0/1
O 192.168.30.0/24 [110/131] via 172.16.200.10, 00:00:04, FastEthernet0/1
O 192.168.40.0/24 [110/131] via 172.16.200.10, 00:00:04, FastEthernet0/1
C 192.168.50.0/24 is directly connected, Vlan5
C 192.168.60.0/24 is directly connected, Vlan6
C 192.168.70.0/24 is directly connected, Vlan7
3SW2#
R1
Router>en
Router#conf t
//路由器基本配置
Router(config)#hostname R1
R1(config)#line vty 0 15
R1(config-line)#password xiaowu
R1(config-line)#exit
R1(config)#line console 0
R1(config-line)#password xiaowu
R1(config-line)#exit
R1(config)#no ip domain-lookup
//配置各个端口IP地址
R1(config)#int s0/0/0
R1(config-if)#ip address 172.16.10.10 255.255.255.0
R1(config-if)#no shut
R1(config-if)#clock rate 64000
R1(config-if)#exit
R1(config)#int s0/1/0
R1(config-if)#ip address 172.16.20.10 255.255.255.0
R1(config-if)#no shut
R1(config-if)#clock rate 64000
R1(config-if)#exit
R1(config)#int s0/0/1
R1(config-if)#ip address 172.16.30.10 255.255.255.0
R1(config-if)#clock rate 64000
R1(config-if)#no shut
//启用OSPF协议
R1(config)#router ospf 100
R1(config-router)#network 172.16.10.0 0.0.0.255 area 10
R1(config-router)#network 172.16.20.0 0.0.0.255 area 10
R1(config-router)#network 172.16.30.0 0.0.0.255 area 10
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
172.16.0.0/24 is subnetted, 7 subnets
C 172.16.10.0 is directly connected, Serial0/0/0
C 172.16.20.0 is directly connected, Serial0/1/0
C 172.16.30.0 is directly connected, Serial0/0/1
O 172.16.40.0 [110/128] via 172.16.30.20, 00:06:37, Serial0/0/1
O 172.16.50.0 [110/128] via 172.16.20.20, 00:08:06, Serial0/1/0
[110/128] via 172.16.10.20, 00:07:31, Serial0/0/0
O 172.16.100.0 [110/65] via 172.16.30.20, 00:00:32, Serial0/0/1
O 172.16.200.0 [110/65] via 172.16.20.20, 00:00:07, Serial0/1/0
R1#
R2
Router>en
Router#conf t
//路由基本配置
Router(config)#hostname R2
R2(config)#enable secret xiaowu
R2(config)#line vty 0 15
R2(config-line)#password xiaowu
R2(config-line)#exit
R2(config)#line console 0
R2(config-line)#password xiaowu
R2(config-line)#exit
R2(config)#no ip domain-lookup
//配置各个端口IP地址
R2(config)#int s0/0/0
R2(config-if)#ip address 172.16.10.20 255.255.255.0
R2(config-if)#no sh
R2(config-if)#exit
R2(config)#int s0/1/0
R2(config-if)#ip address 192.168.40.10 255.255.255.0
R2(config-if)#clock rate 64000
R2(config-if)#no sh
R2(config-if)#exit
R2(config)#int s0/0/1
R2(config-if)#ip address 172.16.50.10 255.255.255.0
R2(config-if)#clock rate 64000
R2(config-if)#no shut
//启用OSPF协议
R2(config)#router ospf 100
R2(config-router)#network 172.16.10.0 0.0.0.255 area 10
R2(config-router)#network 172.16.40.0 0.0.0.255 area 10
R2(config-router)#network 172.16.50.0 0.0.0.255 area 10
R2#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
172.16.0.0/24 is subnetted, 7 subnets
C 172.16.10.0 is directly connected, Serial0/0/0
O 172.16.20.0 [110/128] via 172.16.10.10, 00:52:31, Serial0/0/0
[110/128] via 172.16.50.20, 00:52:21, Serial0/0/1
O 172.16.30.0 [110/128] via 172.16.10.10, 00:52:31, Serial0/0/0
O 172.16.40.0 [110/192] via 172.16.10.10, 00:51:42, Serial0/0/0
C 172.16.50.0 is directly connected, Serial0/0/1
O 172.16.100.0 [110/129] via 172.16.10.10, 00:45:31, Serial0/0/0
O 172.16.200.0 [110/65] via 172.16.50.20, 00:45:07, Serial0/0/1
O 192.168.20.0/24 [110/130] via 172.16.10.10, 00:43:21, Serial0/0/0
O 192.168.30.0/24 [110/130] via 172.16.10.10, 00:43:21, Serial0/0/0
C 192.168.40.0/24 is directly connected, Serial0/1/0
O 192.168.50.0/24 [110/66] via 172.16.50.20, 00:38:37, Serial0/0/1
O 192.168.60.0/24 [110/66] via 172.16.50.20, 00:38:37, Serial0/0/1
O 192.168.70.0/24 [110/66] via 172.16.50.20, 00:38:37, Serial0/0/1
R2#
R3与R4的配置与R1和R2相似,这里就不在写出。
具体可以参考附件中的文档。