0

The Goal: Connect up an existing wireless LAN to an existing wireless WAN without an ethernet drop.

In the past when I had this portable wireless subnet setup, I had an ethernet drop I could plug into my router thereby serving its original purpose as a router.

In the current configuration, I have no ethernet drop but only access to the wireless WAN. (Before your suggest it, it is not desired to configure each of the devices in the subnet to use the wireless credentials.)

Here are my possible ingredients:

  • several wireless devices configured with the credentials for the wireless LAN served by my router
  • A consumer-grade wireless router
  • Another spare wireless router
  • A spare RasPi3 with built-in wireless
  • Access to the wireless WAN

Thinking something like this, but don't know the systems software details.

LAN/WAN gateway diagram

Perhaps there is another magic device I need. Perhaps you can suggest something. I'm sure there are build descriptions out there on the webs, but I wasn't exactly sure what to look for.

Or perhaps, instead of the pi, I can use another wireless router connected to the first, but I'd have no idea how to configure it.

EDIT: I ended up using another router rather than a Pi. Answer here: https://superuser.com/a/1195174/264141

1

This configuration will allow to share/extend a Wireless network to use your own router (192.168.0.0/24); will be like and extender or repeater. The WAN side can be any DHCP WIFI connection.
There will be a double NAT, plus the extra hop, so the system will not be a fast access point but, a very convenient. You may also use this with a switch, allowing internet access to almost any non wireless enabled device.
I use this configuration on my boat, using a pretty good external antenna, to connect to a remote (1 mile +) access point.

  • WAN connection

Connect the extender to the WAN. Create a wpa_supplicant with the proper credentials. You can have multiple WIFI credentials on file if you are roaming.

  • Change your eth0 parameters to have a fix IP address:

Showing here the eth0 configuration.

nano /etc/network/interfaces
.....
allow-hotplug eth0
iface eth0 inet static
  address 192.168.0.1
  network 192.168.0.0
  netmask 255.255.255.0
....
  • DHCP and DNS

Remove isc-dhcp if available and install a couple of packages to provide DHCP and DNS to your private network:

apt-get autoremove isc-dhcp-server
apt-get install -y dnsmasq dnsutils
  • configure dnsmasq

dnsmasq is a very common and powerful package included in a vast number of commercial routers. Modify a few lines on the .conf file (they may be commented with #) most are self explanatory:

nano /etc/dnsmasq.conf
interface=eth0
except-interface=wlan0
dhcp-range=192.168.0.2,192.168.0.254,1h
dhcp-option=option:router,192.168.0.1
# option 6 is dns server
dhcp-option=6,192.168.0.1
  • Configure IPTABLES to forward packets between the networks:

Using cron execute this bash to run on reboot.

#!/bin/bash
# request package forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
i=$(which iptables)
PUB=wlan0
PRI=eth0
GW=$(route -n | grep "^0\.0\..*${PUB}"| tail -n 1|  awk '{print $2}')
$i -A FORWARD -i $PUB -m comment --comment "Created" -j ACCEPT
$i -A FORWARD -i $PRI -m state --state RELATED,ESTABLISHED -m comment --comment "Created" -j ACCEPT
$i -t nat -A POSTROUTING -o $PRI -m comment --comment "Created" -j SNAT --to-source $GW
$i -t nat -A POSTROUTING -o $PUB -m comment --comment "Created" -j MASQUERADE
unset i wlan0 eth0
  • emergency reconnection

In my case, sometimes with no apparent reason I get disconnected (once or twice a day). I have this job running every few minutes to reconnect the WAN if not up:

#!/bin/bash
wlan=wlan0
c=$(iw $wlan link | grep [Cc]onnected\ to | sed 's/.* to //')
# if not connected, reconnect
if [ "x${c}" == "x" ] ; then
   wpa_cli terminate
   sleep .05
   ifconfig $wlan down
   wpa_supplicant -B -K -Dnl80211 -i$wlan -c/etc/wpa_supplicant/wpa_supplicant.conf
   sleep .05
   dhclient $wlan
fi
unset c wlan
  • I didn't get a chance to try your solution, as I ended up using another router, as per superuser.com/a/1195174/264141. I'd like to mark it as the answer, but I haven't tried it. I'll upvote it and if I hear from anyone else that it worked for them, I'll mark it as the answer. – Wes Modes Apr 4 '17 at 3:26
  • And there may come a time that I need to use your solution on MY boat. – Wes Modes Apr 4 '17 at 3:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.