SYNOPSYS

eth0 and eth1 are configured by DHCP.
eth0 is the access to the outside world, eth1 is connected to local LAN.

PROCEDURE

in a usual configuration, you

ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

but in this case we are going to use pdnsd,
so /etc/resolv.conf is a regular file with 1 line :

nameserver=127.0.0.1

We configure 2 servers in pdnsd

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
server {
	label= "outside";
	ip = 192.168.1.1;
	policy=included;
	exclude=.local;
}

server {
	label= "lan";
	ip = 172.16.1.1;
	policy=excluded;
	include=.local;
}

/etc/systemd/network/eth0.network

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
[Match]
Name=eth0

[Network]
DHCP=ipv4
IPv6AcceptRA=no
LinkLocalAddressing=ipv4

[DHCPv4]
UseDNS=no

/etc/systemd/network/eth1.network

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
[Match]
Name=eth1

[Network]
DHCP=ipv4
IPv6AcceptRA=no
LinkLocalAddressing=ipv4

[DHCP]
UseDNS=no
UseRoutes=false

[Route]
Gateway=172.16.1.1
Destination=172.16.2.0/24

route -n

1
2
3
4
5
6
7
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    1024   0        0 eth0
172.16.2.0      172.16.1.1      255.255.255.0   UG    0      0        0 eth1
172.16.1.0      0.0.0.0         255.255.255.0   U     1024   0        0 eth1
192.168.1.0     0.0.0.0         255.255.255.0   U     1024   0        0 eth0
192.168.1.1     0.0.0.0         255.255.255.255 UH    1024   0        0 eth0