by summers » Fri Apr 05, 2019 9:47 am
Obvious problem is that you'll what to run dhcp as a *server* on the RPiZ; you have set it up as a client.
You'll also need to make sure you set up routing correctly on whatever connects to the WAN. That takes some though, e.g. if the WAN doesn't know *all* addresses inside the LAN, you'll need to set up a masquerade, either via ip tables or nf tables.
What will help is logging directly on the RPiZ so you can see what has come up. Attaching via the UART is the obvious direction. As much as anything debugging is far easier when you can see what is happening .... your friends are $this->bbcode_second_pass_code('', 'ip a
ip route')
As an example, what I do on my pocket beagle, where I use the libcomposite/systemd network set up is:
/etc/systemd/network/usb0.network
$this->bbcode_second_pass_code('', '[Match]
Name=usb0
[Network]
DNS=192.168.2.1
IPv6PrivacyExtensions=true
[Address]
Address=192.168.7.18/30
[Route]
Gateway=192.168.7.17')
So I bring up the usb ethernet with an ip address, and also with the knowledge of where the gateway to the WAN is and also my DNS server (192.168.2.1 is my ADSL router ...)
dhcpd is running:
$this->bbcode_second_pass_code('', '[summers@pocketbeagle ~]$ systemctl status dhcpd4@usb0
* dhcpd4@usb0.service - IPv4 DHCP server on usb0
Loaded: loaded (/etc/systemd/system/dhcpd4@.service; enabled; vendor preset:>
Active: active (running) since Thu 2019-02-21 13:46:27 UTC; 1 months 12 days>
Process: 1697 ExecStart=/usr/bin/dhcpd -4 -q -pf /run/dhcpd4.pid usb0 (code=e>
Main PID: 1702 (dhcpd)
Tasks: 1 (limit: 1041)
Memory: 4.9M
CGroup: /system.slice/system-dhcpd4.slice/dhcpd4@usb0.service
`-1702 /usr/bin/dhcpd -4 -q -pf /run/dhcpd4.pid usb0
')
dhcpd is configured
$this->bbcode_second_pass_code('', '[summers@pocketbeagle ~]$ more /etc/dhcpd.conf
subnet 192.168.7.16 netmask 255.255.255.252 {
range 192.168.7.17 192.168.7.17;
}
')
Checking all these is far easier if you can log onto the RPiZ ....
Oh yes 192.168.7.17 has an interesting route
$this->bbcode_second_pass_code('', '[summers@nas ~]$ ip route
default via 192.168.2.1 dev eth0 proto dhcp src 192.168.2.111 metric 1024
192.168.2.0/24 dev eth0 proto kernel scope link src 192.168.2.111
192.168.2.1 dev eth0 proto dhcp scope link src 192.168.2.111 metric 1024
192.168.7.0/30 dev usb0 proto kernel scope link src 192.168.7.1
192.168.7.16/30 dev usb1 proto dhcp scope link src 192.168.7.17 metric 205
')
And that machine also has nftables running
$this->bbcode_second_pass_code('', '[summers@nas ~]$ sudo nft list ruleset
table ip nat {
chain prerouting {
type nat hook prerouting priority 0; policy accept;
}
chain postrouting {
type nat hook postrouting priority 100; policy accept;
masquerade
}
}
table inet filter {
chain input {
type filter hook input priority 0; policy accept;
ct state { established, related } accept
ct state invalid drop
iifname "lo" accept
ip protocol icmp accept
ip6 nexthdr ipv6-icmp accept
tcp dport ssh accept
meta nfproto ipv4 reject
}
chain forward {
type filter hook forward priority 0; policy accept;
}
chain output {
type filter hook output priority 0; policy accept;
}
}
')
And to make routing on the LAN easier, the DNS server 192.168.2.1 has:
$this->bbcode_second_pass_code('', 'root@DavidSummers:~# ip route
default via 195.166.130.251 dev pppoa-wan
192.168.2.0/24 dev br-lan scope link src 192.168.2.1
192.168.7.0/24 via 192.168.2.111 dev br-lan
195.166.130.251 dev pppoa-wan scope link src 84.93.181.88
')
So it knows that 192.168.7.0/24 lives on 192.168.2.111 which is the LAN name of 192.168.7.17 (e.g. that machine has a shed load of ethernet, all with different addresses ....)