1

I looked at several solutions for this question, but none of them worked. Additionally, I tried some of the tutorials provided (with the necessary changes), but none of them worked

My aim is to use a RPi 3B+ as a router with an existing wireless router connected as an access point. The following figure explains this:

enter image description here

'eth0' is the Rpi's WAN port. The IP for eth0 is assigned automatically by a DHCP server that is beyond my control.

'eth1' is an 'USB to Ethernet' adapter. The wireless network is separated from the network the switch is in, by a NAT service that should run on the RPi.

I am following this tutorial as a guide. I have already configured the router as an AP.

My Problem: When I configure the network (i.e. edit the /etc/network/interfaces file) and restart the networking services (sudo /etc/init.d/networking restart), I get the following error:

Restarting networking (via systemctl): networking.serviceJob for networking.service failed because the control process exited with error code. 
See 'systemctl status networking.service' and 'journalctl -xn' for details. 

I also get a similar error when I try to start the DHCP server after configuration.

Starting isc-dhcp-server (via systemctl): isc-dhcp-server.serviceJob for isc-dhcp-server.service failed because the control process exited with error code. 
See 'systemctl status isc-dhcp-server.service' and 'journalctl -xn' for details.

In addition, when I install isc-dhcp-server using sudo apt-get install isc-dhcp-server, it gives an error saying failed to start although it installs properly.

Can someone show me what I'm doing wrong?

EDIT: I have made a change to the setup. Instead of getting a direct connection from the ISP, I get it through a switch (hence no modem). What happens beyond the switch is none of my concern)

Ingo
  • 42,961
  • 20
  • 87
  • 207
Nht_e0
  • 77
  • 1
  • 6

2 Answers2

1

To do what you want is simple with systemd-networkd because it has everything built-in and you don't need additional helpers. So I will use it for my suggestion, tested with Raspbian Buster Lite 2019-07-10 updated on 2019-08-22. Updates done with sudo apt update && sudo apt full-upgrade && sudo reboot.

First switch over to systemd-networkd. For further information look at (1), (2).

# disable classic networking
rpi ~$ sudo -Es
rpi ~# systemctl mask networking.service dhcpcd.service
rpi ~# mv /etc/network/interfaces /etc/network/interfaces~
rpi ~# sed -i '1i resolvconf=NO' /etc/resolvconf.conf

# enable systemd-networkd
rpi ~# systemctl enable systemd-networkd.service systemd-resolved.service
rpi ~# ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

Then create these files:

rpi ~# cat > /etc/systemd/network/04-eth0.network <<EOF
[Match]
Name=eth0
[Network]
DHCP=yes
IPForward=yes
EOF

rpi ~# cat > /etc/systemd/network/06-eth1.network <<EOF
[Match]
Name=eth1
[Network]
Address=192.168.5.1/24
DHCPServer=yes
[DHCPServer]
DNS=84.200.69.80 1.1.1.1
EOF

We also need a Network Address Translation (NAT) on interface eth0 to reach all devices on the access point. Create it with:

rpi ~# systemctl --full --force edit nat@.service

In the empty editor insert these statements, save them and quit the editor:

[Unit]
Description=NAT for interface %i
After=systemd-networkd.service
BindsTo=systemd-networkd.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/iptables -t nat -A POSTROUTING -o %i -j MASQUERADE
ExecStopPost=-/sbin/iptables -t nat -D POSTROUTING -o %i -j MASQUERADE

[Install]
WantedBy=systemd-networkd.service

Enable the new service:

rpi ~# sudo systemctl enable nat@eth0.service

Reboot and it should do.


References:
(1): Compare three available networking systems on Raspbian
(2): Howto migrate from networking to systemd-networkd with dynamic failover

Ingo
  • 42,961
  • 20
  • 87
  • 207
0

You could use my project I once wrote. It isn't perfect and I don't have the time making it better. I'm using dnsmasq and dnsmasq can communicate with eth and wifi due to the Layer-3 protocol.
My tool is tested on the Pi2 running Arch Linux. The project

kuzeyron
  • 128
  • 1
  • 8