LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-26-2017, 12:59 PM   #1
hpapagaj
LQ Newbie
 
Registered: Jul 2017
Posts: 3

Rep: Reputation: Disabled
Share LTE modem (wwan0) to eth0


I am trying to share my LTE modem connection (wwan0) to my ethernet lan port on my rPi.

Code:
@raspberrypi:~ $ ifconfig -a

eth0      Link encap:Ethernet  HWaddr b8:27:eb:2a:2a:0f  
          inet addr:172.24.1.1  Bcast:172.24.1.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:423 errors:0 dropped:0 overruns:0 frame:0
          TX packets:76 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:38877 (37.9 KiB)  TX bytes:13468 (13.1 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:36 errors:0 dropped:0 overruns:0 frame:0
          TX packets:36 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:2813 (2.7 KiB)  TX bytes:2813 (2.7 KiB)

wlan0     Link encap:Ethernet  HWaddr b8:27:eb:7f:7f:5a  
          inet addr:192.168.1.50  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:323 errors:0 dropped:2 overruns:0 frame:0
          TX packets:485 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:30591 (29.8 KiB)  TX bytes:55800 (54.4 KiB)

wwan0     Link encap:Ethernet  HWaddr 00:1e:10:1f:00:00  
          inet addr:100.64.181.186  Bcast:100.64.181.187  Mask:255.255.255.252
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14 errors:0 dropped:0 overruns:0 frame:0
          TX packets:50 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1922 (1.8 KiB)  TX bytes:8367 (8.1 KiB)
sudo nano /etc/network/interfaces

Code:
#iface eth0 inet manual
allow-hotplug eth0  
iface eth0 inet static  
address 192.168.2.1
netmask 255.255.255.0
sudo nano /etc/dnsmasq.conf

Code:
interface=eth0      # Use interface eth0  
listen-address=192.168.2.1 # Explicitly specify the address to listen on  
bind-interfaces      # Bind to the interface to make sure we aren't sending things elsewhere  
server=8.8.8.8       # Forward DNS requests to Google DNS  
domain-needed        # Don't forward short names  
bogus-priv           # Never forward addresses in the non-routed address spaces.  
dhcp-range=192.168.2.1,192.168.2.50,12h # Assign IP addresses between 172.24.1.50 and 172.24.1.150 with a 12 hour lease time
sudo nano /etc/sysctl.conf

Code:
net.ipv4.ip_forward=1
Also I am issuing important command:

Code:
sudo iptables -t nat -A POSTROUTING -o wwan0 -j MASQUERADE
Code:
  pi@raspberrypi:~ $ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         setup.ubnt.com  0.0.0.0         UG    10     0        0 wlan0
default         100.64.35.177   0.0.0.0         UG    1000   0        0 wwan0
100.64.35.176   *               255.255.255.240 U     1000   0        0 wwan0
192.168.1.0     *               255.255.255.0   U     10     0        0 wlan0
192.168.2.0     *               255.255.255.0   U     0      0        0 eth0
...If I am connecting my client PC with rPi I get IP address via DHCP, but there is no internet connection. Can not ping (IP, hostname).

Route table after connecting the client:

Code:
pi@raspberrypi:~ $ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         setup.ubnt.com  0.0.0.0         UG    10     0        0 wlan0
default         100.64.35.177   0.0.0.0         UG    1000   0        0 wwan0
100.64.35.176   *               255.255.255.240 U     1000   0        0 wwan0
link-local      *               255.255.0.0     U     202    0        0 eth0
192.168.1.0     *               255.255.255.0   U     10     0        0 wlan0
192.168.2.0     *               255.255.255.0   U     0      0        0 eth0
syslog:

Code:
Jul 26 00:35:32 raspberrypi dhcpcd[760]: eth0: carrier acquired
Jul 26 00:35:32 raspberrypi kernel: [  662.708525] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xC5E1
Jul 26 00:35:32 raspberrypi dhcpcd[760]: eth0: IAID eb:2a:2a:0f
Jul 26 00:35:33 raspberrypi dnsmasq-dhcp[794]: DHCPDISCOVER(eth0) 00:0e:c6:d9:b4:b0
Jul 26 00:35:33 raspberrypi dnsmasq-dhcp[794]: DHCPOFFER(eth0) 192.168.2.40 00:0e:c6:d9:b4:b0
Jul 26 00:35:33 raspberrypi dhcpcd[760]: eth0: soliciting an IPv6 router
Jul 26 00:35:33 raspberrypi dhcpcd[760]: eth0: soliciting a DHCP lease
Jul 26 00:35:34 raspberrypi dnsmasq-dhcp[794]: DHCPREQUEST(eth0) 192.168.2.40 00:0e:c6:d9:b4:b0
Jul 26 00:35:34 raspberrypi dnsmasq-dhcp[794]: DHCPACK(eth0) 192.168.2.40 00:0e:c6:d9:b4:b0 Adrians-MBP
Jul 26 00:35:42 raspberrypi dhcpcd[760]: eth0: using IPv4LL address 169.254.153.193
Jul 26 00:35:42 raspberrypi avahi-daemon[430]: Registering new address record for 169.254.153.193 on eth0.IPv4.
Jul 26 00:35:42 raspberrypi dhcpcd[760]: wwan0: adding default route via 100.64.35.177
Jul 26 00:35:42 raspberrypi dhcpcd[760]: eth0: adding route to 169.254.0.0/16
Jul 26 00:35:43 raspberrypi dhcpcd[760]: wwan0: removing default route via 100.64.35.177
Jul 26 00:35:44 raspberrypi ntpd[784]: Listen normally on 8 eth0 169.254.153.193 UDP 123
Jul 26 00:35:44 raspberrypi ntpd[784]: peers refreshed
Jul 26 00:36:01 raspberrypi CRON[1732]: (root) CMD (/home/pi/script/watchdog.sh >/dev/null 2>&1)
Jul 26 00:37:01 raspberrypi CRON[1751]: (root) CMD (/home/pi/script/watchdog.sh >/dev/null 2>&1)
Jul 26 00:37:53 raspberrypi dhcpcd[760]: eth0: carrier lost
Jul 26 00:37:53 raspberrypi kernel: [  803.801956] smsc95xx 1-1.1:1.0 eth0: link down
Jul 26 00:37:53 raspberrypi avahi-daemon[430]: Withdrawing address record for 169.254.153.193 on eth0.
Jul 26 00:37:53 raspberrypi dhcpcd[760]: wwan0: adding default route via 100.64.35.177
Jul 26 00:37:53 raspberrypi dhcpcd[760]: eth0: deleting route to 169.254.0.0/16
Jul 26 00:37:54 raspberrypi dhcpcd[760]: wwan0: removing default route via 100.64.35.177
Jul 26 00:37:55 raspberrypi ntpd[784]: Deleting interface #8 eth0, 169.254.153.193#123, interface stats: received=0, sent=0, dropped=0, active_time=131 secs
Jul 26 00:37:55 raspberrypi ntpd[784]: peers refreshed
Only wwan0 sharing is not working, If I replace with Wifi wlan0 it's immediately starts working. What could be the problem?
 
Old 07-27-2017, 11:23 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,522

Rep: Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224
Code:
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         setup.ubnt.com  0.0.0.0         UG    10     0        0 wlan0
default         100.64.35.177   0.0.0.0         UG    1000   0        0 wwan0
The Pi will use the gateway with the lowest metric.

Code:
dhcp-range=192.168.2.1,192.168.2.50,12h # Assign IP addresses between 172.24.1.50 and 172.24.1.150

eth0      Link encap:Ethernet  HWaddr b8:27:eb:2a:2a:0f  
          inet addr:172.24.1.1  Bcast:172.24.1.255  Mask:255.255.255.0
Although it appears dnsmasq dhcp server is working on eth0 192.168.2.0 subnet your comment and the output of the ifconfig command / interfaces file do not match.
 
Old 07-27-2017, 12:22 PM   #3
hpapagaj
LQ Newbie
 
Registered: Jul 2017
Posts: 3

Original Poster
Rep: Reputation: Disabled
michaelk,

YES, YES, YES. Your comment is helped me a LOT.

If I understand correctly eth0 (and clients behind them) basically trying to access gateway with lowest metric setup.ubnt.com, but they can't reach this gateway, because it's my internal network and we redirected request using iptables masquerade.

Again, default routing table:

Code:
$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default             setup.ubnt.com  0.0.0.0         UG    10     0        0 wlan0
default             100.64.213.33   0.0.0.0         UG    1000   0        0 wwan0
100.64.213.32   *               255.255.255.224 U     0      0        0 wwan0
192.168.1.0        *               255.255.255.0   U     10     0        0 wlan0
192.168.2.0        *               255.255.255.0   U     0      0        0 eth0
So If I remove setup.ubnt.com route for test:
pi@raspberrypi:~ $ sudo route del default gw setup.ubnt.com

It's immediately starts working.

Now my question is: how to set wwan0's gateway to eth0, because it's always changing (LTE services are dhcp).
 
Old 07-27-2017, 12:53 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,522

Rep: Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224
You can disable wlan0 so that it defaults to the wwan0.
You can configure the /etc/network/interfaces file and manually set the metric similar to this setup in the link below so that wwan0 has a lower metric than wlan0.

http://captainunlikely.com/blog/2013...ng-with-linux/
 
Old 07-28-2017, 02:20 AM   #5
hpapagaj
LQ Newbie
 
Registered: Jul 2017
Posts: 3

Original Poster
Rep: Reputation: Disabled
If it's possible I don't want to lose wlan0, that's why I don't want to disable. It is not possible to isolate wwan0<->eth0 and keep wlan0 at the same time? On rPi I have other stuffs as well which are using wlan0, but in the same time I want to use rPi as a kinda of LTE to LAN adapter. If I disable wlan0, I can use it only as a LTE to LAN adapter.
 
Old 07-28-2017, 09:44 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,522

Rep: Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224Reputation: 6224
You can only have one active gateway. Do not configure wlan0 as a route
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Openwrt and lte minipci modem (hp lt2523) riodda Linux - Hardware 0 04-09-2016 09:45 PM
Telephone usage through 3G/4G/LTE modem linuxbawks Linux - Networking 24 04-06-2015 06:45 AM
LTE Modem connected to two char devices tramsch Linux - Hardware 6 05-10-2014 03:00 AM
Can't get Verizon 4G LTE UML290 modem to work. steviebob Linux - Networking 2 06-16-2012 07:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration