实验要求:

使得2台不同VLANPC机互通及自动获得IP地址

所需设备:

使用GNS3模拟器 模拟1C2691路由器 1台交换机 2PC

实验拓扑图:

150735897.png

实验过程:

1.C1 C2分别划分到VLAN10 VLAN20

150828823.png

150931425.png

2.1/0接口设为中继口

151003118.png

3.将交换机IP 设置为自动获取

151038234.png

4.为交换机设置网关

151110476.png

5.R1 0/0接口分成2个子接口0.10.2

F0/0.1

R1#conf t //全局配置模式

R1(config)#int fa 0/0.1 //新建子接口f0/0.1

R1(config-subif)#encapsulation dot1Q 10 //将子接口给VLAN10使用

R1(config-subif)#ip add 192.168.10.1 255.255.255.0 //配置网关及掩码

R1(config-subif)#no shut //激活

151140395.png

F0/0.2

R1#conf t

R1(config)#int fa 0/0.2

R1(config-subif)#encapsulation dot1Q 20

R1(config-subif)#ip add 192.168.20.1 255.255.255.0

R1(config-subif)#no shut

151222194.png

6.设置DHCP ip自动获取网段

设置192.168.1.0网段

R1#conf t//全局配置模式

R1(config)#ip dhcp pool vlan1 //新建VLAN1(名称自取)

R1(dhcp-config)#network 192.168.1.0 /24 //建立192.168.1.0网段 使用24掩码

R1(dhcp-config)#default-router 192.168.1.1 // 设置网关192.168.1.

151254254.png

设置192.168.10.0网段

151325733.png

设置192.168.20.0网段

151403167.png

7.激活R10/0接口

151437206.png

8.使用虚拟PC获取IP

151507851.png