
http://www.pinvei.com/gs_detail.asp?id=500216&nowmenuid=500190&previd=0 (转自队友陈龙)

对 SW 2-1 的配置:对 SW 2-1 的配置:对 SW 2-1 的配置:对 SW 2-1 的配置:
sw2-1#
sw2-1#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw2-1(config)#no ip domain lookup
sw2-1(config)#
sw2-1(config)#end
sw2-1#
sw2-1#
sw2-1#vlan data
sw2-1(vlan)#vlan 10
VLAN 10 modified:
sw2-1(vlan)#vlan 20
VLAN 20 modified:
sw2-1(vlan)#vlan 30
VLAN 30 modified:
sw2-1(vlan)#vlan 40
VLAN 40 modified:
sw2-1(vlan)#exit
APPLY completed.
Exiting....
sw2-1#
sw2-1#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw2-1(config)#int f0/1
sw2-1(config-if)#switch mode trunk
sw2-1(config-if)#switch trunk en dot1q
sw2-1(config-if)#
sw2-1(config-if)#end
sw2-1#
对 SW 2-2 的配置:对 SW 2-2 的配置:对 SW 2-2 的配置:对 SW 2-2 的配置:对 SW 2-2 的配置:
sw2-2>
sw2-2>en
sw2-2#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw2-2(config)#no ip domain lookup
sw2-2(config)#end
sw2-2#
sw2-2#vlan data
sw2-2(vlan)#vlan 10
VLAN 10 modified:
sw2-2(vlan)#vlan 20
VLAN 20 modified:
sw2-2(vlan)#vlan 30
VLAN 30 modified:
sw2-2(vlan)#vlan 40
VLAN 40 modified:
sw2-2(vlan)#exit
APPLY completed.
Exiting....
sw2-2#
sw2-2#
sw2-2#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw2-2(config)#int f0/2
sw2-2(config-if)#switchport mode trunk
sw2-2(config-if)#switchport trunk en dot1q
sw2-2(config-if)#end
sw2-2#
对SW 3—1 的配置:对SW 3—1 的配置:对SW 3—1 的配置:对SW 3—1 的配置:对SW 3—1 的配置:
(关于VRRP的配置)
sw3-1#
sw3-1#vlan data
sw3-1(vlan)#vlan 10
VLAN 10 modified:
sw3-1(vlan)#vlan 20
VLAN 20 modified:
sw3-1(vlan)#vlan 30
VLAN 30 modified:
sw3-1(vlan)#vlan 40
VLAN 40 modified:
sw3-1(vlan)#exit
APPLY completed.
Exiting....
sw3-1#
sw3-1#
sw3-1#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw3-1(config)#
sw3-1(config)#
sw3-1(config)#
sw3-1(config)#int vlan 10
sw3-1(config-if)#ip add 192.168.10.254 255.255.255.0
sw3-1(config-if)#vrrp 1 ip 192.168.10.252
sw3-1(config-if)#vrrp 1 priority 105
sw3-1(config-if)#vrrp 1 preempt
sw3-1(config-if)#exit
sw3-1(config)#
sw3-1(config)#int vlan 20
sw3-1(config-if)#ip add 192.168.20.253 255.255.255.0
sw3-1(config-if)#vrrp 2 ip 192.168.20.252
sw3-1(config-if)#vrrp 2 preempt
sw3-1(config-if)#exit
sw3-1(config)#
sw3-1(config)#int vlan 30
sw3-1(config-if)#ip add 192.168.30.254 255.255.255.0
sw3-1(config-if)#vrrp 3 ip 192.168.30.252
sw3-1(config-if)#vrrp 3 priority 105
sw3-1(config-if)#vrrp 3 preempt
sw3-1(config-if)#end
sw3-1#
sw3-1(config)#int vlan 40
sw3-1(config-if)#ip add 192.168.40.253 255.255.255.0
sw3-1(config-if)#vrrp 4 ip 192.168.40.252
sw3-1(config-if)#vrrp 4 preempt
sw3-1(config-if)#exit
sw3-1(config)#
sw3-1#
sw3-1#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw3-1(config)#int f0/5
sw3-1(config-if)#switchport mode trunk
sw3-1(config-if)#switchport trunk en dot1q
sw3-1(config-if)#end
sw3-1#
(关于MSTP的配置)
!
!
spanning-tree mode mst
spanning-tree mst configuration
!
instance 1 vlan 10, 30
instance 2 vlan 20, 40
!
spanning-tree mst 1 root primary
spanning-tree mst 2 root secondary
!
!
(关于OSPF的配置)
sw3-1#
sw3-1#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw3-1(config)#ip routing
sw3-1(config)#int f0/7
sw3-1(config-if)#no switchport
sw3-1(config-if)#ip add 192.168.1.2 255.255.255.0
sw3-1(config-if)#no shutdown
sw3-1(config-if)#
sw3-1#
sw3-1#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw3-1(config)#router ospf 1
sw3-1(config-router)#network 192.168.1.2 0.0.0.0 area 0
sw3-1(config-router)#network 192.168.0.0 0.0.255.255 area 0
sw3-1(config-router)#end
sw3-1#
(关于DHCP的配置)
sw3-1#
sw3-1#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw3-1(config)#ip dhcp pool vlan10
sw3-1(dhcp-config)#network 192.168.10.0 255.255.255.0
sw3-1(dhcp-config)#default-router 192.168.20.254
sw3-1(dhcp-config)#end
sw3-1#
sw3-1#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw3-1(config)#ip dhcp pool vlan20
sw3-1(dhcp-config)#network 192.168.20.0 255.255.255.0
sw3-1(dhcp-config)#default-router 192.168.20.253
sw3-1(dhcp-config)#end
sw3-1#
sw3-1#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw3-1(config)#ip dhcp pool vlan30
sw3-1(dhcp-config)#network 192.168.30.0 255.255.255.0
sw3-1(dhcp-config)#default-router 192.168.30.254
sw3-1(config)#end
sw3-1#
sw3-1#
sw3-1#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw3-1(config)#ip dhcp pool vlan40
sw3-1(dhcp-config)#network 192.168.40.253 255.255.255.0
sw3-1(dhcp-config)#default-router 192.168.40.253
sw3-1(dhcp-config)#end
sw3-1#
对 SW3--2的配置:对 SW3--2的配置:对 SW3--2的配置:对 SW3--2的配置:对 SW3--2的配置:
(关于VRRP的配置)
sw3-2#
sw3-2#
sw3-2#vlan data
sw3-2(vlan)#vlan 10
VLAN 10 modified:
sw3-2(vlan)#vlan 20
VLAN 20 modified:
sw3-2(vlan)#vlan 30
VLAN 30 modified:
sw3-2(vlan)#vlan 40
VLAN 40 modified:
sw3-2(vlan)#exit
APPLY completed.
Exiting....
sw3-2#
sw3-2#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw3-2(config)#int vlan 10
sw3-2(config-if)#ip add 192.168.10.253 255.255.255.0
sw3-2(config-if)#vrrp 1 ip 192.168.10.252
sw3-2(config-if)#vrrp 1 pree
sw3-2(config-if)#vrrp 1 preempt
sw3-2(config-if)#exit
sw3-2(config)#int vlan 20
sw3-2(config-if)#ip add 192.168.20.254 255.255.255.0
sw3-2(config-if)#vrrp 2 ip 192.168.20.252
sw3-2(config-if)#vrrp 2 priority 105
sw3-2(config-if)#vrrp 2 preempt
sw3-2(config-if)#
sw3-2(config-if)#exit
sw3-2(config)#
sw3-2(config)#int vlan 30
sw3-2(config-if)#ip add 192.168.30.253 255.255.255.0
sw3-2(config-if)#vrrp 3 ip 192.168.30.252
sw3-2(config-if)#vrrp 3 preempt
sw3-2(config-if)#exit
sw3-2(config)#
sw3-2(config)#int vlan 40
sw3-2(config-if)#ip add 192.168.40.254 255.255.255.0
sw3-2(config-if)#vrrp 4 ip 192.168.40.252
sw3-2(config-if)#vrrp 4 priority 105
sw3-2(config-if)#vrrp 4 preempt
sw3-2(config-if)#exit
sw3-2(config)#
(关于MSTP的配置)
!
!
spanning-tree mode mst
spanning-tree mst configuration
!
instance 1 vlan 10, 30
instance 2 vlan 20, 40
!
spanning-tree mst 2 root primary
spanning-tree mst 1 root secondary
!
!
(关于OSPF的配置)
sw3-2#
sw3-2#
sw3-2#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw3-2(config)#ip routing
sw3-2(config)#int f0/7
sw3-2(config-if)#no switchport
sw3-2(config-if)#ip add 192.168.2.2 255.255.255.0
sw3-2(config-if)#end
sw3-2#
sw3-2#
sw3-2#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw3-2(config)#router ospf 1
sw3-2(config-router)#network 192.168.2.2 0.0.0.0 area 0
sw3-2(config-router)#network 192.168.0.0 0.0.255.255 area 0
sw3-2(config-router)#end
sw3-2#
(关于DHCP的配置)
sw3-2#
sw3-2#config t
Enter configuration commands, one per line. End with CNTL/Z.
sw3-2(config)#ip dhcp pool vlan1o
sw3-2(dhcp-config)#ip dhcp pool vlan10
sw3-2(dhcp-config)#network 192.168.10.0 255.255.255.0
sw3-2(dhcp-config)#default-router 192.168.10.253
sw3-2(dhcp-config)#exit
sw3-2(config)#
sw3-2(config)#ip dhcp pool vlan20
sw3-2(dhcp-config)#network 192.168.20.0 255.255.255.0
sw3-2(dhcp-config)#default-router 192.168.20.254
sw3-2(dhcp-config)#exit
sw3-2(config)#
sw3-2(config)#
sw3-2(config)#ip dhcp pool vlan30
sw3-2(dhcp-config)#network 192.168.30.0 255.255.255.0
sw3-2(dhcp-config)#default-router 192.168.30.253
sw3-2(dhcp-config)#exit
sw3-2(config)#
sw3-2(config)#ip dhcp pool vlan40
sw3-2(dhcp-config)#network 192.168.40.0 255.255.255.0
sw3-2(dhcp-config)#default-router 192.168.40.254
sw3-2(dhcp-config)#end
sw3-2#
对Router 1 的配置:对Router 1 的配置:对Router 1 的配置:对Router 1 的配置:
Router-1#
Router-1#
Router-1#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router-1(config)#no ip domain-lookup
Router-1(config)#
Router-1(config)#int f0/0
Router-1(config-if)#ip add 192.168.1.1 255.255.255.0
Router-1(config-if)#no sh
Router-1(config-if)#no shutdown
Router-1(config-if)#end
Router-1#
Router-1#
Router-1#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router-1(config)#int f0/1
Router-1(config-if)#ip add 192.168.2.1 255.255.255.0
Router-1(config-if)#no sh
Router-1(config-if)#no shutdown
Router-1(config-if)#end
Router-1(config)#
Router-1(config)#
Router-1(config)#int s1/1
Router-1(config-if)#ip add 192.168.3.2 255.255.255.0
Router-1(config-if)#no shutdown
Router-1(config-if)#
Router-1(config)#
Router-1(config)#router ospf 1
Router-1(config-router)#network 192.168.1.1 0.0.0.0 area 0
Router-1(config-router)#network 192.168.2.1 0.0.0.0 area 0
Router-1(config-router)#end
Router-1#
对Router-2的配置:
(对OSPF的配置)
Router-2#
Router-2#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router-2(config)#int s1/1
Router-2(config-if)#ip add 192.168.3.1 255.255.255.0
Router-2(config-if)#no shutdown
Router-2(config-if)#exit
Router-2(config)#
Router-2(config)#int s1/0
Router-2(config-if)#ip add 211.81.157.83 255.255.255.0
Router-2(config-if)#no shutdown
Router-2(config-if)#end
Router-2#Router-2#
Router-2#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router-2(config)#router ospf 1
Router-2(config-router)#network 192.168.3.1 0.0.0.0 area 0
Router-2(config-router)#network 211.81.157.83 0.0.0.0 area 0
Router-2(config-router)#end
Router-2#
(NAT的转换)
Router-2#
Router-2#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router-2(config)#int s1/1
Router-2(config-if)#ip nat inside
Router-2(config-if)#exit
Router-2(config)#int s1/0
Router-2(config-if)#ip nat outside
Router-2(config-if)#exit
Router-2(config)ip nat inside source list 1 interface Serial1/0 overload
Router-2(config)access-list 1 permit any
Router-2(config)#exit
Router-2#
(默认路由 重分发)
Router-2#
Router-2#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router-2(config)#ip route 0.0.0.0 0.0.0.0 211.81.157.1
Router-2(config)#end
Router-2#
Router-2#
Router-2#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router-2(config)#router ospf 1
Router-2(config-router)#default-information originate metric 5
Router-2(config-router)#end
Router-2#
验证部分:::
在 SW3--1 验证 VRRP:
sw3-1#
sw3-1#show vrrp br
Interface Grp Pri Time Own Pre State Master addr Group addr
Vl10 1 105 3589 Y Master 192.168.10.254 192.168.10.252
Vl20 2 100 3609 Y Backup 192.168.20.254 192.168.20.252
Vl30 3 105 3589 Y Master 192.168.30.254 192.168.30.252
Vl40 4 100 3609 Y Backup 192.168.40.254 192.168.40.252
sw3-1#
在SW3--2 验证 VRRP:
sw3-2#
sw3-2#show vrrp brief
Interface Grp Pri Time Own Pre State Master addr Group addr
Vl10 1 100 3609 Y Backup 192.168.10.254 192.168.10.252
Vl20 2 105 3589 Y Master 192.168.20.254 192.168.20.252
Vl30 3 100 3609 Y Backup 192.168.30.254 192.168.30.252
Vl40 4 105 3589 Y Master 192.168.40.254 192.168.40.252
sw3-2#
验证 MSTP:
sw3-2# show spanning-tree mst
###### MST00 vlans mapped: 1-9,11-19,21-29,31-39,41-4094
Bridge address 000b.46ca.4880 priority 32768 (32768 sysid 0)
Root address 0006.5361.c700 priority 32768 (32768 sysid 0)
port Fa0/3 path cost 200000
IST master this switch
Operational hello time 2, forward delay 15, max age 20
Configured hello time 2, forward delay 15, max age 20, max hops 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/3 Root FWD 200000 128.3 P2p Bound(PVST)
Fa0/5 Desg FWD 200000 128.5 P2p Bound(STP)
Fa0/11 Desg FWD 200000 128.11 P2p Bound(RSTP)
###### MST01 vlans mapped: 10,30
Bridge address 000b.46ca.4880 priority 28673 (28672 sysid 1)
Root this switch for MST01
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/3 Boun FWD 200000 128.3 P2p Bound(PVST)
Fa0/5 Boun FWD 200000 128.5 P2p Bound(STP)
Fa0/11 Boun FWD 200000 128.11 P2p Bound(RSTP)
###### MST02 vlans mapped: 20,40
Bridge address 000b.46ca.4880 priority 24578 (24576 sysid 2)
Root this switch for MST02
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/3 Boun FWD 200000 128.3 P2p Bound(PVST)
Fa0/5 Boun FWD 200000 128.5 P2p Bound(STP)
Fa0/11 Boun FWD 200000 128.11 P2p Bound(RSTP)
sw3-2#
在Router 2 上查看OSPF:
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, su - IS-IS summary, 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 211.81.157.1 to network 0.0.0.0
O 192.168.30.0/24 [110/66] via 192.168.3.2, 00:18:54, Serial3/0
O 192.168.10.0/24 [110/66] via 192.168.3.2, 00:18:54, Serial3/0
O 192.168.40.0/24 [110/66] via 192.168.3.2, 00:18:54, Serial3/0
O 192.168.20.0/24 [110/66] via 192.168.3.2, 00:18:54, Serial3/0
C 211.81.157.0/24 is directly connected, FastEthernet0/0
O 192.168.1.0/24 [110/65] via 192.168.3.2, 00:18:54, Serial3/0
O 192.168.2.0/24 [110/65] via 192.168.3.2, 00:18:54, Serial3/0
C 192.168.3.0/24 is directly connected, Serial3/0
S* 0.0.0.0/0 [1/0] via 211.81.157.1
验证链路的通情况: 用主机ping 211.81.157.1
C:\Documents and Settings\Administrator>ping 211.81.157.83
Pinging 211.81.157.83 with 32 bytes of data:
Reply from 211.81.157.83: bytes=32 time=2ms TTL=253
Reply from 211.81.157.83: bytes=32 time=2ms TTL=253
Reply from 211.81.157.83: bytes=32 time=2ms TTL=253
Reply from 211.81.157.83: bytes=32 time=2ms TTL=253
Ping statistics for 211.81.157.83:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 2ms, Average = 2ms
C:\Documents and Settings\Administrator>ping 211.81.157.1
Pinging 211.81.157.1 with 32 bytes of data:
Reply from 211.81.157.1: bytes=32 time=11ms TTL=252
Reply from 211.81.157.1: bytes=32 time=10ms TTL=252
Reply from 211.81.157.1: bytes=32 time=9ms TTL=252
Reply from 211.81.157.1: bytes=32 time=8ms TTL=252
Ping statistics for 211.81.157.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 8ms, Maximum = 11ms, Average = 9ms
验证DHCP: 在主机上设置自动获取IP地址:
C:\Documents and Settings\Administrator>ipconfig
Windows IP Configuration
Ethernet adapter 本地连接:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.20.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.20.254
测试链路的选择情况:
C:\Documents and Settings\Administrator>tracert www.baidu.com
Tracing route to www.a.shifen.com [211.94.144.100]
over a maximum of 30 hops:
1 <1 ms <1 ms <1 ms 192.168.20.254
2 1 ms 1 ms 1 ms 192.168.2.1
3 2 ms 1 ms 1 ms 192.168.3.1
4 11 ms 9 ms 19 ms 211.81.157.1
5 3 ms 3 ms 4 ms 60.6.238.1
6 2 ms 2 ms 2 ms 60.6.39.125
7 * * 2 ms 218.12.255.221
8 3 ms 3 ms 3 ms 61.182.174.49
9 6 ms 5 ms 27 ms 61.182.174.113
10 24 ms 23 ms 23 ms pppa253.sj.he.cn [202.99.160.253]
11 23 ms 23 ms 23 ms 219.158.6.57
12 24 ms 24 ms 24 ms 202.96.12.34
13 24 ms 24 ms 23 ms 61.148.154.101
14 15 ms 14 ms 14 ms 202.106.193.149
15 24 ms 24 ms 24 ms 61.148.142.102
16 15 ms 15 ms 14 ms 61.51.26.210
17 24 ms 24 ms 24 ms 61.51.26.238
18 51 ms 51 ms 51 ms 202.99.1.69
19 50 ms 50 ms 50 ms 202.99.57.9
20 52 ms 51 ms 52 ms 202.99.1.102

