5

I have a scenario where I have a cellular Wifi hotspot modem also known as 'MiFi'. The problem I am encountering is all the tutorials I have come across are mostly outdated or purely just don't work.

What I am trying to achieve is the following:

  1. Having my Rpi 3 setup to handle all communication between devices (cellular, laptop and desktop)
  2. Desktop with ethernet cable to have internet and possibly communicate with laptops if necessary
  3. The WiFi modem only acts as a hotspot for the Rpi 3 and preferably nothing else all other devices communicate through the Rpi 3

I have the following equipment: Raspberry Pi 3B Panda Pau05 wireless adapter 16GB Memory card with Raspbian Stretch Lite Installed on it And then of course power adapter.

My aim is to have the internal wifi of the adapter connect to the WiFi modem, the Wireless adapter as a Hotspot and then the ethernet to provide internet to the Switch or Desktop with internet.

I don't mind if the Rpi 3 is on a different IP Range (eg:192.168.2.x) from the WiFi Modem (eg:192.168.1.x)

If anyone has managed something like this or can point me to a more recent post please that would be highly appreciated

2 Answers 2

2

You do not need a second wireless adapter. The Raspberry Pi is able to work as a wireless hotspot and simultanous connect to another hotspot as client. But the wifi device on the RasPi has a general limitation. The client connection cannot be bridged because lack of WDS (wireless distribution system) that is needed for bridging on wireless. But as you say that is no problem because you can use routing with different subnets. The wifi hotspot and the ethernet port can be bridged so your laptop on wifi and the desktop on wired ethernet are on a common subnet. So it seems that all fit your needs. How to configure it you can look at Wireless access point with bridged wired ethernet port and wireless client connection.

If you want to use a second wifi adapter you can look at RPI3 Raspbian Stretch regular connection on wlan0 AP on wlan1. It is only for connecting two wifi devices but you may get an idea how it could work.

Update:
As from the comments you used the same subnet from the internet router for the access point (AP) but fixed it by using a different subnet for the AP. Now you can ping 8.8.8.8, the google DNS nameserver on the internet from a device attached to the ethernet port eth0 but you cannot ping 8.8.8.8 from a device connected to the AP (ap0). That is something I do not understand. eth0 and ap0 are bridged, so on the ethernet link layer (OSI layer 2) there is no difference between both interfaces. Either both work or none of them. Maybe there is a problem with flood on/off on the interface but I don't believe it because of correct default settings. Or the device on the AP is the problem. On my tests with many bring up and shut down of the AP my mobile phone get stuck and I had to restart it. Try this first.

Then check if eth0 and ap0 are both slave interfaces of the bridge with:

rpi ~$ bridge link show
2: eth0 state UP : <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 4
5: ap0 state UP : <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 100

Check if ip forwarding is active and the default route is set to the internet router:

rpi ~$ cat /proc/sys/net/ipv4/ip_forward   # should give 1
1

rpi ~$ ip route show
default via 192.168.10.1 dev wlan0 proto dhcp src 192.168.10.125 metric 1024
10.0.0.0/24 dev br0 proto kernel scope link src 10.0.0.1
192.168.10.0/24 dev wlan0 proto kernel scope link src 192.168.10.125
192.168.10.1 dev wlan0 proto dhcp scope link src 192.168.10.125 metric 1024

The line with default must point to the internet router and the source must be the ip address from wlan0.

Then NAT (network address translation) must be enabled. Check with:

rpi ~$ sudo iptables --table nat --list POSTROUTING --verbose
Chain POSTROUTING (policy ACCEPT 5 packets, 479 bytes)
 pkts bytes target     prot opt in     out     source               destination
   36  2685 MASQUERADE  all  --  any    wlan0   anywhere             anywhere

Yes, and sometimes ap0 gets stuck with unknown reason and needs a kick with:

rpi ~$ sudo ip link set ap0 up
14
  • Hi Ingo. the first link you provided me really helped a lot thank you so much. I am unable to comment on the post asking for help hence why I am commenting here now However I have managed to get internet connection to the ethernet port now which is exactly what I am looking for. I was not able to get internet connection when connecting to the ap0(RPiNet) Any suggestions going forward please? I have copy and pasted everything across using ssh. @Ingo
    – user92651
    Oct 11, 2018 at 13:49
  • Hi @user92651, your question was a trigger for me to optimize that answer. I have added routing through wlan0 to the internet and reduced the setup for 2 steps. I have made some updates the last two days and I don't know what version you have used. The first versions weren't able to connect to the internet. The version just now can. You should have a look at it, but I'm still working on it. Please feel free to comment here and tell we what's going wrong.
    – Ingo
    Oct 11, 2018 at 14:07
  • @user92651 And yes, you are free to up vote that linked answer ;-)
    – Ingo
    Oct 11, 2018 at 14:16
  • Hi @Ingo, I have upvoted the your post thanks, unfortunately I am under 15 points so it doesn't show yet. However, I have redone everything just to make sure I wasn't missing anything. I am not sure about the versions you are running but I have followed the one on this link 'you mentioned reduced the setup for 2 steps' where about can I find this please. at the moment I am not using a secondary adapter only the onboard chip.
    – user92651
    Oct 11, 2018 at 14:52
  • @user92651 This version with 4 steps you linked to should work. I have just tested it three hours ago. At the end of the answer there is a link edited $time ago. You can click on this link and you will see the change history. The versions before had two steps more to create unneeded help services.
    – Ingo
    Oct 11, 2018 at 15:10
1

I have managed to get a working connection from wifi through to ethernet. I changed the network manager used on Raspbian to Network-manager-gnome and deviated from stretch-lite to stretch fully updated

  1. Install Network Manager Gnome

    sudo apt install network-manager network-manager-gnome

  2. Remove the unneeded package. (vital step else network-manager-gnome won't work at all)

    sudo apt purge openresolv dhcpcd5

  3. Now go to the top right corner and remove 'wireless and wired network' from the panel items

  4. Reboot the system (the new network manager panel should appear after reboot

    reboot

5.1 Right click on new network manager icon 5.2 edit connections 5.3 click on 'Wired Connection 1' the click on edit 5.4 select 'IPv4 Settings' 5.5 'Method drop down menu' then select 'Shared to other computers'

You can also add an adhoc, wifi sharing to other computers and a few others with this Network Manager.

Please note that I have not yet figured out how to configure the DHCP IP address settings to create your own range as it creates one in the 10.42.x.x range if I remember correct.

I have also noticed that if you are using a Mac that and connected to pi with ethernet that you preferably have to turn off your 'wifi' else the laptop battles to receive an IP Address even after renewing DHCP Lease

I haven't yet tried other settings with the wifi yet as it was out of my reach for the purpose I needed it but will give it a test some time soon and give feedback.

Ping time to 8.8.8.8

64 bytes from 8.8.8.8: icmp_seq=0 ttl=119 time=56.365 ms 64 bytes from 8.8.8.8: icmp_seq=1 ttl=119 time=42.128 ms 64 bytes from 8.8.8.8: icmp_seq=2 ttl=119 time=50.178 ms 64 bytes from 8.8.8.8: icmp_seq=3 ttl=119 time=68.017 ms

Thank you @Ingo for being such an amazing help at the time before I came to this solution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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