Search for a command to run...
This guide explains how to set up DHCP and DNS servers on a Debian-based system. We'll use isc-dhcp-server
for dynamic IP address assignment and bind9
for DNS resolution.
sudo apt update
sudo apt install isc-dhcp-server
Edit the main configuration file:
sudo nano /etc/dhcp/dhcpd.conf
Add the following configuration:
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.140 192.168.1.150;
option routers 192.168.1.254;
option domain-name-servers 192.168.1.100;
}
range
: the IP addresses the server can assign.routers
: the default gateway.domain-name-servers
: DNS server to use.Edit:
sudo nano /etc/default/isc-dhcp-server
Set the network interface (e.g., eth0
, wlan0
):
INTERFACESv4="wlan0"
sudo systemctl restart isc-dhcp-server
sudo apt install bind9 bind9utils bind9-doc -y
Edit:
sudo nano /etc/bind/named.conf.local
Add:
zone "0x3adomain.com" IN {
type master;
file "/etc/bind/db.0x3adomain.com";
};
Create the file:
sudo nano /etc/bind/db.0x3adomain.com
Example content:
$TTL 604800
@ IN SOA 0x3adomain.com. root.0x3adomain.com. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ; Negative Cache TTL
)
@ IN NS ns.0x3adomain.com.
@ IN A 192.168.1.100
ns IN A 192.168.1.100
sudo systemctl restart bind9
sudo systemctl restart systemd-resolved
Use dig
to test:
dig 0x3adomain.com
If there are errors, review the zone file and check the status of bind9
.
You’ve now configured a basic DHCP server for IP assignment and a DNS server for name resolution on Debian. This setup provides a solid base for managing a local network. You can explore advanced options like static leases, reverse zones, or DNSSEC as next steps.
Stay in the loop with my latest projects and insights! Follow me on Twitter to catch all the updates as they happen. Don't miss out on the journey – let's connect and explore the world of tech together. Click to follow now!