其他分享
首页 > 其他分享> > DHCP中继配置案例

DHCP中继配置案例

作者:互联网

需求:在不同网段获取IP地址

  1. Router为DHCP服务器,开启DHCP服务,为PC分配地址,使用地址池网段为192.168.1.0/24,
  2. 地址池中排除掉地址192.168.1.254,192.168.1.253 ,这些地址留作他用
  3. 为客户端分配的网关地址是:192.168.1.254,分配租期为2天。DNS服务器地址为:8.8.8.8
  4. SW上部署两个VLAN;分别是VLAN10,VLAN20,PC属于VLAN10,Router属于VLAN20
  5. 要求PC机器能够通过DHCP自动获取IP地址和网关。

实现步骤

  1. 交换机配置vlan

    <Huawei>sys
    [Huawei]sys SW
    
    # 将 1端口划分 vlan10   24端口划分vlan 20
    [SW]vlan batch 10 20
    [SW]int g0/0/1
    [SW-GigabitEthernet0/0/1]port link-type access
    [SW-GigabitEthernet0/0/1]port default vlan 10
    
    
    [SW-GigabitEthernet0/0/1]int g0/0/24
    [SW-GigabitEthernet0/0/24]port link-type access
    [SW-GigabitEthernet0/0/24]port default vlan 20
    
    
    [SW-GigabitEthernet0/0/24]int vlanif 10
    [SW-Vlanif10]ip address 192.168.1.254 24
    
    [SW-Vlanif10]int vlanif 20
    [SW-Vlanif20]ip address 192.168.2.1 24
    
  2. 路由器配置地址池

    <Huawei>sys
    [Huawei]sys Router
    [Router]int g0/0/0
    [Router-GigabitEthernet0/0/0]ip address 192.168.2.2 24
    
    
    # 启动dhcp服务
    # 创建地址池
    
    [Router]dhcp enable
    [Router]ip pool dhcppool	#命名为 dhcppool
    [Router-ip-pool-dhcppool]dns-list 8.8.8.8  #dns 设置
    
    
    # 设置网关
    [Router-ip-pool-dhcppool]gateway-list 192.168.1.254
    
    # 分配网段
    [Router-ip-pool-dhcppool]network 192.168.1.0 mask 24
    
    # 排除分配,预留他用
    [Router-ip-pool-dhcppool]excluded-ip-address 192.168.1.250 192.168.1.253
    
    # 设置租期2天
    [Router-ip-pool-dhcppool]lease day 2
    
    [Router-ip-pool-dhcppool]dis this
    [V200R003C00]
    #
    ip pool dhcppool
     gateway-list 192.168.1.254 
     network 192.168.1.0 mask 255.255.255.0 
     excluded-ip-address 192.168.1.250 192.168.1.253 
     lease day 2 hour 0 minute 0 
     dns-list 8.8.8.8 
    #
    return
     
    # 进入端口0 ,启用dhcp 地址池
    [Router]int g0/0/0
    [Router-GigabitEthernet0/0/0]dhcp select global 
    
    
    # 返程路由
    [Router]ip route-static 192.168.1.0 24 192.168.2.1
    
  3. 交换机DHCP中继

    
    [SW]dhcp enable 
    [SW]int vlanif 10
    [SW-Vlanif10]dhcp select relay 
    
    #中继服务器地址 可以把192.168.2.2  地址池的地址分配给PC1
    # 从192.168.2.2  地址池拿IP
    [SW-Vlanif10]dhcp relay  server-ip 192.168.2.2
    
  4. PC从路由器预置地址池中获取IP地址

    PC>ipconfig
    
    Link local IPv6 address...........: fe80::5689:98ff:fe2c:7b1f
    IPv6 address......................: :: / 128
    IPv6 gateway......................: ::
    IPv4 address......................: 0.0.0.0
    Subnet mask.......................: 0.0.0.0
    Gateway...........................: 0.0.0.0
    Physical address..................: 54-89-98-2C-7B-1F
    DNS server........................:
    
    PC>ipconfig
    Link local IPv6 address...........: fe80::5689:98ff:fe2c:7b1f
    IPv6 address......................: :: / 128
    IPv6 gateway......................: ::
    IPv4 address......................: 192.168.1.249
    Subnet mask.......................: 255.255.255.0
    Gateway...........................: 192.168.1.254
    Physical address..................: 54-89-98-2C-7B-1F
    DNS server........................: 8.8.8.8
    

标签:24,中继,ip,address,SW,192.168,案例,Router,DHCP
来源: https://www.cnblogs.com/xuwei1/p/15265762.html