DHCP service configuration in Linux

Source: Internet
Author: User
We all know that using DHCP to dynamically allocate IP addresses can reflect the ease of use, especially when there are many hosts in the LAN, it is a good choice to configure the DHCP server. In this article, we will implement the following DHCP goals: (1) Basic settings of scope (2) settings of host binding (3) Super scope settings (4) Server

We all know that using DHCP to dynamically allocate IP addresses can reflect the ease of use, especially when there are many hosts in the LAN, it is a good choice to configure the DHCP server. In this article, we will introduce the following DHCP targets:

(1) Basic settings of the Scope

(2) host binding settings

(3) Super scope settings

(4) settings of server options

(5) assign IP addresses by client type

[Configure the environment]

REdWhat is Hat Enterprise Linux 5.3?

[DHCP server settings]

1. Software Package:

DhCp-3.0.5-18. el5.i386. rpm

2. installation:

# Rpm-ivh dhcp-3.0.5-18.el5.i386.rpm

3. Configure the master configuration file/etc/dhcpd. conf.

(1) # vim/etc/dhcpd. conf

For ease of editing, read the content in/usr/share/doc/dhcp-3.0.5/dhcpd. conf. sample to dhcpd. conf,

----------------------------------------------------------

You can also copy dhcpd. conf. sample to dhcpd. conf.

# Cp/usr/share/doc/dhcpd-3.0.5/dhcpd. conf. sample dhcpd. conf

Where:

DdNs-upDate-Style interim; // configure the update mode using a transitional DHCP-DNS interactive

Ignore client-updates; // ignore client updates

SuBnet 192.168.0.0 netmask 255.255.255.0 {// assign an address for the 192.168.0.0 Subnet

Option routers 192.168.0.1; // specify the default gateway for the client

Option subnet-mask subnet mask 255.255.0; // specify the subnet mask for the client

Option nis-domain "domain.org"; // assign an NIS domain to the client

Option domain-name "domain.org"; // assign a DNS domain to the client

Option domain-name-servers 192.168.1.1; // assigned DNS address

Range dynamic-bootp 192.168.0.128 192.168.0.254; // address pool

Default-lease-Time21600; // default lease time (seconds)

Max-lease-time 43200; // maximum lease time (seconds)

}

Note: 1) No matter whether you create one or more scopes, you must declare that one scope is the subnet address of the IP address of the DHCP server after subnet, otherwise, DHCP cannot be started. For example, if the IP address of the DHCP server is 192.168.1.1/24, it must have the following scope:

Subnet 192.168.1.0 mask 255.255.255.0 {

}

2) if multiple DNS servers exist, separate them with commas (,) to list them one by one, as shown in figure

Option domain-name-servers 192.168.1.1, 192.168.1.2;

3) if the addresses allocated to a CIDR block are not consecutive, we only need to create multiple address pool records, such:

Range dynamic-bootp 192.168.1.1 192.168.1.40;

Range dynamic-bootp 192.168.1.61 192.168.1.254;

In this case, you can assign an address in the network segment 192.168.1.0 except for the range 192.168.1.41-192.168.1.60.

(2) host binding

For some clients, we always hope that the IP addresses they obtain are fixed each time. In this case, you can bind the hosts,

Host ns {

NExT-server marvin.RedHat.com; // you can specify the host name that is mounted to the server from the boot file and used for diskless workstation.

Hardware ethernet 12: 34: 56: 78: AB: CD; // the MAC address of the DHCP client to bind

Fixed-address 207.175.42.254; // the IP address to be fixed to the DHCP Client

}

(3) Super Scope

Super scopes are mainly used to allocate addresses to clients of different network segments. When configuring super scopes, you only need to place Multiple scopes in the shared-network. The format is as follows:

Shared-network name {

Subnet address netmask subnet mask {};

Subnet address netmask subnet mask {};

......

}

(4) server options

If dhcp has multiple scopes and each scope has some identical configurations, we can reduce the configuration workload and put the same configurations out of the Super scope. For example:

Shared-network name {};

Default-lease-time 21600;

Max-lease-time 43200;

In this way, the same lease will be set for hosts of different scopes.

(5) assign IP addresses by client type

Classifies the client according to a certain attribute and assigns addresses of different ranges based on different attribute classes, for example:

Subnet 192.168.10.0 network 255.255.255.0 {

Class "vm "{

Match if subsTrIng (hardware, 1, 3) = 00: 0c: 29

} // Match the VM class according to the MAC Definition

Pool {

Allow members of "vm ";

Range 192.168.10.10 192.168.10.50;

} // Assign IP addresses to clients matching "vm"

Pool {

Deny members of "vm ";

Range 192.168.10.100 192.168.10.110;

}

} // Assign IP addresses to clients that do not match "vm"

4. syntax check

# Service dhcpd configtest

5. Start the DHCP service.

# Service dhcpd start

[DHCP Client configuration]

Configure Nic parameters in Linux

# Vim/etc/sysconfig/network-scripts/ifcfg-eth [0-n]

DEVICE = eth [0-n]

BOOTPROTO = dhcp

ONBOOT = yes

Restart Nic

# Service network restart

To exclude DNS information from the IP address obtained by the DHCP client, you can add the following statement in ifcfg-eth [0-n:

PEERDNS = no

Related Article

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.