Tuesday, October 04, 2011

linux: setup dhcp server

1. install dhcp rpm

2. add route for 255.255.255.255 (*for picky dhcp clients to work)
# route add -host 255.255.255.255 dev eth0

3. edit your configuration file /etc/dhcp.conf
this is what my dhcp.conf looks like:
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
#ddns-update-style interim;
ddns-update-style none;
#ignore client-updates;

authoritative;

# --- set lease time
default-lease-time 21600;
max-lease-time 43200;

subnet 192.168.0.0 netmask 255.255.255.0 {

# --- set ip range (with mac filter below)
#range dynamic-bootp 192.168.0.83 192.168.0.100;

# --- dont forward dhcp requests
#option ip-forwarding off;

# --- network setup
option broadcast-address 192.168.0.255;
option subnet-mask 255.255.255.0;
option domain-name "linus.ph";

# --- mac filter
class "allowedmac" {
match if (
(substring(hardware,1,6) = x:x:x:x:x:x)
or (substring(hardware,1,6) = y:y:y:y:y:y)
);
}

# --- ip range for mac filter
pool {
range 192.168.0.83 192.168.0.100;
allow members of "allowedmac" ;
# --- setup default gateway and dns
option routers 192.168.0.254;
option domain-name-servers 8.8.8.8,8.8.4.4;
}
}


4. invoke dhcp server
# dhcpd eth0

or to invoke in debug mode
# dhcpd -d -f

* sources
http://tldp.org/HOWTO/DHCP/x369.html
http://www.linuxquestions.org/questions/linux-server-73/dhcp-with-mac-filter-641850/

No comments:

Post a Comment

SSH : No matching host key type found. Their offer: ssh-rsa,ssh-dss

Got this while connecting to my mikrotik router via ssh   Unable to negotiate with <ip address> port <ssh port>: no matching hos...