The software simulates the configuration of a DHCP relay agent

DHCP relay can process and forward DHCP information between different subnets and physical network segments.
DHCP has the following functions:

  1. It is guaranteed that any IP address can only be used by one DHCP client at a time.
  2. DHCP should be able to assign permanent fixed IP addresses to users.
  3. DHCP should be able to coexist with hosts that obtain IP addresses by other means (eg, hosts manually configured with IP addresses).
  4. The DHCP server should serve existing BOOTP clients.

Experiment preparation


GNS3, Linux virtual machine (Red Hat Enterprise 6.5
Linux virtual machine to mount the CD-ROM (image file) into the system

Purpose


Use DHCP relay to forward dhcp information between different vlans, so that the PC can automatically obtain an IP address from the dhcp server

Experiment starts


Draw network topology in GNS3 software

Note: When connecting to the Linux server, you need to select the vmnet1 network card (the network card selection here should be consistent with the Linux host, and the Linux server selects only the host mode vmnet1)
The software simulates the configuration of a DHCP relay agent
Layer 2 switch and Layer 3 switch configuration in the network topology Layer
2 switch configuration

  • Ports with trunk and vlan encapsulation mode dot1q (the port with trunk is the port on the Layer 2 switch that is connected to the Layer 3 switch)
switchport mode trunk      //端口做trunk
switchport trunk encapsulation dot1q        //vlan封装方式为dot1q

The software simulates the configuration of a DHCP relay agent

  • Divide vlan, add port to vlan
vlan 10,20,100     //一次划分多个vlan
int f1/1        //进端口
switchport mode access    //端口做access
switchport access vlan 10    //将端口加入到vlan

The software simulates the configuration of a DHCP relay agent
Layer 3 switch configuration

  • Ports with trunk and vlan encapsulation mode dot1q (the port with trunk is the port on the Layer 3 switch that is connected to the Layer 2 switch, the method is the same as the configuration of the Layer 2 switch)
switchport mode trunk      //端口做trunk
switchport trunk encapsulation dot1q        //vlan封装方式为dot1q
  • Divide vlan and assign address to each vlan
    int vlan 10    //进vlan
    ip add 192.168.10.1 255.255.255.0 //配地址,子网掩码
    no shut    //开启端口

    The software simulates the configuration of a DHCP relay agent
    linux configuration

  • install dhcp package
    rpm -ivh /mnt/Packages/dhcp-4.1.1-38.P1.el6.x86_64.rpm
  • Copy the dhcpd.conf configuration file to the /etc directory xi
    cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
  • Modify the configuration file
    vim /etc/dhcp/dhcpd.conf
    subnet 192.168.175.0 netmask 255.255.255.0 {     //写入需要自动获取的网段及子网掩码
        range 192.168.175.100 192.168.175.110;       //自动获取的地址短
        option routers 192.168.175.1;  //网关地址
    }

    After each statement in the configuration file, add a semicolon ";" at the end of the
    The software simulates the configuration of a DHCP relay agent
    The software simulates the configuration of a DHCP relay agent
    configuration to exit the vim editor and start the service

    service dhcpd start

    Back to the Layer 3 switch again

    int vlan 10
    ip helper-address 192.168.175.105      //指定dhcp服务器的地址,表示通过指定端口向该服务器发送DHCP请求包

    The software simulates the configuration of a DHCP relay agent
    Open VPCS to automatically obtain the address of the address segment allowed by the server
    The software simulates the configuration of a DHCP relay agent

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325275053&siteId=291194637