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 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:  Bcast:  Mask:
          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:  Mask:
          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:  Bcast:  Mask:
          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

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:


subnet netmask {
option broadcast-address;
option routers;
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
# 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 ( 56(84) bytes of data.
From icmp_seq=1 Destination Host Unreachable
From icmp_seq=2 Destination Host Unreachable
From icmp_seq=3 Destination Host Unreachable
From icmp_seq=4 Destination Host Unreachable
From icmp_seq=5 Destination Host Unreachable
From icmp_seq=6 Destination Host Unreachable
--- 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.

  • 2
    While it's probably not the whole issue, remove the gateway line from the eth0 configuration. Other machines should see the pi's as the way to the Internet, but the pi should not, which explains your inability to ping google from the pi. Jan 26, 2015 at 16:17
  • @ChrisStratton: Thanks Chris, I'll try that when I get home.
    – James
    Jan 26, 2015 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, 2015 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, 2015 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, 2015 at 21:58


Browse other questions tagged or ask your own question.