Linux DHCPServer
1.1.installationDhcp
Yum Install dhcp*-y
1.2.Dhcpconfiguration file
[Email protected] ~]# ls/etc/dhcp/
DHCLIENT.D dhcpd6.conf dhcpd.conf
[Email protected] ~]# vi/etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see/usr/share/doc/dhcp*/dhcpd.conf.sample # template file
# See ' Mans 5 dhcpd.conf '
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to allsupported networks ...
optiondomain-name "example.org"; # Configure the domain name of the work
optiondomain-name-servers 202.96.128.86,202.96.134.133; # Configure multiple DNS servers separated by commas
default-lease-time600; # Lease time of ten seconds
max-lease-time7200; # 2H minutes
# Use this to enble/disable dynamic dnsupdates globally.
#ddns-update-style None;
# If This DHCP server was the official dhcpserver for the local
# Network, the authoritative directiveshould be uncommented.
#authoritative;
# Use this to send DHCP log messages to adifferent log file (you also
# has to hack syslog.conf to complete the redirection).
Log-facility Local7; # Log Level
# No Service would be given on this subnet,but declaring it helps the
# DHCP Server to understand the networktopology.
# Specify a network number, a subnet mask, and a range assignment in curly braces .
# multiple segments can write multiple lines
# This is a very basic subnet declaration.
subnet192.168.1.0 netmask 255.255.255.0
{
Range 192.168.1.100 192.168.1.200;
Option Domain-name-servers 192.168.1.10; #
Option Domain-name "hdbattery.cn";
option routers 192.168.1.1; # Gateway
option broadcast-address 192.168.1.255; # broadcast address
Default-lease-time 600;
Max-lease-time 7200;
}
# The following configuration is for fixed allocation of MAC binding
Hostfantasia
{
Hardware Ethernet 08:00:07:26:C0:A5;
Fixed-address 192.168.1.100;
}
# You can declare a class of clients andthen do address allocation
# based on that. The example below shows a case where allclients
# in a certain class get addresses on the10.17.224/24 subnet, and all
# Other clients get addresses on THE10.0.29/24 subnet.
Class "Foo" {
Match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
}
Shared-network 224-29 {
Subnet 10.17.224.0 netmask 255.255.255.0 {
option routers rtr-224.example.org;
}
Subnet 10.0.29.0 netmask 255.255.255.0 {
option routers rtr-29.example.org;
}
Pool {
Allow members of "Foo";
Range 10.17.224.10 10.17.224.250;
}
Pool {
Deny members of "Foo";
Range 10.0.29.10 10.0.29.230;
}
}
To test the configuration file syntax:
Service DHCPD Configtest
# Test if the DHCP syntax is normal
Service DHCPD Restart
# reboot after configuration
########################## Simple configuration file ################################
Ddns-update-styleinterim;
Ignoreclient-updates;
next-server192.168.1.11;
FileName "pxelinux.0";
allowbooting;
ALLOWBOOTP;
subnet192.168.0.0 netmask 255.255.255.0 {
Optionrouters 192.168.0.1
Optionsubnet-mask 255.255.255.0;
Optiondomain-name-servers 8.8.8.8,114.114.114.114;
Range DYNAMIC-BOOTP 192.168.0.100 192.168.0.200;
Hostns {
Hardware Ethernet 00:12:a0:2d:81;
Fixed-address 192.168.0.101;
}
}
##################################################################################### #3
1.3.Services and Ports
DHCP Port:67 68
1.4.Firewall Configuration
turn on the firewall Dhcp
Iptable-i INPUT 1-p TCP--dport 67-jaccept
Iptable-i INPUT 1-p UDP--dport 67-jaccept
Iptable-i INPUT 1-p TCP--dport 68-jaccept
Iptable-i INPUT 1-p UDP--dport 68-jaccept
1.5.ViewDhcpAssigning distribution Information
Cd/var/lib/dhcpd
Cat dhcpd.leases
1.6.Client-sideDhcpGet information
cd/var/lib/dhclient/
Cat dhclient.leases
1.7.whenDhcpwhen a server is multi-interface, a specific interface is limitedDhcpService
Vi/etc/sysconfig/dhcpd
# Command Line Options here
Dhcpdargs= ' eth0 ' # Specify interface
1.8.Remote boot
Ether-wake-i eth0 00:11:22:33:44:55
1.9.Step Essence¡ï ★
1.10.Fault Error:
1: Permissions issues?
650) this.width=650; "Width=" 681 "height=" 378 "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd; "alt=" Spacer.gif "/>
[[Email protected]]# VI/ETC/RC.D/INIT.D/DHCPD
User=root
Group=root
2. Interface Issues
Not configured Tolisten on any interfaces!
1. Configuring a fixed IP address
2. Check if hsot ns {} in dhcpd.cnf is bound
3.vi/etc/sysconfig/dhcpd
This article is from the Linux Technical Exchange blog, so be sure to keep this source http://zhongliang.blog.51cto.com/4507905/1878840
Linux DHCP server