Sunday, August 17, 2014

DHCP daemon in ubuntu

1. bind a static ip for the interface, for example eth1
in /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#allow-hotplug eth0
auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
address 169.254.1.2
netmask 255.255.255.0

2. install isc-dhcp-server
 apt-get install isc-dhcp-server

3. in /etc/default/isc-dhcp-server
  INTERFACES="eth1"

4. in /etc/dhcp/dhcpd.conf
 subnet 169.254.1.0 netmask 255.255.255.0 {
   range 169.254.1.3 169.254.1.254;
   option routers 169.254.1.2;
   option domain-name-servers 169.254.1.2;
 }

or

 subnet 169.254.1.0 netmask 255.255.255.0 {
   range 169.254.1.1 169.254.1.254;
   option routers 169.254.1.120;
   option domain-name-servers 169.254.1.120;
 }

5. restart the service by the following steps
 ifdown eth1
 ifup eth1
 killall dhclient

6. if the steps cannot work, just reboot.

Reference:
http://askubuntu.com/questions/4826/switching-a-server-to-static-ip-from-dhcp

No comments: