OpenWrt Forum Archive

Topic: 3G to Ethernet Modem / Public IP Pass Through

The content of this topic has been archived on 6 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I have a NSLU2 that I would like to turn into a 3G Ethernet modem similar to how the Cradlepoint CBA250 (http://www.evdoinfo.com/content/view/2601/64/ & http://www.cradlepoint.com/products/cba … d-adapter) works.  I have been able to connect to the 3G network fine but I need to ability to pass the public IP address to whatever is connected to the Ethernet interface of the NSLU2.  Basically i want to turn a 3G USB modem into a 3G Ethernet modem and use a regular router to connect to the internet through the 3G network.  I don't want to do NAT twice.  I tried bridging but when connecting to the modem a ppp connection is created and you cant bridge between ppp and Ethernet.  Here is a graphical depiction of what I am trying to do:

KEY:
{name} - Internal device interfaces
[name]  - Network node
--          - Wired/wireless connection
||          - Switch internal to router

[PC1]--||
[PC2]--||--[{Router LAN/WiFi}--router--{Router WAN Port}]--[{eth0 of NSLU2}-NSLU2--{ppp0 to 3g USB modem}]--[internet]
[PC3]--||                ^                                         ^                                                                                   ^
                              |                                          |                                                                                    |
                              |                                          |                                                                                    |
                  NATed IP Addresses        Gets the Public IP Address the ppp0 interface would get on the NSLU2    |
                                                                                                                                                               |
                                                                                                                                           3G Modem Connection to ISP

The NSLU2 would pass the Public IP address received from the 3G ISP on to the WAN port of the router (Just like a modem would) and the router would be the firewall/NAT/DMZ etc.  I just want to pass the public IP address through the NSLU2 on to the router.  I know this sounds strange and off-the-wall but having something like this would create a very useful device for all kinds of situations.

Backup modem when cable/DSL is down
Mobile office Application
Outdoor events where internet is not available
High speed connectivity in areas where only dial up is available but 3G is avaliable (Farms and back wood areas)
Cable/DSL Replacement
Giving devices that have Ethernet but no USB port the ability to have 3G connectivity and a Public IP address (No NAT)

I can't believe that this is that strange, I would think that with all the Linux WAN devices out there that someone somewhere needed to pass the public IP address on to another device, am I wrong?  Older ADSL modems did something similar to this and called it half-bridge, ZIPB, DHCP Spoofing, IP Address Pass through.  I want to copy the functionality that the cradlepoint CBA250 using an NSLU2 so that I have an open source implementation because cradlepoint uses some goofy proprietary OS and I can't add stuff to.

Anyone got any Idea's.  I am stumped and could use some advice.  I am willing to write code to get it to work, i just don't know where to start.

I've been interested in doing this for a while now as well. I've been trying some things and I've gotten close. If I figure it out I'll post back here.

(Last edited by aport on 11 May 2009, 21:31)

Bonding or bridging?  Bonding is where 2 interfaces are tied together and if one fails the other switches over and aliases the other interfaces IP address so that traffic doesn't stop.  I would like to bridge but it is simply not possible.  As was stated by aport DSL modems do this (to a point, mostly older models, new models use PPPoE).  I can't seem to find much information on how the DSL modem actually configured this.  I have seens discussion with older kernels where bridging between PPP and Ethernet was possible but it seems that that patches have since vanished into thin air and they did not accept them in the 2.6 kernel at all.  Like I said I really don't have an issue writing the code, I just don't know where I would even start.

I just don't get why this is such a difficult task, i would think many people would want to do something of this nature.  It sure would be a handy device to have around the house, sometimes you just need a backup internet connection, what better way than to also have a device that could be used with your laptop.  I really need this because my network is always going up and down, they are doing construction and my internet connection is constantly going up and down because of the construction.  My router doesn't have a USB port and I really cant afford a new one.  I have an NSLU2 that I am not using and I think it should do what I want it to do.  Since the cradlepoint can do it, Linux should be able to do it.

watts, I have this working. It was fairly straightforward to do. The only thing I haven't done yet is to get dnsmasq to serve up the WAN IP and gateway to one client.


ifconfig ppp0 0.0.0.0
route add -net $WANIP netmask 255.255.255.255 dev br-lan
route add default ppp0
route add -host $GATEWAY dev ppp0
echo "1" > /proc/sys/net/ipv4/conf/ppp0/proxy_arp
echo "1" > /proc/sys/net/ipv4/conf/br-lan/proxy_arp

Then I assign my laptop the WAN IP and GW from the ppp connection and bam, I'm online. I've tested on Sprint and AT&T so far.

aport,

I got it working but did it slightly differently.  Instead of using 0.0.0.0 for the ppp0 interface I instead stripped the IP address off resulting in no IP address on the interface using iproute2.  I did all of my routing tables based on interfaces rather than IP addresses.  Give that a try and see if this helps with the DNS issues.  I had no problems resolving the IP addresses for google and other sites and did not need to make any additional changes in order for it to work. I was doing funky stuff.  The "3G Modem" did not have any IP addresses on any interface at all resulting in a device that is virtually undetectable on the network.  On the router I have 2 network interfaces, one is my primary the other (Connected to 3g) is a fail over and I bonded the 2 network interfaces for fail over.  If I have a route go down it automatically switches all of my routing tables toe the 2nd set of routing tables and uses the fail over interface for Internet access.  I have several hard coded DNS entries and since proxy ARP is enabled it doesn't matter what the router does for DNS, it will always go over 3G in this case and the routers on whatever network will handle DNS for me.

watts wrote:

aport,

I got it working but did it slightly differently.  Instead of using 0.0.0.0 for the ppp0 interface I instead stripped the IP address off resulting in no IP address on the interface using iproute2.  I did all of my routing tables based on interfaces rather than IP addresses.  Give that a try and see if this helps with the DNS issues.  I had no problems resolving the IP addresses for google and other sites and did not need to make any additional changes in order for it to work. I was doing funky stuff.  The "3G Modem" did not have any IP addresses on any interface at all resulting in a device that is virtually undetectable on the network.  On the router I have 2 network interfaces, one is my primary the other (Connected to 3g) is a fail over and I bonded the 2 network interfaces for fail over.  If I have a route go down it automatically switches all of my routing tables toe the 2nd set of routing tables and uses the fail over interface for Internet access.  I have several hard coded DNS entries and since proxy ARP is enabled it doesn't matter what the router does for DNS, it will always go over 3G in this case and the routers on whatever network will handle DNS for me.

watts,


That sounds like a very robust solution. The problem I am having is that I want the "3G Modem" to assign the client the WAN IP of the datacard via DHCP. I can't get it to do that because dnsmasq (the DHCP server) complains that the IP is outside the network it's servicing...


Are you statically assigning your router the IP address of the 3G card, or is your NSLU2 giving the router the IP via DHCP?



I assume you have some sort of script handle the setup of this? Would you mind posting it?
Thanks!

(Last edited by aport on 30 Oct 2009, 01:03)

I had a very specific configuration where I receive a static IP address from the ISP using a dedicated APN (Access Point Name, a partition of the cellular network) from the ISP for my company.  You might be able to have your ISP assign you a static IP address for a small additional fee a month ($5 - $10)  This gave me the ability to hard code stuff and not have an issue with this sort of thing.  Having a dynamic IP address really makes things a bit more difficult and I can see your issue.  You will want to lookup how to do boned network interfaces as it is an involved process if you want to do a fail over.  There are lots of tutorials on how to do this.

I got laid off from the company I was working on this for (I got a new job that pays better cool) and no longer have access to hardware I was working with.  This should be what I did, sorry if it isn't perfect, it has been a few months since I did it.  I wish I submitted it here before that faithful day:

ip addr flush dev ppp0 # strip the IP address
ip route add default via dev $PPP_PHY #access the world via the ppp0 interface interface
ip route add $WANIP/$NETMASK via dev $LAN_PHY # access your IP via yur lan 
echo "1" > /proc/sys/net/ipv4/conf/$LAN_PHY/proxy_arp # enable ARP_PROXY on your lan interface

take a close look at the Linux Advance Routing and Traffic Control tutorials for specifics, dig deep as this is not very well documented but is in there.  This is part thinking beyond typical routing rules and part voodoo routing magic.  Think policy based routing over regular routing, use iproute2 over route...route is nowhere near as powerful as iproute2.

http://lartc.org/

You really do not need to do proxy arps on the PPP interface.  PPP connection is a direct link to the ISP and you should only need to throw the frame out there and the ISP's routers should just take care of the rest.  That is the whole point of a PPP connection.  There are no arps over PPP as it is not Ethernet.  It is strictly a routing issue.  By striping the IP address off the PPP interface and do interface based routing you should not have any issues with DNS.  using static DNS services should fix these issues.  Look at your resolve.conf file on the laptop, overriding this might help solve your issue. 

You might be able to write a script that reads the PPP interface before striping the IP address and serve the IP via DHCP to your laptop.  Once you obtain an IP from the ISP you should keep it until a reboot/disconnect, again this is how the ISP does things...they should not change your IP once the PPP link is established as PPP has no way of dealing with this.

(Last edited by watts on 30 Oct 2009, 03:49)

OpenWRT makes this process a bit easier since it stores the WAN IP and gateway of the ppp connection in /var/state... so I can strip the IP all day long off the iface without worrying about forgetting the IP. My device has a dynamic IP though honestly I'd want the DHCP solution regardless. Call it "problem solving just because." big_smile


And congrats on the new job!

The discussion might have continued from here.