I am not understand dhcp very well. The following is my experience about dhcp.
DHCP packet flow
Client -- send DHCP Discover
Server -- send DHCP Offer
Client -- send DHCP Request
Server -- send DHCP ACK
These four packets all contain the same Transaction ID
DHCP protocols use option to carry the main messages. These options include message type, server identifier, IP address lease time, renewal time value and rebinding time value etc..
dhcp running daemon
/sbin/dhclient -1 -q -lf /var/lib/dhcp/dhclient-eth0.leases -pf /var/run/dhclient-eth0.pid eth0
dhcp configuration file
/var/lib/dhcp/dhclient-eth0.leases
lease {
interface "eth0";
fixed-address 192.168.1.4;
option subnet-mask 255.255.255.0;
option routers 192.168.1.254;
option dhcp-lease-time 604800; ==> one week
option dhcp-message-type 5;
option domain-name-servers 168.95.1.1,140.113.1.1;
option dhcp-server-identifier 192.168.1.254;
option dhcp-renewal-time 302400;
option dhcp-rebinding-time 453600;
option domain-name "";
renew 0 2008/2/10 19:31:07;
rebind 3 2008/2/13 04:01:58;
expire 4 2008/2/14 22:01:58;
}
lease {
interface "eth0";
fixed-address 192.168.1.4;
option subnet-mask 255.255.255.0;
option routers 192.168.1.254;
option dhcp-lease-time 604800; ==> one week
option dhcp-message-type 5;
option domain-name-servers 168.95.1.1,140.113.1.1;
option dhcp-server-identifier 192.168.1.254;
option dhcp-renewal-time 302400;
option dhcp-rebinding-time 453600;
option domain-name "";
renew 3 2008/2/13 21:31:39;
rebind 6 2008/2/16 01:31:07;
expire 0 2008/2/17 19:31:07;
}
lease {
interface "eth0";
fixed-address 192.168.1.4;
option subnet-mask 255.255.255.0;
option routers 192.168.1.254;
option dhcp-lease-time 604800;
option dhcp-message-type 5;
option domain-name-servers 168.95.1.1,140.113.1.1;
option dhcp-server-identifier 192.168.1.254;
option dhcp-renewal-time 302400;
option dhcp-rebinding-time 453600;
option domain-name "";
renew 6 2008/2/16 17:36:07;
rebind 2 2008/2/19 03:31:39;
expire 3 2008/2/20 21:31:39;
}
lease {
interface "eth0";
fixed-address 192.168.1.4;
option subnet-mask 255.255.255.0;
option routers 192.168.1.254;
option dhcp-lease-time 604800;
option dhcp-message-type 5;
option domain-name-servers 168.95.1.1,140.113.1.1;
option dhcp-server-identifier 192.168.1.254;
option dhcp-renewal-time 302400;
option dhcp-rebinding-time 453600;
option domain-name "";
renew 1 2008/3/10 17:58:49;
rebind 3 2008/3/12 12:55:15;
expire 5 2008/3/14 06:55:15;
}
lease {
interface "eth0";
fixed-address 192.168.1.101;
option subnet-mask 255.255.255.0;
option routers 192.168.1.254;
option dhcp-lease-time 86400;
option dhcp-message-type 5;
option domain-name-servers 192.168.1.254;
option dhcp-server-identifier 192.168.1.254;
renew 2 2008/3/11 03:37:46;
rebind 2 2008/3/11 14:58:50;
expire 2 2008/3/11 17:58:50;
}
lease {
interface "eth0";
fixed-address 192.168.1.2;
option subnet-mask 255.255.255.0;
option routers 192.168.1.254;
option dhcp-lease-time 86400;
option dhcp-message-type 5;
option domain-name-servers 192.168.1.254;
option dhcp-server-identifier 192.168.1.254;
renew 2 2008/3/11 15:28:19;
rebind 3 2008/3/12 00:37:47;
expire 3 2008/3/12 03:37:47;
}
# if you want dhcpd to listen only on the specific interface, add the interface parameter in the dhcpd config file, as following steps
a. update /etc/sysconfig/dhcpd, add " eth1" as the listening interface
DHCPDARGS=" eth1"
b. restart the dhcpd
# service dhcpd restart
c. verify that dhcpd is launched with the " eth1" as the parameter
# ps auxwww | grep dhcpd
root 3848 0.0 0.1 6208 1212 ? Ss 14:51 0:00 /usr/sbin/dhcpd eth1
### Setup the dhcp config
And we config the /etc/dhcpd.conf to include the following options to comply the AutoIP testing item requirement of DLNA Test Plan.
# --- default gateway
# option routers 192.168.0.1; << comment out the default router of DHCP advertisement to avoid the client receiver to set the default router in the LAN network
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.1.1;
option time-offset -18000; # Eastern Standard Time
range dynamic-bootp 192.168.0.10 192.168.0.100;
default-lease-time 300; << Set lease time as 300 seconds to conform the certification testing requirement
max-lease-time 43200;
Besides, we need to setup the server address of binding network interface in the same network domain as the assigned dhcp address. In our example, we set the server network address as 192.168.0.1 and netmask as 255.255.255.0.
### Start up the DHCP Server
Start the DHCP server
# service dhcpd start
Starting dhcpd: [ OK ]
Show the DHCP server current status
# service dhcpd status
dhcpd (pid 11185) is running...
# netstat -anp | grep 67 | grep dhcpd
udp 0 0 0.0.0.0:67 0.0.0.0:* 11185/dhcpd
Stop the DHCP server
# service dhcpd stop
Shutting down dhcpd: [ OK ]
沒有留言:
張貼留言