Dynamic Host
Configuration Protocol Daemon (DHCPD):
DHCP Dynamic Host Configuration Protocol allows
network settings configuration for all clients from a central dhcp
server. The dhcp clients request an IP address and other network
settings to all dhcp servers listening on the local LAN where the
client is connected. The dhcp server leases to the client one IP
address based on the client MAC or just from a IP range, then the
client accepts the configuration served by the dhcp server and notify
it to the dhcp server.
DHCP server
In order to configure a server as dhcp server, the dhcp
RPM package must be installed.
# yum install dhcp
The copy the sample configuration file from shared/doc to /etc/dhcpd/dhcpd.conf file.
# cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd/dhcpd.conf
Edit the sample config file with your LAN (192.168.1.0/24 in this case) network parameters configuration.
# cat /etc/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.110;
option domain-name-servers 192.168.1.1;
option domain-name "192.168.1.1";
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
default-lease-time 600;
max-lease-time 7200;
}
# Hosts which require special configuration options can be listed in
# host statements.
host fantasia {
hardware ethernet 08:00:07:26:c0:a5;
fixed-address 192.168.1.200;
}
From this file can be seen that the dhcp server will serve the network configuration for 192.168.1.0/24 LAN providing IPs from the range 192.168.1.100-192.168.1.110. It also will configure the DNS server 192.168.1.1 on /etc/resolv.conf and default gateway on 192.168.1.1 for all clients. It will also reserve the IP 192.168.1.200 to the node with MAC 08:00:07:26:c0:a5 and it will call it fantasia.
Once the dhcp server has been configured the next step is start the service and make sure that it will be started on boot. It will start the dhcp service on the port 67/UDP.
# /etc/init.d/dhcpd start
# chkconfig dhcpd on
# yum install dhcp
The copy the sample configuration file from shared/doc to /etc/dhcpd/dhcpd.conf file.
# cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd/dhcpd.conf
Edit the sample config file with your LAN (192.168.1.0/24 in this case) network parameters configuration.
# cat /etc/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.110;
option domain-name-servers 192.168.1.1;
option domain-name "192.168.1.1";
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
default-lease-time 600;
max-lease-time 7200;
}
# Hosts which require special configuration options can be listed in
# host statements.
host fantasia {
hardware ethernet 08:00:07:26:c0:a5;
fixed-address 192.168.1.200;
}
From this file can be seen that the dhcp server will serve the network configuration for 192.168.1.0/24 LAN providing IPs from the range 192.168.1.100-192.168.1.110. It also will configure the DNS server 192.168.1.1 on /etc/resolv.conf and default gateway on 192.168.1.1 for all clients. It will also reserve the IP 192.168.1.200 to the node with MAC 08:00:07:26:c0:a5 and it will call it fantasia.
Once the dhcp server has been configured the next step is start the service and make sure that it will be started on boot. It will start the dhcp service on the port 67/UDP.
# /etc/init.d/dhcpd start
# chkconfig dhcpd on
DHCP Security
In order to allow dhcp service through a firewall the
port 67/UDP must be open on the dhcp server.
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 67 -j ACCEPT
And the port 68/UDP must be open on the dhcp client.
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 68 -j ACCEPT
If SElinux is interfering on the dhcpd service on the server, the dhcpd service will be disabled from SElinux protection.
# setsebool -P dhcpd_disable_trans 1
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 67 -j ACCEPT
And the port 68/UDP must be open on the dhcp client.
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 68 -j ACCEPT
If SElinux is interfering on the dhcpd service on the server, the dhcpd service will be disabled from SElinux protection.
# setsebool -P dhcpd_disable_trans 1
DHCP Client
The dhcp client configuration can be configured at the
network device configuration file,
/etc/sysconfig/network-script/ifcfg-eth0 for eth0. The following
parameters must be used :
BOOTPROTO='dhcp'
The dhcp configuration for a network device as /dev/eth0 can be executed by hand with the dhclient command.
# dhclient eth0
In both cases using ifcfg-eth0 file or through 'dhclient' command the client node broadcast the LAN searching for dhcp configuration from a dhcp server.
BOOTPROTO='dhcp'
The dhcp configuration for a network device as /dev/eth0 can be executed by hand with the dhclient command.
# dhclient eth0
In both cases using ifcfg-eth0 file or through 'dhclient' command the client node broadcast the LAN searching for dhcp configuration from a dhcp server.
Features:
1. Auto-configuration of IP client(s)
2. Includes all sorts of settings:
IPv4, IPv6, DNS, NTP, NIS, etc.
3. DHCP is an UDP application (UDP:67)
Tasks:
1. Reconfigure 'eth1' to use: '/27'
a. 'vi
/etc/sysconfig/network-scripts/ifcfg-eth1' 'PREFIX=27'
2. Install DHCP
a. 'yum -y install dhcp'
b. 'rpm -ql dhcp'
/etc/dhcp - container for DHCPD
configuration
/etc/dhcp/dhcpd.conf - IPv4 config
/etc/dhcp/dhcpd6.conf - IPv6 config
/var/lib/dhcpd - container for leases
/var/lib/dhcpd/dhcpd.leases - IPv4
leases
/var/lib/dhcpd/dhcpd6.leases - IPv6
leases
3. Configure scope for:
'192.168.0.0/27' - facilitates 2**5 -2 hosts
192.168.0.0 - Network address
192.168.0.1-30 - Usable
192.168.0.31 - Broadcast Address
Note: Alter DHCPD to log using a
different facility: i.e. 'local6' because boot messages are logged
via: 'local7'
4. Start/Invoke 'eth1' interface on:
'hindux' server
Note: This will launch the 'dhclient'
process, which will request configuration via DHCP
a. 'ifup eth1'
INET ADDR=192.168.0.1
Bcast:192.168.0.31 Mask:255.255.255.224
'.224'= '/27'
'/24' = '.0'
'/25' = '.128'
'/26' = '.192'
'/27' = '.224'
5. Configure a reservation to ensure
that: 'hindux' is always served the same address
a. 'vi /etc/dhcp/dhcpd.conf'
Note: DHCPD follows the DORA process:
D - Discovery (Client)
O - Offer (Server)
R - Request (Client)
A - Acknowledment (Server)
No comments :
Post a Comment