Thursday, November 25, 2010

How to setup DHCP client on Debian

The Dynamic Host Configuration Protocol (DHCP) is an auto configuration protocol used on IP networks. Before we proceed let assume the hostname we are going to setup is deby01.dev.local.
  1. Configure hostname:
    echo "deby01" > /etc/hostname
    
  2. Ensure hosts file properly resolves localhost:
    127.0.0.1       localhost
    # In some circumstance it is not recommended to
    # resolve machine name to local ip address
    #127.0.1.1      deby01.dev.local  deby01
    
  3. Here is content of /etc/network/interfaces
    # The primary network interface
    allow-hotplug eth0
    iface eth0 inet dhcp
    
    # If you experience issues with obtaining
    # default gateway consider uncomment lines below.
    #       up route add default gw 192.168.10.1
    #       down route del default gw 192.168.10.1
    
  4. Let your dhcp client publish our name (so it can be resolved by name). Ensure the following in file /etc/dhcp/dhcpclient.conf:
    send host-name "deby01";
    
  5. If you experience issues with DNS you can set them manually (file /etc/dhcp/dhcpclient.conf)
    prepend domain-name-servers 8.8.8.8, 8.8.4.4;
    
  6. Reboot in order to changes take effect or issue the following commands:
    ifdown eth0 && ifup eth0
    
  7. Check your dynamically obtained ip address:
    deby01:~# ifconfig eth0 | grep inet
     inet addr:192.168.10.41 ...
    
If you need to setup a static ip address, take a look here.

No comments :

Post a Comment