0

I am trying to set up a Raspberian Stretch install to act as DHCP server on the ethernet port (eth0), to share the network coming from wlan0, but when I restart dnsmasq it fails and in the logs I see: unknown interface eth0. I have looked around at various docs, but I am still not working out what's going wrong?

ifconfig output:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether b8:27:eb:41:7e:e5  txqueuelen 1000  (Ethernet)
        RX packets 147  bytes 49152 (48.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 455  bytes 86402 (84.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 4  bytes 156 (156.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 156 (156.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.89  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::5c84:d395:9208:b2  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:16:2b:b0  txqueuelen 1000  (Ethernet)
        RX packets 4603  bytes 1034004 (1009.7 KiB)
        RX errors 0  dropped 2  overruns 0  frame 0
        TX packets 1356  bytes 304820 (297.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Contents of the /etc/dnsmasq.conf:

dhcp-range=eth0,192.168.8.8,192.168.8.250,255.255.255.0,12h

Notable changes in /etc/sysctl.conf:

net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1

Notable changes in /etc/dhcpcd.conf:

interface eth0
static ip_address=192.168.8.1/24

Running sudo systemctl restart dnsmasq, gives me:

Job for dnsmasq.service failed because the control process exited with error code.
See "systemctl status dnsmasq.service" and "journalctl -xe" for details.

Checking journalctl -xe gives me:

Sep 14 22:08:23 pibridge NetworkManager[376]: <info>  [1568495303.0907] dhcp4 (eth0): canceled DHCP transaction, DHCP client pid 3408
Sep 14 22:08:23 pibridge NetworkManager[376]: <info>  [1568495303.0908] dhcp4 (eth0): state changed timeout -> done
Sep 14 22:08:23 pibridge NetworkManager[376]: <info>  [1568495303.0925] device (eth0): state change: ip-config -> failed (reason 'ip-config-unavailable') [70 120 5]
Sep 14 22:08:23 pibridge NetworkManager[376]: <info>  [1568495303.0940] policy: disabling autoconnect for connection 'Wired connection 1'.
Sep 14 22:08:23 pibridge NetworkManager[376]: <warn>  [1568495303.0955] device (eth0): Activation: failed for connection 'Wired connection 1'
Sep 14 22:08:23 pibridge NetworkManager[376]: <info>  [1568495303.0997] device (eth0): state change: failed -> disconnected (reason 'none') [120 30 0]
Sep 14 22:08:23 pibridge avahi-daemon[374]: Withdrawing address record for fe80::bfb3:994d:2b02:2adb on eth0.
Sep 14 22:08:23 pibridge avahi-daemon[374]: Leaving mDNS multicast group on interface eth0.IPv6 with address fe80::bfb3:994d:2b02:2adb.
Sep 14 22:08:23 pibridge avahi-daemon[374]: Interface eth0.IPv6 no longer relevant for mDNS.
Sep 14 22:08:36 pibridge sudo[3666]:       pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/bin/systemctl restart dnsmasq
Sep 14 22:08:36 pibridge sudo[3666]: pam_unix(sudo:session): session opened for user root by pi(uid=0)
Sep 14 22:08:36 pibridge systemd[1]: Stopping dnsmasq - A lightweight DHCP and caching DNS server...
-- Subject: Unit dnsmasq.service has begun shutting down
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Unit dnsmasq.service has begun shutting down.
Sep 14 22:08:37 pibridge dnsmasq[3672]: Too few arguments.
Sep 14 22:08:37 pibridge dnsmasq[3567]: exiting on receipt of SIGTERM
Sep 14 22:08:37 pibridge systemd[1]: Stopped dnsmasq - A lightweight DHCP and caching DNS server.
-- Subject: Unit dnsmasq.service has finished shutting down
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Unit dnsmasq.service has finished shutting down.
Sep 14 22:08:37 pibridge systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
-- Subject: Unit dnsmasq.service has begun start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Unit dnsmasq.service has begun starting up.
Sep 14 22:08:37 pibridge dnsmasq[3723]: dnsmasq: syntax check OK.
Sep 14 22:08:37 pibridge dnsmasq[3725]: dnsmasq: unknown interface eth0
Sep 14 22:08:37 pibridge dnsmasq[3725]: unknown interface eth0
Sep 14 22:08:37 pibridge dnsmasq[3725]: FAILED to start up
Sep 14 22:08:37 pibridge systemd[1]: dnsmasq.service: Control process exited, code=exited status=2
Sep 14 22:08:37 pibridge systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.
-- Subject: Unit dnsmasq.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Unit dnsmasq.service has failed.
-- 
-- The result is failed.
Sep 14 22:08:37 pibridge systemd[1]: dnsmasq.service: Unit entered failed state.
Sep 14 22:08:37 pibridge systemd[1]: dnsmasq.service: Failed with result 'exit-code'.
Sep 14 22:08:37 pibridge sudo[3666]: pam_unix(sudo:session): session closed for user root

Note once or twice it did seem to restart without complaint, but then I did not see any IPv4 address assigned to the eth0 interface. I would have assumed 192.168.8.1, per the above config?

I have also avoided touching /etc/network/interface since most recent sources suggest this should not be touched in Raspian Stretch.

Environment details:

Model: Raspberry Pi 3 Model B Rev 1.2
uname -a: Linux pibridge 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux
Andre M
  • 129
  • 1
  • 6
  • 1
    The Answer by Dougie is correct BUT even though you claim to be using Raspberian(sic) Stretch your logs show NetworkManager so you have a non-standard installation, but have not elaborated. – Milliways Sep 15 '19 at 01:31

4 Answers4

3

First of all, you should add an IP address to eth0 that is in the same range with dnsmasq configuration.

ifconfig eth0 192.168.8.254 netmask 255.255.255.0 up

Be sure that 127.0.0.1 is one of your host nameserver or add it to /etc/resolv.conf.

echo "nameserver 127.0.0.1" > /etc/resolv.conf

Finally, reboot your host or restart dnsmasq and networking service.

/etc/init.d/dnsmasq restart
/etc/init.d/networking restart

I hope this will be useful.

M. Rostami
  • 4,235
  • 1
  • 15
  • 34
2

Change your dnsmasq.conf to

interface=eth0
dhcp-range=192.168.8.8,192.168.8.250,255.255.255.0,12h
Dougie
  • 4,940
  • 7
  • 14
  • 27
  • Done that, but still seeing issues with dhcp. At this point still having issues due to no address being assigned to eth0. Restarted and still seeing issues. – Andre M Sep 14 '19 at 21:43
  • the dhcp server should not be assigning an IP address to the port ... the port address should be fixed ... the dhcp server assigns an address to any device that is plugged into the port – jsotola Sep 14 '19 at 23:20
  • How in Raspian Stretch do we define the address of this is interface? – Andre M Sep 15 '19 at 05:09
0

Very confusing. You named the device "pibridge" but use routing. Is there also a bridge? You use NetworkManager which isn't supported by Raspbian Stretch and does not conform with dhcpcd but you try to set a static ip address with dhcpcd to eth0. As you show that doesn't work because eth0 does not get an ip address.

Then it is unclear for me what you mean with

to act as DHCP server on the ethernet port (eth0), to share the network coming from wlan0

You try to setup a DHCP server on eth0 and it seems that you use routing between wlan0 (subnet 192.168.2.0/24) and eth0 (subnet 192.168.8.0/24). But dnsmasq is configured to serve ip addresses to devices connected to eth0 but wlan0 isn't served. What devices are connected to eth0 that need an ip address from the DHCP server? Maybe there is also a DHCP server running if you use it as uplink to an internet router? How does devices connected to wlan0 get an ip address?

First of all you should decide what networking system do you want to use and then only use this one without mixing them up. On Raspbian you have the choice between three networking systems, dhcpcd (default), old style Debian ifupdown (configured with /etc/netwwork/interfaces) and systemd-networkd. For further information look at three different notworking systems on Raspbian. If you want to use NetworkManager then you should disable the other three systems. I would prefer systemd-networkd.

Update:
You asked for recommended setups for an access point together with a wired connection. For using systemd-networkd you can look at Setting up a Raspberry Pi as an access point - the easy way.

Ingo
  • 40,606
  • 15
  • 76
  • 189
  • I am essentially trying to share a WiFi connection to devices connected to the Ethernet port. I have been trying to follow various docs, but they all seem to have issue. Which is the recommended one these days and do you have up to date instructions on how to create a subnet with it? The device name was poorly chosen. – Andre M Sep 15 '19 at 13:50
  • Since I can’t edit: I’ll be connecting a WiFi access point to the Pi, to allow IoT type devices to connect. They can’t connect directly to the main WiFi network due to certain limitations. – Andre M Sep 15 '19 at 14:06
  • @AndreM You cannot connect an access point to the RasPi. You can only create an access point on the RasPi, to that other devices can connect. I have updated my answer at the end. – Ingo Sep 15 '19 at 17:49
0

I've been having this same issue. It only happens for me if the Ethernet cable is not connected to something (so eth0 hasn't been assigned an address by dhcpcd.)

The fix for me was to edit dnsmasq.conf to be the following:

except-interface wlan0 # ignore anything on the WiFi connection
bind-interfaces # bind all interfaces regardless of current status

If you have interface=eth0 comment that out.

tresni
  • 1