My Main Question
How do I configure my RPi so that I can share its internet connection with an IoT device plugged in via ethernet cable in addition to sharing its internet connection via its wifi-adapter?
I have multiple IoT devices that need internet access. Most are wireless, but one requires a wired ethernet connection. I have an RPi running Raspbian stretch with a static IP issued by my organization's network admin. The connection to my org network is via ethernet cable, and uses the built-in ethernet port on the RPi. It is
eth0 in my configuration. The RPi itself has no trouble connecting to the internet.
I was able to configure the RPi as a wireless access point using this tutorial. That works great. My wireless IoT devices can connect to the wifi network on my RPi without issue.
For the wired device, I purchased a USB ethernet adapter that shows up as
I'm trying to setup
eth1 so that any device that is plugged into it will automatically be given an IP address and have access to the internet.
Here are the current contents of key files (or ones that appear to be "key files" to me):
# /etc/network/interfaces source-directory /etc/network/interfaces.d auto br0 iface br0 inet manual bridge_ports eth0 wlan0
# /etc/dhcpcd.conf hostname clientid persistent option rapid_commit option domain_name_servers, domain_name, domain_search, host_name option classless_static_routes option ntp_servers require dhcp_server_identifier slaac private nohook lookup-hostname # RaspAP-WebGui wireless configuration interface wlan0 static ip_address=10.3.141.1/24 static routers=10.3.141.1 static domain_name_server=126.96.36.199 188.8.131.52
# /etc/rc.local _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP Address is %s\n" "$_IP" fi iptables-restore < /etc/iptables.ipv4.nat echo 1 > /proc/sys/net/ipv4/ip_forward #RASPAP iptables -t nat -A POSTROUTING -j MASQUERADE #RASPAP exit 0
# /etc/iptables.ipv4.nat *nat :PREROUTING ACCEPT [0:0] :INPUT ACCEPT [0:0] :OUTPUT ACCEPT [0:0] :POSTROUTING ACCEPT [0:0] -A POSTROUTING -o eth0 -j MASQUERADE COMMIT
What I've Tried
I'm a web developer and don't have enough background in networking to have more than a bare grasp of what I'm trying to do. Essentially what I believe is that I need to setup
eth1 to act as a DHCP server for anything that connects to it, and then allow it to bridge to my internet connection which comes in via
eth0. I tried to mimic the settings for
Of course, I've done a lot of googling, but I never fully feel like I understand the reasoning behind the various configurations I've been reading, and therefore am not sure what I should try next.
I tried adding
eth1 to the
br0 bridge by adding
bridge_ports eth0 eth1 to
I tried assigning different static IP addresses to
/etc/dhcpcd.conf. Here are the addresses that I've tried (both with and without having it be a part of the bridge):
# first try interface eth1 static ip_address=10.4.141.1/24 static routers=10.4.141.1 static domain_name_server=184.108.40.206 220.127.116.11 # second try interface eth1 static ip_address=10.3.141.2/24 static routers=10.3.141.2 static domain_name_server=18.104.22.168 22.214.171.124 # third try interface eth1 static ip_address=192.168.2.3/24 static routers=192.168.2.3 static domain_name_server=126.96.36.199 188.8.131.52
I was successful at getting
eth1 to assign an IP address (in the host org network's IP address range) to a computer that I connected to it, but I haven't yet been able to also get internet access through that connection. Not only that, usually when I do this, though, my RPi loses internet access altogether, but not immediately. It will have internet access for a few seconds/minutes when it first boots up, but then loses it.
It feels like I'm really close, but I'm missing some key piece of understanding about how this stuff works.
Thank you for your time!!!