3

I don't have a lot of experience with Linux, but I was hoping I'd be able to use my Raspberry Pi to share a 4G dongle's internet connection with my main router. Unfortunately I haven't quite managed to get it to work so far.

The Raspberry Pi in question is a 512MB Model B from 2014 running Raspbian and the dongle is a Huawei E8278. I have been following various tutorials around although none of them are for exactly the same scenario. I installed usb_modeswitch and sg3-utils, but I'm not sure if I even needed to. Either way the dongle is showing up as wwan0 and once I realised that I could tell wicd to use it as a wired network, I was able to connect to the internet on the Pi. At this point I did not have anything connected to the Ethernet port.

Afterwards I followed some instructions for installing a DHCP server (using dhcpd) and setting up IP tables. Finally I connected it up to my router, but it's not working correctly. My router gets a WAN IP of 192.168.50.10 from the Pi which is in line with what I configured it to be, but I can't connect to any external sites and I can't connect to the dongle's administration page. Interestingly on the Pi itself I can connect to the dongle via its IP address, and it looks like web addresses are being resolved by a DNS, but I still get an error about not being able to reach the destination host.

Here is ifconfig info:

pi@raspberrypi ~ $ ifconfig -a
eth0      Link encap:Ethernet  HWaddr b8:27:eb:66:33:f1 
          inet addr:192.168.50.1  Bcast:192.168.50.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1372 errors:0 dropped:0 overruns:0 frame:0
          TX packets:800 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:99647 (97.3 KiB)  TX bytes:103984 (101.5 KiB)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:102 errors:0 dropped:0 overruns:0 frame:0
          TX packets:102 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:10944 (10.6 KiB)  TX bytes:10944 (10.6 KiB)

wwan0     Link encap:Ethernet  HWaddr 0c:5b:8f:27:9a:64 
          inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:815 errors:0 dropped:0 overruns:0 frame:0
          TX packets:58 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:348906 (340.7 KiB)  TX bytes:80077 (78.2 KiB)

Here is /etc/network/interfaces:

auto lo

iface lo inet loopback

allow-hotplug eth0
iface eth0 inet static
address 192.168.50.1
netmask 255.255.255.0
network 192.168.50.0
broadcast 192.168.50.255
gateway 192.168.50.1

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

allow-hotplug wwan0
iface wwan0 inet dhcp

up iptables-restore < /etc/network/iptables

Here is the section I added to the default settings in /etc/dhcp/dhcpd.conf:

...

authoritative;
subnet 192.168.50.0 netmask 255.255.255.0 {
range 192.168.50.10 192.168.50.250;
option broadcast-address 192.168.50.255;
option routers 192.168.50.1;
default-lease-time 43200;
max-lease-time 172800;
option domain-name "local";
interface eth0;
}

Here is the /etc/network/iptables file which I am loading via the restore command in /etc/network/interfaces:

# Generated by iptables-save v1.4.14 on Sun Jan 25 15:26:17 2015
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o wwan0 -j MASQUERADE
COMMIT
# Completed on Sun Jan 25 15:26:17 2015

Finally, here are the results of pinging an address on the Pi:

pi@raspberrypi ~ $ ping google.com
PING google.com (173.194.32.198) 56(84) bytes of data.
From 192.168.50.1 icmp_seq=1 Destination Host Unreachable
From 192.168.50.1 icmp_seq=2 Destination Host Unreachable
From 192.168.50.1 icmp_seq=3 Destination Host Unreachable
From 192.168.50.1 icmp_seq=4 Destination Host Unreachable
From 192.168.50.1 icmp_seq=5 Destination Host Unreachable
From 192.168.50.1 icmp_seq=6 Destination Host Unreachable
^C
--- google.com ping statistics ---
9 packets transmitted, 0 received, +6 errors, 100% packet loss, time 8288ms
pipe 4

So my questions are:

  • Any ideas what this isn't working?
  • Is the fact that the dongle is presenting as wwan0 instead of eth1 an issue and does it mean that there are extra considerations?

Any help would be appreciated, I really need to get this working soon.

closed as off-topic by goldilocks May 9 '15 at 17:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be specific to the Raspberry Pi within the scope defined in the help center." – goldilocks
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    While it's probably not the whole issue, remove the gateway line from the eth0 configuration. Other machines should see the pi's 192.168.50.1 as the way to the Internet, but the pi should not, which explains your inability to ping google from the pi. – Chris Stratton Jan 26 '15 at 16:17
  • @ChrisStratton: Thanks Chris, I'll try that when I get home. – James Jan 26 '15 at 16:28
  • @ChrisStratton: It actually seems to have worked. If you post your comment as an answer then I'll accept it. – James Jan 27 '15 at 9:23
  • You've probably thought of this yourself, just double-checking: Is there a DHCP server on your router ? Did you switch it off ? – ssc Jan 29 '15 at 21:42
  • 2
    @ssc: The issue was caused by having the gateway for eth0 set to the the Pi's own IP address in /etc/network/interfaces. Removing that line (as Chris suggested) fixed it. I left the DHCP service running on my router since the Pi is connected to the WAN port and using a different subnet. – James Jan 29 '15 at 21:58