Skip to content

Instantly share code, notes, and snippets.

@CallMarl
Last active October 3, 2020 16:08
Show Gist options
  • Save CallMarl/323c6b39f38f754917abf0ee5ed55e0e to your computer and use it in GitHub Desktop.
Save CallMarl/323c6b39f38f754917abf0ee5ed55e0e to your computer and use it in GitHub Desktop.
Setup linux dhcp serveur (debian)
# Restart resyslog service to consider modification
local7.* /var/log/dhcpd.log
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to all supported networks...
# option domain-name "callmarl";
# option domain-name-servers dns1.callmarl
default-lease-time 600;
max-lease-time 7200;
# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
# eth1 interface
subnet 172.16.1.0 netmask 255.255.255.0 {
range 172.16.1.50 172.16.1.100;
# option definitions common to local subnet...
option domain-name "callmarl";
option domain-name-servers dns1.callmarl;
option subnet-mask 255.255.255.0;
option broadcast-address 172.16.1.254;
option routers 172.16.1.1;
}
# Hosts which require special configuration options can be listed in
# host statements. If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.
#host passacaglia {
# hardware ethernet 0:0:c0:5d:bd:95;
# filename "vmunix.passacaglia";
# server-name "toccata.example.com";
#}
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# Download paquage
apt-get update && apt-get upgrade -y
apt-get install isc-dhcp-server
# Create log file
touch /var/log/dhcpd.log
# Start service
service rsyslog restart
service isc-dhcp-server start
# Check service is running
service isc-dhcp-server status
netstat -unlp
# Extends firewall rules
iptables -t filter -A INPUT -i eth1 -p udp --dport 59 -j ACCEPT
iptables -t filter -A OUTPUT -o eth1 -p udp --sport 59 -j ACCEPT
# display current lease
dhcp-lease-list
# Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server)
# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
#DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
#DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf
# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPDv4_PID=/var/run/dhcpd.pid
#DHCPDv6_PID=/var/run/dhcpd6.pid
# Additional options to start dhcpd with.
# Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACESv4="eth1"
INTERFACESv6=""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment