Difference between revisions of "DHCP static IP assignation"

(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...")
 
Line 1: Line 1:
 
[[Category:Linux]]
 
[[Category:Linux]]
  
 +
=Global configuration=
  
=Access configuration file=
+
 
 +
==Access configuration file==
  
 
The main configuration file is '''/etc/dhcp/dhcpd.conf'''
 
The main configuration file is '''/etc/dhcp/dhcpd.conf'''
Line 12: Line 14:
  
  
 
+
==Static IP @==
=Static IP @=
 
  
 
This new configuration will ONLY accept known clients and give them a static IP @.
 
This new configuration will ONLY accept known clients and give them a static IP @.
Line 52: Line 53:
 
* MAC @
 
* MAC @
 
* Set a specific static IP @
 
* Set a specific static IP @
 
  
  
Line 59: Line 59:
 
=Add new host=
 
=Add new host=
  
 
+
==Configuration file==
Every time you need to install you host you have to:
 
  
 
Edit the configuration file:
 
Edit the configuration file:
Line 68: Line 67:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
 +
 +
==Declare new host==
  
 
Add new host at the end of the file :
 
Add new host at the end of the file :
Line 83: Line 85:
  
  
 +
==Take on changes==
  
 
Restart the DHCP server :
 
Restart the DHCP server :

Revision as of 22:18, 8 August 2014


Global configuration

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

Configuration file

Edit the configuration file:

vim /etc/dhcp/dhcpd.conf


Declare new host

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 !


Take on changes

Restart the DHCP server :

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