1

Pulling my hair for days here setting up DNS and DHCP with dnsmasq and the new way of doing things with netplan.

WAN-router is on 192.168.0.1 - works fine

LAN-router (Ubuntu 18.04) received 192.168.0.205 on enp1s0 and is serving addresses on enp2s0; 192.168.1.1 - DHCP works fine, handing out 192.168.1.x addresses as it should. Can ping google.com

Client laptop is on 192.168.1.181 - Gets IP, can ping LAN-router, can ping IP addresses directly (such as 8.8.8.8) but traceroute and DNS does not work

This is my dnsmasq config:

bogus-priv
strict-order
filterwin2k
expand-hosts
domain=home
no-resolv
listen-address=127.0.0.1
listen-address=192.168.1.1
#DHCP range
dhcp-range=192.168.1.1,192.168.1.254,72h
dhcp-option=option:router,192.168.0.1

# Upstream name servers
server=192.168.0.1
server=8.8.4.4
server=8.8.8.8

Status of dnsmasq, boots fine:

Nov 15 06:54:17 router systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
Nov 15 06:54:17 router dnsmasq[2000]: dnsmasq: syntax check OK.
Nov 15 06:54:17 router dnsmasq[2030]: started, version 2.79 cachesize 150
Nov 15 06:54:17 router dnsmasq[2030]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify
Nov 15 06:54:17 router dnsmasq-dhcp[2030]: DHCP, IP range 192.168.1.1 -- 192.168.1.254, lease time 3d
Nov 15 06:54:17 router dnsmasq[2030]: using nameserver 8.8.8.8#53
Nov 15 06:54:17 router dnsmasq[2030]: using nameserver 8.8.4.4#53
Nov 15 06:54:17 router dnsmasq[2030]: using nameserver 192.168.0.1#53
Nov 15 06:54:17 router dnsmasq[2030]: read /etc/hosts - 7 addresses
Nov 15 06:54:17 router systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.

ip address show:

2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:e8:4c:68:61:52 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.205/24 brd 192.168.0.255 scope global dynamic enp1s0
       valid_lft 1962sec preferred_lft 1962sec
    inet6 fe80::2e8:4cff:fe68:6152/64 scope link
       valid_lft forever preferred_lft forever
3: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:e8:4c:68:61:53 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.1/24 brd 192.168.1.255 scope global enp2s0
       valid_lft forever preferred_lft forever
    inet6 fe80::2e8:4cff:fe68:6153/64 scope link
       valid_lft forever preferred_lft forever

netplan-yaml:

network:
    renderer: networkd
    ethernets:
        enp1s0:
            addresses: []
            dhcp4: true
        enp2s0:
            addresses: [192.168.1.1/24]
            gateway4: 192.168.0.1
            dhcp4: false
            nameservers:
              search: [home]
              addresses: [192.168.0.1,8.8.8.8,8.8.4.4]
    version: 2

I'm sure I've confused it along the way. I was able to DNS resolve for names from the client laptop for a while, but no actual data transport was possible, so wasn't possible to actually reach the internet practically.

It's all a bit new to me so would appreciate any pointers.

edit--

Topology - updated:

Client (192.168.1.2) -> Unifi AP (192.168.1.71) -> Lan-Router [192.168.1.1 -> 192.168.0.205] -> WAN-router (192.168.0.1) -> Internet

As I learned more about Netplan vs dnsmasq vs routing/networking in general I understood that in the Netplan config I was supposed to have only one gateway defined. I figured that gateway needs to be the one showing the way out and updated the configuration as such, see below:

network:
    renderer: networkd
    ethernets:
        enp1s0:
            addresses: [192.168.0.205/24]
            dhcp4: true
            gateway4: 192.168.0.1
        enp2s0:
            addresses: [192.168.1.1/24]
            dhcp4: false
            nameservers:
              search: [home]
              addresses: [192.168.0.1,8.8.8.8,8.8.4.4]
    version: 2

This worked, for a while. I could even resolve "router:xxxx" in the browser of the client.

Then, with no change made to Lan-Router, it stopped working. This happened maybe 30-60 minutes after it started working.

Ping on Client resolves the DNS but can't receive any packets, indicating some routing issue:

PING google.com (172.217.20.78): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
^C
--- google.com ping statistics ---
3 packets transmitted, 0 packets received, 100.0% packet loss

Traceroute on Client doesn't come further than LAN-Router:

traceroute to google.com (172.217.20.78), 64 hops max, 52 byte packets
 1  * router (192.168.1.1)  1.391 ms  2.486 ms
 2  *^C

Ip route on Lan-Router:

default via 192.168.0.1 dev enp1s0 proto static
default via 192.168.0.1 dev enp1s0 proto dhcp src 192.168.0.205 metric 100
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
192.168.0.0/24 dev enp1s0 proto kernel scope link src 192.168.0.205
192.168.0.1 dev enp1s0 proto dhcp scope link src 192.168.0.205 metric 100
192.168.1.0/24 dev enp2s0 proto kernel scope link src 192.168.1.1

route -n on LAN-Router:

0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 enp1s0
0.0.0.0         192.168.0.1     0.0.0.0         UG    100    0        0 enp1s0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 enp1s0
192.168.0.1     0.0.0.0         255.255.255.255 UH    100    0        0 enp1s0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 enp2s0

There might have been a restart in that timeframe but I don't remember that being specifically what caused the drop.

Any pointers as to how to troubleshoot would be appreciated.

edit

Solved it - for now. It was a routing statement missing (must have been after reboot)

I added this: phil@router:~$ sudo iptables -t nat -A POSTROUTING -o enp1s0 -j MASQUERADE

And Client got internet. I'll make this forwarding rule permanent next. Most likely it'll be fine from now on.... let's see!

  • 1
    Glad you were able to find the issue and fix it. – Lewis M Nov 16 '18 at 14:45
3

Based on your problem statement, you have something like this, yes?

Client         <--->    LAN-Router   <--->     WAN-Router  <---> Internet
192.168.1.181   192.168.1.1    192.168.0.205   192.168.0.1

The client's gateway IP is configured to 192.168.0.1, which is the IP of the WAN Router. How does the client know how to get to 192.168.0.1?

Remember, gateway addresses are defined as letting a computer know how to send traffic to the next computer or router, the next hop. If needs to be some address the client can get to, typically on the same subnet as the client. So, if you change your client's gateway to 192.168.1.1, you should be good.

Hope this helps.

  • Thanks for your reply. I need to verify that the client's gateway indeed is 192.168.0.1. If it is, Is it possible to at connection time coerce the client into using 192.168.1.1 as gateway? – Phil Nov 15 '18 at 14:47
  • I see now. The "option:router" specifies the default gateway for the client, yeah? I'll change that tonight, thanks for the heads up :) – Phil Nov 15 '18 at 14:53
  • I changed the client gateway to 192.168.1.1 but to no avail. Good catch though, I'm sure that was one step in the right direction – Phil Nov 16 '18 at 6:49
  • What commands are you running? What error messages are you getting? Could you edit your original post to include them? – Lewis M Nov 16 '18 at 12:29
  • updated the question with some progress, almost there I feel – Phil Nov 16 '18 at 14:16

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.