思科——DHCP中繼的應用

實驗名稱:不同vlan通過配置DHCP中繼自動獲取IP且互通
實驗目的:配置DHCP使DHCP客戶端自動獲取到IP並保證pc機互通
實驗拓撲:
思科——DHCP中繼的應用
實驗需求:四臺 PC機,四臺交換機,一臺三層交換機,一臺路由器,一臺服務器
實驗思路:
1、配置 DHCP 客戶端
確保每個 PC 爲 自動獲取IP地址的方式;
2、配置交換機,確保DHCP客戶端與服務器之間的 DHCP 報文互通;

將相關的端口,放入到對應的 VLAN ;

# 配置交換機之間的互聯鏈路 - Trunk ; 

3、配置三層交換機
—配置與交換機之間的互聯鏈路 - Trunk ;
—配置爲 每個 VLAN 的網關
&開啓路由功能
&配置每個VLAN對應的 SVI ;
&配置DHCP中繼
&配置與 Router 的互聯網段爲三層端口
&配置與 Router 的互聯端口的 IP 地址 - 192.168.88.0/24
&配置去往 DHCP 服務器網段的路由
4、配置 Router 的相關接口地址以及去往各個vlan的路由;
5、配置 DHCP-Server 的IP地址池
實驗步驟:

  1. 配置DHCP客戶端爲“自動獲取”
    思科——DHCP中繼的應用
    Pc全部以上配置。
  2. 確保DHCP客戶端與服務器之間的 DHCP 報文互通
    1) 創建vlan,將接口加入相應vlan,
    2) 交換機與交換機之間配置trunk模式
    Sw1:
    Switch>en
    Switch#configure terminal
    Enter configuration commands, one per line. End with CNTL/Z.
    Switch(config)#hostname sw1
    sw1(config)#vlan 10
    sw1(config-vlan)#vlan 20
    sw1(config-vlan)#vlan 30
    sw1(config-vlan)#vlan 40
    sw1(config-vlan)#exit
    sw1(config)#interface fastEthernet 0/1
    sw1(config-if)#switchport mode access
    sw1(config-if)#switchport access vlan 10
    sw1(config-if)#exit
    sw1(config)#interface fastEthernet 0/2
    sw1(config-if)#switchport mode access
    sw1(config-if)#switchport access vlan 20
    sw1(config-if)#exit
    sw1(config)#int
    sw1(config)#interface f
    sw1(config)#interface fastEthernet 0/3
    sw1(config-if)#switchport mode trunk
    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down
    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up
    sw1(config-if)#switchport trunk allowed vlan all
    sw1(config-if)#exit
    sw1(config)#interface fastEthernet 0/4
    sw1(config-if)#switchport mode trunk
    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to down
    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to up
    sw1(config-if)#switchport trunk allowed vlan all
    sw1(config-if)#exit
    sw1(config)#interface fastEthernet 0/5
    sw1(config-if)#switchport mode trunk
    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to down
    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to up
    sw1(config-if)#switchport trunk allowed vlan all
    sw1(config-if)#exit

Sw2:
Switch>en
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname sw2
Sw2(config)#vlan 10
Sw2(config-vlan)#vlan 20
Sw2(config-vlan)#vlan 30
Sw2(config-vlan)#vlan 40
Sw2(config-vlan)#exit
Sw2(config)#interface fastEthernet 0/1
Sw2(config-if)#switchport mode access
Sw2(config-if)#switchport access vlan 30
Sw2(config-if)#exit
Sw2(config)#interface fastEthernet 0/2
Sw2(config-if)#switchport mode access
Sw2(config-if)#switchport access vlan 40
Sw2(config-if)#exit
Sw2(config)#int
Sw2(config)#interface f
Sw2(config)#interface fastEthernet 0/3
Sw2(config-if)#switchport mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up
Sw2(config-if)#switchport trunk allowed vlan all
Sw2(config-if)#exit
Sw2(config)#interface fastEthernet 0/4
Sw2(config-if)#switchport mode trunk
%LNEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to up
Sw2(config-if)#switchport trunk allowed vlan all
Sw2(config-if)#exit
Sw2(config)#interface fastEthernet 0/5
Sw2(config-if)#switchport mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to up
Sw2(config-if)#switchport trunk allowed vlan all
Sw2(config-if)#exit

Sw3:
Switch>en
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname sw3
sw3(config)#vlan 10
sw3(config-vlan)#vlan 20
sw3(config-vlan)#vlan 30
sw3(config-vlan)#vlan 40
sw3(config-vlan)#exit
sw3(config)#interface fastEthernet 0/1
sw3(config-if)#switchport mode trunk
sw3(config-if)#switchport trunk allowed vlan all
sw3(config-if)#exit
sw3(config)#interface fastEthernet 0/2
sw3(config-if)#switchport mode trunk
sw3(config-if)#switchport trunk allowed vlan all
sw3(config-if)#exit
sw3(config)#interface fastEthernet 0/3
sw3(config-if)#switchport mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up
sw3(config-if)#switchport trunk allowed vlan all
sw3(config-if)#exit

Sw4:
Switch>en
Switch#configure
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname sw4
sw4(config)#vlan 10
sw4(config-vlan)#vlan 20
sw4(config-vlan)#vlan 30
sw4(config-vlan)#vlan 40
sw4(config-vlan)#exit
sw4(config)#interface fastEthernet 0/1
sw4(config-if)#switchport mode trunk
sw4(config-if)#switchport trunk allowed vlan all
sw4(config-if)#exit
sw4(config)#interface fastEthernet 0/2
sw4(config-if)#switchport mode trunk
sw4(config-if)#switchport trunk allowed vlan all
sw4(config-if)#exit
sw4(config)#interface fastEthernet 0/3
sw4(config-if)#switchport mode trunk
sw4(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up
sw4(config-if)#switchport trunk allowed vlan all
sw4(config-if)#exit
sw4(config)#
3.配置三層交換機
1)配置與交換機之間的互聯鏈路 爲 Trunk模式 ;
Switch>enable
Switch#configure
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname gateway
gateway(config)#vlan 10
gateway(config-vlan)#vlan 20
gateway(config-vlan)#vlan 30
gateway(config-vlan)#vlan 40
gateway(config-vlan)#exit
gateway(config)#interface fastEthernet 0/1
gateway(config-if)#switchport trunk encapsulation dot1q
gateway(config-if)#switchport mode trunk
gateway(config-if)#switchport trunk allowed vlan all
gateway(config-if)#exit
gateway(config)#interface fastEthernet 0/2
gateway(config-if)#switchport trunk encapsulation
gateway(config-if)#switchport trunk encapsulation dot1q
gateway(config-if)#switchport mode trunk
gateway(config-if)#switchport trunk allowed vlan all
gateway(config-if)#exit
2)配置每個vlan的網關
&開啓路由功能
gateway(config)#ip routing
&配置每個VLAN對應的 SVI ;
gateway(config)#interface vlan 10
gateway(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
gateway(config-if)#no shutdown
gateway(config-if)#ip address 192.168.10.254 255.255.255.0
gateway(config-if)#exit
gateway(config)#interface vlan 20
%LINK-5-CHANGED: Interface Vlan20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
gateway(config-if)#no shutdown
gateway(config-if)#ip address 192.168.20.254 255.255.255.0
gateway(config-if)#exit
gateway(config)#interface vlan 30
%LINK-5-CHANGED: Interface Vlan30, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan30, changed state to up
gateway(config-if)#no shutdown
gateway(config-if)#ip address 192.168.30.254 255.255.255.0
gateway(config-if)#exit
gateway(config)#interface vlan 40
%LINK-5-CHANGED: Interface Vlan40, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan40, changed state to up
gateway(config-if)#no shutdown
gateway(config-if)#ip address 192.168.40.254 255.255.255.0
gateway(config-if)#exit
&配置與 Router 的互聯網段爲三層端口
gateway(config)#interface fastEthernet 0/3
&配置與 Router 的互聯端口的 IP 地址 - 192.168.88.0/24
gateway(config-if)#no switchport
gateway(config-if)#no shutdown
gateway(config-if)#ip address 192.168.50.1 255.255.255.0
gateway(config-if)#exit
&配置去往 DHCP 服務器網段的路由
gateway(config)#ip route 192.168.60.0 255.255.255.0 192.168.50.2
gateway(config)#
3)配置DHCP中繼
gateway(config)#interface vlan 10
gateway(config-if)#ip helper-address 192.168.60.1
gateway(config-if)#exit
gateway(config)#interface vlan 20
gateway(config-if)#ip help
gateway(config-if)#ip helper-address 192.168.60.1
gateway(config-if)#exit
gateway(config)#interface vlan 30
gateway(config-if)#ip helper-address 192.168.60.1
gateway(config-if)#exit
gateway(config)#interface vlan 40
gateway(config-if)#ip helper-address 192.168.60.1
gateway(config-if)#exit
gateway(config)#
4.配置router路由器
配置接口ip
Router>en
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface gigabitEthernet 0/0
RRouter(config-if)#no shutdown
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
Router(config-if)#ip address 192.168.50.2 255.255.255.0
Router(config-if)#exit
Router(config)#interface gigabitEthernet 0/1
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up
Router(config-if)#ip address 192.168.60.254 255.255.255.0
Router(config-if)#exit
配置去往 DHCP 客戶器網段的路由
Router(config)#ip route 0.0.0.0 0.0.0.0 192.168.50.1
Router(config)#

5.配置DHCP服務端
配置DHCP服務端ip
思科——DHCP中繼的應用
配置DHCP服務端的IP地址池
思科——DHCP中繼的應用
驗證與測試:
自動獲取到IP地址:
Pc1:
思科——DHCP中繼的應用
Pc2:
思科——DHCP中繼的應用
Pc3:
思科——DHCP中繼的應用
Pc4:
思科——DHCP中繼的應用
四臺PC機互通:
思科——DHCP中繼的應用
思科——DHCP中繼的應用

實驗總結:
1.保證全網互通才能正常獲取到IP。
2.配置三層交換機時,一定要記得IP routing。
3.想讓DHCP客戶端獲取到DHCP服務端分配的IP地址,在三層交換機一定要配置DHCP中繼。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章