DHCP static IP assignation

Revision as of 22:17, 8 August 2014 by WikiFreak (talk | contribs) (Created page with "Category:Linux =Access configuration file= The main configuration file is '''/etc/dhcp/dhcpd.conf''' <syntaxhighlight lang="bash"> vim /etc/dhcp/dhcpd.conf </syntaxhig...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Access configuration file

The main configuration file is /etc/dhcp/dhcpd.conf

vim /etc/dhcp/dhcpd.conf



Static IP @

This new configuration will ONLY accept known clients and give them a static IP @.

# Sample /etc/dhcpd.conf
# (add your comments here) 
default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 172.16.50.255;
option routers 172.16.50.254;
option domain-name-servers 172.16.50.2, 8.8.8.8;
option domain-name "mydomain.lan";
option ntp-servers 172.16.50.254;

deny unknown-clients;

subnet 172.16.50.0 netmask 255.255.255.0 {
    host client1 {
        hardware ethernet DD:GH:DF:E5:F7:D7;
        fixed-address 172.16.50.20;
    }
    host client2 {
        hardware ethernet 00:JJ:YU:38:AC:45;
        fixed-address 172.16.50.21;
    }
}

Note:

The deny unknown-clients; command is why only known clients are accepted.


For each client you have to adjust:

  • MAC @
  • Set a specific static IP @



Add new host

Every time you need to install you host you have to:

Edit the configuration file:

vim /etc/dhcp/dhcpd.conf


Add new host at the end of the file :

host myNewHost {
  hardware ethernet 00:0e:af:31:d1:cc;
  fixed-address 172.16.50.60;
  option host-name "myNewHost";
}

==> Don't forget to the given IP @ must match the DNS server declaration !



Restart the DHCP server :

/etc/init.d/isc-dhcp-server restart