1. 程式人生 > >基礎實驗1(單臂路由及利用路由器開啟DHCP自動分配IP地址)

基礎實驗1(單臂路由及利用路由器開啟DHCP自動分配IP地址)

單臂路由 路由器dhcp服務應用 子接口封裝協議

技術分享

實驗環境:PT 6.2

兩臺PC:PC1/PC2 一臺cisco 2960交換機 一臺2620路由器

實驗目的:讓PC1/PC2屬於不同的VLAN,且相互通信。同時自動獲取各自網段IP地址。

1、進入2960的配置模式,劃分不同的vlan並將PC1/PC2劃入不同的網段。並將連通路由器端口轉為幹道協議。

代碼如下:

>en

#conf t

config)#vlan 10

config)#vlan 20

config)#int f0/21

config)#switchport ac vlan 10

config)#int f0/22

config)#switchport ac vlan 20

config)#int f0/1

config)#switchport mo tr

config)#ex

2、配置路由器到交換機接口為開啟狀態,並開啟路由器的子接口。封裝協議並配置子接口IP地址。開啟路由器DHCP服務(網段以172.16.x.0為例)

代碼如下:

en

#conf t

config)#int f0/0

config-if)#ip add 172.16.1.1 255.255.255.0 (此行添加沒有多大意義,由於是實驗故沒有配置DNS)

config-if)#no shut

config)#int f0/0.10
config-sub)#en dot1q 10

config-sub)#ip add 172.16.10.1 255.255.255.0

config-sub)#ex

config)#int f0/0.20

config-sub)#en dot1q 20

config-sub)#ip add 172.16.20.1 255.255.255.0

config-sub)#ex

config)#service dhcp

config-dhcp)#ip dhcp pool vlan 10

config-dhcp)#network 172.16.10.0 255.255.255.0

config-dhcp)#default-router 172.16.10.1

config-dhcp)#ip dhcp pool vlan 20

config-dhcp)#network 172.16.20.0 255.255.255.0

config-dhcp)#default-router 172.16.20.1

config-dhcp)#ex

3、測試運行情況

PC1 to PC2

技術分享

技術分享


PC2 to PC1


技術分享

技術分享

基礎實驗,路由器接口f0/0是否需要配置地址及配置地址意義在哪。沒有想清楚,最初當做子接口指定網關用。後來發現並非如此,請各位大牛提出好的建議。

本文出自 “故地南國blog” 博客,轉載請與作者聯系!

基礎實驗1(單臂路由及利用路由器開啟DHCP自動分配IP地址)