注意:在配置之前请先看拓扑图(要关注设备之间的连接和连接所用的端口);并用笔画出拓扑图,在图上备注IP地址和端口信息。
本步目标特注:内网主机(PC1~PC8)能够相互访问;内网主机能够访问外网主机(PC9)。
第一部分:配置交换机1912-1、1912-2和路由器R2621-1(PC机分别属于不同Vlan及不同IP网段)
//配置交换机1912-1
>en
#conf t
Enter configuration commands, one per line. End with CNTL/Z.
(config)#vlan 2 name v2
(config)#int e0/2
(config-if)#vlan-membership static 2
(config-if)#exit
(config)#int fa0/26
(config-if)#trunk on
(config-if)#exit
(config)#int fa0/27
(config-if)#trunk on
//配置交换机1912-2
>en
#conf t
Enter configuration commands, one per line. End with CNTL/Z.
(config)#vlan 2 name v2
(config)#int e0/2
(config-if)#v s 2
(config-if)#exit
(config)#int fa0/26
(config-if)#trunk on
//配置路由器R2621-1
Router>
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int fa0/0
Router(config-if)#no ip address (只须在已经为此端口配置IP地址的情况下使用该命令)
Router(config-if)#no shutdown
%LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
Router(config-if)#int fa0/0.1
Router(config-subif)#encapsulation isl 1
Router(config-subif)#ip addres 192.168.1.10 255.255.255.0
Router(config-subif)#int fa0/0.2
Router(config-subif)#encapsulation isl 2
Router(config-subif)#ip addres 192.168.2.10 255.255.255.0
Router(config-subif)#end
Router#sh int fa0/0.1
FastEthernet0/0.1.1 is up, line protocol is up
Internet address is 192.168.1.10/24
MTU 1500 bytes, BW Kbit, DLY 1000 usec, rely 255/255, load 1/255
Encapsulation ARPA, loopback not set, keepalive set (10 sec)
Auto-duplex, Auto Speed, 100BaseTX/FX
ARP type: ARPA, ARP Timeout 04:00:00
Router#sh int fa0/0.2
FastEthernet0/0.2.2 is up, line protocol is up
Internet address is 192.168.2.10/24
MTU 1500 bytes, BW Kbit, DLY 1000 usec, rely 255/255, load 1/255
Encapsulation ARPA, loopback not set, keepalive set (10 sec)
Auto-duplex, Auto Speed, 100BaseTX/FX
ARP type: ARPA, ARP Timeout 04:00:00
//配置PC机
PC1:配置IP地址为192.168.1.1(根据交换机上的配置PC1属于vlan1),默认网关地址为192.168.1.10;
PC2:配置IP地址为192.168.2.2(根据交换机上的配置PC2属于vlan2),默认网关地址为192.168.2.10;
PC3:配置IP地址为192.168.1.3(根据交换机上的配置PC3属于vlan1),默认网关地址为192.168.1.10;
PC4:配置IP地址为192.168.2.4(根据交换机上的配置PC4属于vlan2),默认网关地址为192.168.2.10。
---在PC2上用ping命令测试:
C:>ping 192.168.2.4
Pinging 192.168.2.4 with 32 bytes of data:
Reply from 192.168.2.4: bytes=32 time=60ms TTL=241
Reply from 192.168.2.4: bytes=32 time=60ms TTL=241
Reply from 192.168.2.4: bytes=32 time=60ms TTL=241
Reply from 192.168.2.4: bytes=32 time=60ms TTL=241
Reply from 192.168.2.4: bytes=32 time=60ms TTL=241
Ping statistics for 192.168.2.4: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
C:>ping 192.168.2.10
Pinging 192.168.2.10 with 32 bytes of data:
Reply from 192.168.2.10: bytes=32 time=60ms TTL=241
Reply from 192.168.2.10: bytes=32 time=60ms TTL=241
Reply from 192.168.2.10: bytes=32 time=60ms TTL=241
Reply from 192.168.2.10: bytes=32 time=60ms TTL=241
Reply from 192.168.2.10: bytes=32 time=60ms TTL=241
Ping statistics for 192.168.2.10: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
C:>ping 192.168.1.10
Pinging 192.168.1.10 with 32 bytes of data:
Reply from 192.168.1.10: bytes=32 time=60ms TTL=241
Reply from 192.168.1.10: bytes=32 time=60ms TTL=241
Reply from 192.168.1.10: bytes=32 time=60ms TTL=241
Reply from 192.168.1.10: bytes=32 time=60ms TTL=241
Reply from 192.168.1.10: bytes=32 time=60ms TTL=241
Ping statistics for 192.168.1.10: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
C:>ping 192.168.1.1
Pinging 192.168.1.1 with 32 bytes of data:
Reply from 192.168.1.1: bytes=32 time=60ms TTL=241
Reply from 192.168.1.1: bytes=32 time=60ms TTL=241
Reply from 192.168.1.1: bytes=32 time=60ms TTL=241
Reply from 192.168.1.1: bytes=32 time=60ms TTL=241
Reply from 192.168.1.1: bytes=32 time=60ms TTL=241
Ping statistics for 192.168.1.1: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
C:>ping 192.168.1.3
Pinging 192.168.1.3 with 32 bytes of data:
Reply from 192.168.1.3: bytes=32 time=60ms TTL=241
Reply from 192.168.1.3: bytes=32 time=60ms TTL=241
Reply from 192.168.1.3: bytes=32 time=60ms TTL=241
Reply from 192.168.1.3: bytes=32 time=60ms TTL=241
Reply from 192.168.1.3: bytes=32 time=60ms TTL=241
Ping statistics for 192.168.1.3: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
---在PC3上用ping命令测试:
C:>ping 192.168.1.1
Pinging 192.168.1.1 with 32 bytes of data:
Reply from 192.168.1.1: bytes=32 time=60ms TTL=241
Reply from 192.168.1.1: bytes=32 time=60ms TTL=241
Reply from 192.168.1.1: bytes=32 time=60ms TTL=241
Reply from 192.168.1.1: bytes=32 time=60ms TTL=241
Reply from 192.168.1.1: bytes=32 time=60ms TTL=241
Ping statistics for 192.168.1.1: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
C:>ping 192.168.1.10
Pinging 192.168.1.10 with 32 bytes of data:
Reply from 192.168.1.10: bytes=32 time=60ms TTL=241
Reply from 192.168.1.10: bytes=32 time=60ms TTL=241
Reply from 192.168.1.10: bytes=32 time=60ms TTL=241
Reply from 192.168.1.10: bytes=32 time=60ms TTL=241
Reply from 192.168.1.10: bytes=32 time=60ms TTL=241
Ping statistics for 192.168.1.10: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
C:>ping 192.168.2.10
Pinging 192.168.2.10 with 32 bytes of data:
Reply from 192.168.2.10: bytes=32 time=60ms TTL=241
Reply from 192.168.2.10: bytes=32 time=60ms TTL=241
Reply from 192.168.2.10: bytes=32 time=60ms TTL=241
Reply from 192.168.2.10: bytes=32 time=60ms TTL=241
Reply from 192.168.2.10: bytes=32 time=60ms TTL=241
Ping statistics for 192.168.2.10: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
C:>ping 192.168.2.2
Pinging 192.168.2.2 with 32 bytes of data:
Reply from 192.168.2.2: bytes=32 time=60ms TTL=241
Reply from 192.168.2.2: bytes=32 time=60ms TTL=241
Reply from 192.168.2.2: bytes=32 time=60ms TTL=241
Reply from 192.168.2.2: bytes=32 time=60ms TTL=241
Reply from 192.168.2.2: bytes=32 time=60ms TTL=241
Ping statistics for 192.168.2.2: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
C:>ping 192.168.2.4
Pinging 192.168.2.4 with 32 bytes of data:
Reply from 192.168.2.4: bytes=32 time=60ms TTL=241
Reply from 192.168.2.4: bytes=32 time=60ms TTL=241
Reply from 192.168.2.4: bytes=32 time=60ms TTL=241
Reply from 192.168.2.4: bytes=32 time=60ms TTL=241
Reply from 192.168.2.4: bytes=32 time=60ms TTL=241
Ping statistics for 192.168.2.4: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
第二部分:配置路由器R2621-2和PC5~PC8(PC机分别属于不同IP网段)
//配置路由器R2621-2
Router>en
Router#conf t
Enter config