Page 1 of 1

frustrated: how to create backwards router on 3B+ ??

Posted: Thu Nov 22, 2018 10:46 pm
by mushu999
So I say "backwards" because all the googling I've found shows several completely different ways to turn the Pi 3B+ into a bridge or router by using a wired connection to the Internet and allowing wireless clients to connect to it.

I want it the other way around. And since you're asking yourself "why?" it is because I need a wired ethernet client hardware to be assigned an IP address in the garage from the Pi which is itself getting an IP address via wireless to a router in the house, and I don't want to lay 100 feet of CAT6 from the living room into the garage just to connect that hardware (which *would* work.)

So I'm at the point where, via iptables rules and installing hostapd (which I've subsequently removed because I think that isn't what I want) I no longer have access to the network via wireless. When it boots it says near the end "my IP address is" but that is the one assigned to the eth0 for the other hardware to plug in to, so I don't want the Pi itself to have that IP addr. One more thing: I was having errors at bootup with an "rc.local Compatibility" issue so I grep'd dmesg for dhcp and found two versions of dhcp installed so I removed dhcp5 and the error went away.

Here's some output, which sucks because no connection, so all typed manually:


Code: Select all

eth0    no wireless extensions
lo        no wireless extensions
wlan0  IEEE 802.11 ESSID: off/any
           Mode: managed Access Point: not associated  Tx-Power=31 dBm
           Retry short limit: 7  RTS thr:off  Fragment thr: off
           Power management: on


Code: Select all

eth0:  flags=4099<up,broadcast,multicast> mtu 1500
          inet  netmask  broadcast
no packets or errors
lo:      flags=73<up,loopback,running> mtu 65536
wlan0: flags=4099<up,broadcast,multicast> mtu 1500
no packets or errors

/etc/dhcpcd.conf (only the lines not commented out):

Code: Select all

option rapid_commit
option domain_name_servers, domain_name, domain_search, hostname
option classless_static_routes
option ntp_servers
option interface_mtu
require dhcp_server_identifier
slaac private
interface wlan0
static ip_address=

(for next item note that /etc/network/interfaces.d/ contains no files)

Code: Select all

source-directory /etc/network/interfaces.d
auto lo
auto wlan0
iface lo inet loopback
iface wlan0 inet dhcp
allow-hotplug eth0
iface eth0 inet static
   post-up iw dev $IFACE set power_save off
post-up iptables-restore < /etc/iptables.ipv4.nat


Code: Select all

:INPUT ACCEPT [105:8608]
:OUTPUT ACCEPT [49:5764]
-A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i eth0 -o wlan0 -j ACCEPT
:INPUT ACCEPT [10:1002]


Code: Select all

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

I may have typo'd so let me know if something looks wonky. Also if you need other file data let me know. I understand this is difficult to troubleshoot via proxy but I'm hoping someone has at least an idea I can try. Thanks in advance and Happy Thanksgiving!

TL;DR: how do I get rpi 3B+ to assign IP on eth0 but receive IP on wlan0?

Re: frustrated: how to create backwards router on 3B+ ??

Posted: Fri Nov 23, 2018 8:11 am
by epoch1970
Is this backwards enough?

Common ways to avoid this grief:
- Use 2 networks, one for wifi, one for ethernet, and route/masquerade between the 2 networks. Not transparent, but works in practice.
- Get a "gaming adapter" or "wifi travel router" that features an ethernet port and wifi capability. In general these will allow to connect over wifi uplink a single machine connected via ethernet. Works only for a single machine and direct connection, not when connected to a network segment via a switch.
- Find network hardware that will handle bridging over wireless. Not standards-compliant, so your best bet is getting 2 router/AP units of the same brand or at least running the same software.

Re: frustrated: how to create backwards router on 3B+ ??

Posted: Fri Nov 23, 2018 2:33 pm
by mushu999
OMG thank you! That's exactly what I'm trying to do. Will get on it right away. :-)

Re: frustrated: how to create backwards router on 3B+ ??

Posted: Fri Nov 23, 2018 4:21 pm
by epoch1970
Also here, you can follow the tribulations of someone trying to apply the above guide.
A bit lengthy but could contain additional useful bits of info. The OP used 2 Pis, and a Pi3b+ on the "house" side.

Re: frustrated: how to create backwards router on 3B+ ??

Posted: Sun Dec 16, 2018 12:00 am
by mushu999
Okay, I followed several guides and with a mishmash of configs I managed to get the pi to act as a router for the ethernet port over wifi. It actually works, since I disabled my laptop's wireless and plugged in an ethernet-to-usb adapter, then plugged it in the pi and got an IP address and had Internet connectivity, yay!

However, whenever the ethernet is plugged in to the pi, the pi itself no longer has Internet connectivity. Would really like someone to point me in the right direction, I think it's an iptables issue. Here is what is set up now on the pi:

Code: Select all

$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target        prot   opt  source                 destination

Chain FORWARD (policy ACCEPT)
target        prot   opt  source                 destination
ACCEPT        all    --   anywhere               anywhere             state RELATED,ESTABLISHED
ACCEPT        all    --   anywhere               anywhere

Chain OUTPUT (policy ACCEPT)
target        prot   opt  source                 destination

So what is missing to allow the pi to also access the Internet when ethernet is plugged in?

Thanks in advance!