In order to set up routes, you'll need to set up dhcpd
, which will assign local IP addresses, as well as push routes.
In order to resolve hostnames, you need a DNS server, which BIND9 does a great job handling.
The following uses domain.tld as the domain being used, and 10.1.0.1 as the GATEWAY/ROUTER's IP. Also, somename is used to represent a client to your network.
/etc/dhcp/dhcpd.conf
# Zone Set Up
zone domain.tld {
primary 10.1.0.1;
}
# Additional Information
ddns-domainname "domain.tld";
ddns-rev-domainname "in-addr.arpa.";
option domain-name "domain.tld";
option domain-name-servers 10.1.0.1;
option broadcast-address 10.1.0.255;
# Routes
option classless-static-routes
0, 0,0,0,0,
0, 10,1,0,1,
24, 10,1,0, 10,1,0,1;
# Push Routes to Clients
subnet 10.1.0.0 netmask 255.255.255.0 {
range 10.1.0.100 10.1.0.254;
option routers 10.1.0.1;
zone 0.1.10.in-addr.arpa. {
primary 10.1.0.1;
}
zone domain.tld. {
primary 10.1.0.1;
}
}
The above assumes that your GATEWAY/ROUTER will be 10.1.0.1. You will need to select which 'domain.tld' you'd like to use. This will cause all routes to go to the gateway, 10.1.0.1.
This is also where you could specify IP addresses using the client's MAC address. This gives you DHCP, with psuedo-static IPs.
host somename {
hardware ethernet 60:XX:4c:XX:8a:XX;
fixed-address 10.1.0.100;
}
/var/lib/bind/db.0.1.10
$TTL 86400 ; 24 hours could have been written as 24h or 1d
;$ORIGIN 0.1.10.in-addr.arpa.
@ 1D IN SOA domain.tld. admin.domain.tld. (
2002022401 ; serial
3H ; refresh
15 ; retry
1w ; expire
3h ; minimum
)
; server host definitions
@ IN NS domain.tld.
1 IN PTR domain.tld.
100 IN PTR somename.domain.tld
This says "admin@domain.tld is the contact for these IPs and 10.1.0.1 is 'domain.tld'". You could add other IPs pointing to other subdomains.
125 IN PTR sub.domain.tld.
Adding this would tell reverse lookups that 10.1.0.125 is sub.domain.tld.
/var/lib/bind/db.domain.tld
$ORIGIN .
$TTL 604800 ; 1 week
domain.tld IN SOA domain.tld. admin.domain.tld. (
205 ; serial
604800 ; refresh (1 week)
86400 ; retry (1 day)
2419200 ; expire (4 weeks)
604800 ; minimum (1 week)
)
NS 10.1.0.1.
A 10.1.0.1
router A 10.1.0.1
somename A 10.1.0.100
* CNAME domain.tld.
This says "admin@domain.tld is the contact for these domains and 'domain.tld' is 10.1.0.1". You could add other domains, and even subdomains, pointing to other devices/ips.
router.domain.tld will resolve to 10.1.0.1. This also redirects (CNAMES) any not-mentioned subdomain (whatever.domain.tld) to domain.tld.
/etc/bind/named.conf.local
This file will tell bind
to load the previous db files we've created.
zone "domain.tld" {
type master;
file "/var/lib/bind/db.domain.tld";
};
zone "0.1.10.in-addr.arpa" {
type master;
file "/var/lib/bind/db.0.1.10";
};
Notes
There are plenty of tutorials on how to 'set up a gateway on Debian'.