實驗要求:ide
使得2臺不一樣VLAN的PC機互通及自動得到IP地址spa
所需設備:3d
使用GNS3模擬器 模擬1臺C2691路由器 1臺交換機 2臺PCrouter
實驗過程:接口
1.將C1 C2分別劃分到VLAN10 VLAN20ip
2.將1/0接口設爲中繼口路由
3.將交換機IP 設置爲自動獲取get
4.爲交換機設置網關it
5.將R1 0/0接口分紅2個子接口0.1和0.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 //激活
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
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.
設置192.168.10.0網段
設置192.168.20.0網段
7.激活R10/0接口
8.使用虛擬PC獲取IP