H3C交换机配置DHCP的方法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了H3C交换机配置DHCP的方法相关的知识,希望对你有一定的参考价值。

参考技术A

H3C交换机配置DHCP的方法

  通常,我们会使用一些网络硬件的功能,来进行一些服务的设置。这里我就讲解少一下H3C交换机配置DHCP的`内容,希望对你有帮助!

  目前网络中,很少使用交换机来做DHCP server,一般都是在交换机上配置DHCP中继来完成内网的IP地址分发。

  H3C交换机配置DHCP环境说明:DHCP server链接到H3C交换机的e1/0/1端口上,并属于vlan100;pc1与H3C交换机e1/0/2互联,属于vlan2;pc2与H3C交换机e1/0/3互联,属于vlan3.

  H3C交换机配置DHCP实例:

  [H3C]dhcp-server 0 ip 172.16.0.254 指定DHCP服务器地址

  [H3C]vlan 100

  [H3C-vlan100]port e1/0/1 将服务器端口放入vlan100

  [H3C-vlan100]quit

  [H3C]interface vlan-interface 100

  [H3C-Vlan-interface100]ip address 172.16.0.1 255.255.255.0

  [H3C]vlan 2

  [H3C-vlan2]port Ethernet 1/0/2

  [H3C-vlan2]quit

  [H3C]interface Vlan-interface 2

  [H3C-Vlan-interface2]ip address 10.1.1.1 255.255.255.0

  [H3C-Vlan-interface2]dhcp-server 0 在vlan2中指定dhcp中继

  [H3C]vlan 3

  [H3C-vlan3]port Ethernet 1/0/3

  [H3C-vlan3]quit

  [H3C]interface Vlan-interface 3

  [H3C-Vlan-interface3]ip address 10.1.2.1 255.255.255.0

  [H3C-Vlan-interface3]dhcp-server 0 在vlan3中指定dhcp中继

;

不同vlan通过配置DHCP中继自动获取IP且互通

实验名称:不同vlan通过配置DHCP中继自动获取IP且互通
实验目的:配置DHCP使DHCP客户端自动获取到IP并保证pc机互通
实验拓扑:
技术分享图片
实验需求:四台 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客户端为“自动获取”
    技术分享图片
    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服务端的IP地址池
技术分享图片
验证与测试:
自动获取到IP地址:
Pc1:
技术分享图片
Pc2:
技术分享图片
Pc3:
技术分享图片
Pc4:
技术分享图片
四台PC机互通:
技术分享图片
技术分享图片

实验总结:
1.保证全网互通才能正常获取到IP。
2.配置三层交换机时,一定要记得IP routing。
3.想让DHCP客户端获取到DHCP服务端分配的IP地址,在三层交换机一定要配置DHCP中继。

以上是关于H3C交换机配置DHCP的方法的主要内容,如果未能解决你的问题,请参考以下文章

h3c交换机怎样配置DHCP协议

H3C交换机基本配置vlan,dhcp,telnet

H3C交换机配置DHCP

H3C交换机(路由器)如何配置DHCP?

H3C交换机(路由器)如何配置DHCP?

H3C S5500 SI三层交换机如何配置DHCP服务器