Install and configure the DHCP service in unixlinux

Source: Internet
Author: User
Install and configure the DHCP service in unixlinux-Linux Enterprise Application-Linux server application information. For more information, see. I. Prerequisites for DHCP server operation:

To enable the DHCP server to serve windows machines, you may need to create a route to the IP address 255.255.255.255 and add this route command to/etc/rc. d/rc. local Enables automatic operation after each startup.

# Route add-host route 255.255.255 dev eth0

If an error message is reported: commandid 255.255: Unkown host

Try adding the following entry to the/etc/hosts file:

# Route add-host dhcp dev eth0.

   2. The DHCPd background program always reads the configuration file/etc/dhcpd. conf. The following is an example of the DHCP configuration file:

# Sample/etc/dhcpd. conf

Default-lease-time 1200;

Max-lease-time 9200;

Option subnet-mask limit 255.0;

Option broadcast-address 192.168.1.255;

Option routers 192.168.1.254;

Option domain-name-servers 192.168.1.1, 192.168.1.2;

Option domain-name "mydomain.org ";

Subnet 192.168.1.0 netmask 255.255.255.0 {

Range 192.168.1.10 192.168.1.100;

Range 192.168.1.150 192.168.1.200;

}

This will allow the DHCP server to allocate two IP address ranges to the customer 192.168.1.10-100 or 192.168.1.150-200. if the customer does not continue to request the DHCP address, the IP address will be released after 1200 seconds, otherwise, the maximum lease time is 9200 seconds.

The server sends the following parameters to the DHCP Client: 255.255.255.0 is used as the subnet mask, 192.168.1.255 is used as the broadcast address, and 192.168.1.254 is used as the default gateway, use 192.168.1.1 and 192.168.1.2 as the DNS server. If you want to specify a WINS server for windows customers, you need to include the following options to dhcpd. in the conf file: option netbios-name-servers 192.168.1.1.

   III. you can also specify a fixed IP address for a network card. At any time, the network card will always get a fixed IP address from the DHCP server, and add the following statement to/etc/dhcpd. conf:

Host haagen {

Hardware ethernet 08: 00: 2b: 4c: 59: 23;

Fixed-address 192.168.1.222;

}

You can also write a row:

Host Jephe {hardware ethernet 00: a0: c9: a6: 96: 33; fixed-address 192.168.1.12 ;}

You can also specify different Gateway Addresses and server names for a machine:

Host Jephe {hardware ethernet 00: a0: c9: a6: 96: 33; fixed-address 192.168.1.12; option routers 192.168.11.5 ;}

   4. In most cases, the DHCP installation does not create a dhcpd. leases file. Before you start the DHCP server, you must create an empty file dhcpd. leases:

# Touch/var/state/dhcp/dhcpd. leases

To start the DHCP server, simply enter/usr/sbin/dhcpd or use # ntsysv to automatically start the DHCP service. This will start the dhcpd on the eth0 device; if you want to start dhcpd on the eth1 device, #/usr/sbin/dhcpd eth1; if you want to debug DHCP, use #/usr/sbin/dhcpd-d-f.

   5. Two NICs:

Sometimes you need to install the DHCP service on a machine with two NICs (as a firewall or gateway). The following example shows a DHCP setting on a firewall machine, the DHCP Service is not required for external NICs (internet.

Therefore, the settings are as follows:

Subnet 192.168.1.0 netmask 255.255.255.0 {

Range 192.168.1.2 192.168.1.4;

Default-lease-time 86400;

Max-lease-time 259200;

Option subnet-mask limit 255.0;

Option broadcast-address 192.168.1.255;

Option routers 192.168.1.254;

Option domain-name-servers 192.168.1.254;

}

Subnet 202.102.34.102 netmask 255.255.255.255 {

}

   6. FAQs

A. Is the fixed IP address of the MAC machine?

If you do not know the IP address obtained by setting the DHCP function for the MAC server, you can send an email on the MAC server. The recipient can check the IP address of the sender through the mail header, then ping the IP address and use the arp command to check the physical address of the IP address in the arp cache.

B. If a windows machine is installed with software with a DHCP function, such as sygate and wingate, other windows customers may find windows DHCP servers first, rather than Linux DHCP servers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.