实验环境:
实验要求:PC1在192.168.10.0/24网段
PC2在192.168.20.0/24网段
PC3在192.168.30.0/24网段
路由器f0/0.1网关为192.168.10.1/24
路由器f0/0.2网关为192.168.20.1/24
路由器f0/0.3网关为192.168.30.1/24
实验过程:
1. 去除交换机sw1路由功能
sw1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
sw1(config)#no ip routing
2. 创建vlan10,vlan20,vlan30
sw1(config)#vlan 10
sw1(config-vlan)#exit
sw1(config)#vlan 20
sw1(config-vlan)#exit
sw1(config)#vlan 30
sw1(config-vlan)#exit
3. 开启sw1中f1/0接口的trunk模式
sw1(config)#int f1/0
sw1(config-if)#sw mo tr
sw1(config-if)#sw
sw1(config-if)#sw tr en do
sw1(config-if)#no sh
4. 在f/1接口中做access口vlan10
sw1(config-if)#int f1/1
sw1(config-if)#sw mo acc
sw1(config-if)#sw acc vlan 10
sw1(config-if)#no sh
5. 在f1/2接口中做access口vlan20
sw1(config-if)#int f1/2
sw1(config-if)#sw mo acc
sw1(config-if)#sw acc vlan 20
6. 在f1/3接口中做access口vlan30
sw1(config-if)#int f1/3
sw1(config-if)#sw mo acc
sw1(config-if)#sw acc vlan 30
sw1(config-if)#no sh
7. 在路由器R1上配置f0/0.1接口模式和IP地址
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int f0/0.1
R1(config-subif)#en do 10
R1(config-subif)#ip add 192.168.10.1 255.255.255.0
8. 配置f0/0.2接口模式和IP地址
R1(config-subif)#int f0/0.2
R1(config-subif)#en do 20
R1(config-subif)#ip add 192.168.20.1 255.255.255.0
R1(config-subif)#no sh
9. 配置f0/0.3接口模式和IP地址
R1(config-subif)#int f0/0.3
R1(config-subif)#en do 30
R1(config-subif)#ip add 192.168.30.1 255.255.255.0
R1(config-subif)#no sh
10. 将f0/0接口开启
R1(config)#int f0/0
R1(config-if)#no sh
11. 分别配置vlan10,vlan20,vlan30的DHCP
R1(config)#ip dhcp pool vlan10
R1(dhcp-config)#netw
R1(dhcp-config)#network 192.168.10.0 255.255.255.0
R1(dhcp-config)#de
R1(dhcp-config)#default-router 192.1568
*Mar 100:06:49.999: %CDP-4-DUPLEX_MISMATCH: duplex mismatch discovered onFastEthernet0/0 (not full duplex), with sw1 FastEthernet1/0 (full duplex).
R1(dhcp-config)#default-router 192.168.10.1
R1(dhcp-config)#dns
R1(dhcp-config)#dns-server
R1(dhcp-config)#dns-server 114.114.114.114 8.8.8.8
R1(dhcp-config)#le
R1(dhcp-config)#lease 5
R1(dhcp-config)#exit
R1(config)#ip dhcp po
R1(config)#ip dhcp pool
*Mar 100:07:49.975: %CDP-4-DUPLEX_MISMATCH: duplex mismatch discovered onFastEthernet0/0 (not full duplex), with sw1 FastEthernet1/0 (full duplex).
R1(config)#ip dhcp pool vlan20
R1(dhcp-config)#netw
R1(dhcp-config)#network 192.168.20.0 255.255.255.0
R1(dhcp-config)#de
R1(dhcp-config)#default-router 192.168.20.1
R1(dhcp-config)#dns
R1(dhcp-config)#dns-server 114.114.114.114 8.8.8.8
R1(dhcp-config)#le
R1(dhcp-config)#lease 5
*Mar 100:08:49.971: %CDP-4-DUPLEX_MISMATCH: duplex mismatch discovered onFastEthernet0/0 (not full duplex), with sw1 FastEthernet1/0 (full duplex).
R1(dhcp-config)#exit
R1(config)#ip dhcp po
R1(config)#ip dhcp pool vlan30
R1(dhcp-config)#netw
R1(dhcp-config)#network 192.168.30.0 255.255.255.0
R1(dhcp-config)#de
R1(dhcp-config)#default-router 192.168.30.1
R1(dhcp-config)#dns
R1(dhcp-config)#dns-server 114.114.114.114 8.8.8.8
R1(dhcp-config)#le
R1(dhcp-config)#lease 5
12. 让PC机自动获取DHCP地址
VPCS[1]> ip dhcp
DDORA IP 192.168.10.2/24 GW 192.168.10.1
VPCS[1]> 2
VPCS[2]> ip dhcp
DDORA IP 192.168.20.2/24 GW 192.168.20.1
VPCS[2]> 3
VPCS[3]> ip dhcp
DDORA IP 192.168.30.2/24 GW 192.168.30.1
13. Ping通实验
VPCS[3]> ping 192.168.20.2
192.168.20.2 icmp_seq=1 ttl=63 time=32.149 ms
192.168.20.2 icmp_seq=2 ttl=63 time=48.299 ms
192.168.20.2 icmp_seq=3 ttl=63 time=32.283 ms
192.168.20.2 icmp_seq=4 ttl=63 time=47.820 ms
192.168.20.2 icmp_seq=5 ttl=63 time=32.510 ms
VPCS[3]> ping 192.168.10.2
192.168.10.2 icmp_seq=1 ttl=63 time=79.000 ms
192.168.10.2 icmp_seq=2 ttl=63 time=47.737 ms
192.168.10.2 icmp_seq=3 ttl=63 time=32.385 ms
192.168.10.2 icmp_seq=4 ttl=63 time=48.887 ms
192.168.10.2 icmp_seq=5 ttl=63 time=33.041 ms
能互相通信,实验完成。
实验总结: 通过实验了解单臂路由的原理以及实现单臂路由的命令,dhcp的设置过程,
能在不同网段下vlan直接的互通。
原文地址:http://jigang.blog.51cto.com/12902771/1935133