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
  • 40,606
  • 15
  • 76
  • 189
Nht_e0
  • 77
  • 6
  • 1
    "Can someone show me what I'm doing wrong?" Running a 7 year old tutorial designed for an obsolete OS. – Milliways Aug 20 '19 at 03:39
  • 1
    You might like to try the following tutorials: (1) Rpi Wireless Hotspot - elinux 2018aug https://elinux.org/RPI-Wireless-Hotspot (2) Setting up a Raspberry Pi as a Wireless Access Point https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md (3) How to use your Raspberry Pi as a wireless access point - Stephen Lovely 2017july https://thepi.io/how-to-use-your-raspberry-pi-as-a-wireless-access-point/ (4) Setting up a Raspberry Pi 3 as an Access Point - Shawn Hymel https://learn.sparkfun.com/tutorials/setting-up-a-raspberry-pi-3-as-an-access-point/all – tlfong01 Aug 20 '19 at 07:04
  • What operating system do you use? What version? Is there a special reason why you don't connect the **AP** direct to **ISP** with an ethernet cable? – Ingo Aug 20 '19 at 11:29
  • @Ingo OS is Raspbian buster Jul 2019. I am replacing the router with the RPi to get more insight into the traffic. I am using the existing router as an AP connected to the RPi because its signal strength is better and I don't want to buy a new wifi dongle or something similar :) – Nht_e0 Aug 20 '19 at 21:15
  • I do not understand how the RasPi is connected to **ISP** by eth0. How does the interface eth0 gets it ip address? For what do you need a DHCP server on the RasPi? Does not the **AP** provide a DHCP server? – Ingo Aug 20 '19 at 21:25
  • @Ingo The connection from ISP is similar to any other home connection. Instead of connecting a typical router I have connected a RPi. The IP address for eth0 should be provided by the ISP. The DHCP server is for the internal network that is behind a NAT (provided by the RPi that acts as a router). The AP does not a provide any service. It only acts like a bridge – Nht_e0 Aug 20 '19 at 21:47
  • OK, the **AP** bridges WiFi and wired connection. But still unclear is how the RasPi connects to the **ISP** (Internet Service Provider) which is not a device. Usually you have a peace of hardware (modem, router) that connects to the ISP mostly with the PPPOE protocol or by a xG (GSM, 3G, 4G) satellite connection. How does the RasPi connects to your provider? Does it use PPPOE? This configuration is important because we have to check routing. Can you please edit your question and add the things to it that you have clarified in comments? – Ingo Aug 21 '19 at 07:11
  • @Ingo I added more details. Please disregard any prior details that may not make sense with the current setup – Nht_e0 Aug 21 '19 at 16:14

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
  • 40,606
  • 15
  • 76
  • 189
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