vlan da vlan 10 vlan 20 vlan 30 vlan 40 exit conf ter int vlan 10 ip add 192.168.1.1 255.255.255.0 int vlan 20 ip add 192.168.2.1 255.255.255.0 int vlan 30 ip add 192.168.3.1 255.255.255.0 int vlan 40 ip add 192.168.4.1 255.255.255.0 ip routing ip dhcp excluded-address 192.168.1.1 ip dhcp excluded-address 192.168.2.1 ip dhcp excluded-address 192.168.3.1 ip dhcp excluded-address 192.168.4.1 ip dhcp pool 1 net 192.168.1.0 255.255.255.0 default-ro 192.168.1.1 dns-server 1.1.1.1 ip dhcp pool 2 net 192.168.2.0 255.255.255.0 default-ro 192.168.2.1 dns-server 1.1.1.1 ip dhcp pool 3 net 192.168.3.0 255.255.255.0 default-ro 192.168.3.1 dns-server 1.1.1.1 ip dhcp pool 4 net 192.168.4.0 255.255.255.0 default-ro 192.168.4.1 dns-server 1.1.1.1 exit SW1: conf ter int f0/1 sw acc vlan 10 exit int f0/2 sw acc vlan 20 exit int f0/3 sw mode trunk sw trunk allowed vlan all exit SW2: conf ter int f0/1 sw acc vlan 30 exit int f0/2 sw acc vlan 40 exit int f0/3 sw mode trunk sw trunk allowed vlan all exit 测试: Packet Tracer PC Command Line 1.0 PC>ipconfig /all
FastEthernet0 Connection:(default port) Physical Address................:0030.F2BB.C910 Link-local IPv6 Address.........:FE80::230:F2FF:FEBB:C910 IP Address......................:192.168.1.2 Subnet Mask.....................:255.255.255.0 Default Gateway.................:192.168.1.1 DNS Servers.....................: 1.1.1.1 DHCP Servers....................:192.168.1.1
PC>ipconfig /release
IP Address......................: 0.0.0.0 Subnet Mask.....................: 0.0.0.0 Default Gateway.................: 0.0.0.0 DNS Server......................: 0.0.0.0
PC>ipconfig /renew
IP Address......................: 192.168.1.2 Subnet Mask.....................:255.255.255.0 Default Gateway.................:192.168.1.1 DNS Server......................: 1.1.1.1
PC>ipconfig /all
FastEthernet0 Connection:(default port) Physical Address................:0030.F2BB.C910 Link-local IPv6 Address.........:FE80::230:F2FF:FEBB:C910 IP Address......................:192.168.1.2 Subnet Mask.....................:255.255.255.0 Default Gateway.................:192.168.1.1 DNS Servers.....................: 1.1.1.1 DHCP Servers....................:192.168.1.1
PC>ping 192.168.4.2
Pinging 192.168.4.2 with 32 bytes of data:
Request timed out. Reply from 192.168.4.2: bytes=32 time=0msTTL=127 Reply from 192.168.4.2: bytes=32 time=15msTTL=127 Reply from 192.168.4.2: bytes=32 time=16msTTL=127
Ping statistics for 192.168.4.2: Packets: Sent = 4, Received = 3, Lost = 1 (25% loss), Approximate round trip times inmilli-seconds: Minimum = 0ms, Maximum = 16ms, Average = 10ms
PC>ping 192.168.3.2
Pinging 192.168.3.2 with 32 bytes of data:
Request timed out. Reply from 192.168.3.2: bytes=32 time=0msTTL=127 Reply from 192.168.3.2: bytes=32 time=0msTTL=127 Reply from 192.168.3.2: bytes=32 time=15msTTL=127
Ping statistics for 192.168.3.2: Packets: Sent = 4, Received = 3, Lost = 1 (25% loss), Approximate round trip times inmilli-seconds: Minimum = 0ms, Maximum = 15ms, Average = 5ms
PC>ping 192.168.2.2
Pinging 192.168.2.2 with 32 bytes of data:
Request timed out. Reply from 192.168.2.2: bytes=32 time=16msTTL=127 Reply from 192.168.2.2: bytes=32 time=15msTTL=127 Reply from 192.168.2.2: bytes=32 time=0msTTL=127
Ping statistics for 192.168.2.2: Packets: Sent = 4, Received = 3, Lost = 1 (25% loss), Approximate round trip times inmilli-seconds: Minimum = 0ms, Maximum = 16ms, Average = 10ms
|