inTheDMZ Posted February 14, 2013 Share Posted February 14, 2013 Why: Because I'm lazy and Don't want to write it myself! I noticed when the pineapple has a usb0 device (android phone) it automatically adjusts its iptables rules to use this at the gateway to the internet. Wondered if i could have this script so i can use it on a personal project. Background for those who are interested: I have a internet connection with Virgin Media, which constantly drops out. I also have unlimited teathering on my Galaxy S3 with ThreeUK, so want to be able to plug it into my WR1043N and have it automatically foward all traffic over the usb0 connection. I want to also edit the script so when usb0 is removed the WAN ethernet port is once again used as the internet access gateway. Many Thanks, IntheDMZ Quote Link to comment Share on other sites More sharing options...
Foxtrot Posted February 14, 2013 Share Posted February 14, 2013 Lol, have you tried researching how the pineapple does it? -Foxtrot Quote Link to comment Share on other sites More sharing options...
inTheDMZ Posted February 14, 2013 Author Share Posted February 14, 2013 (edited) Looked at the Github repository for a script but think it may be beyond the webui! edit: Don't have my pineapple with me at the moment so will have a look on it when I get hold of it again, unless anyone else knows how it does it? Edited February 14, 2013 by inTheDMZ Quote Link to comment Share on other sites More sharing options...
Foxtrot Posted February 14, 2013 Share Posted February 14, 2013 Looked at the Github repository for a script but think it may be beyond the webui! edit: Don't have my pineapple with me at the moment so will have a look on it when I get hold of it again, unless anyone else knows how it does it? I'll start looking for it soon Help a brother out! -Foxtrot Quote Link to comment Share on other sites More sharing options...
inTheDMZ Posted February 14, 2013 Author Share Posted February 14, 2013 Many Thanks! Quote Link to comment Share on other sites More sharing options...
Foxtrot Posted February 14, 2013 Share Posted February 14, 2013 Okay, just done some poking around and i couldn't find any .sh (I'm presuming it would be a .sh), however looking on the OpenWRT Forums, i think that the switch might be made by usb-modeswitch. -Foxtrot Quote Link to comment Share on other sites More sharing options...
inTheDMZ Posted February 15, 2013 Author Share Posted February 15, 2013 Thanks for the heads up, if my research is correct then usb modeswitch is used mainly to switch a usb 3G stick with a sd card from a 'external hard drive' to a '3G modem'? Quote Link to comment Share on other sites More sharing options...
Sebkinne Posted February 15, 2013 Share Posted February 15, 2013 First, you will need to set up a USB0 Interface. See the pineapple's /etc/config/network file: config interface usb option ifname usb0 option proto dhcp post-up sh /path/to/iptables/script.sh To be able to do this you WILL need to have the appropriate driver installed. Then, you will need to run these IPtable commands (or put them in a script to automate with the above post-up): iptables -t nat -A POSTROUTING -s 172.16.42.0/24 -o usb0 -j MASQUERADE iptables -A FORWARD -s 172.16.42.0/24 -o usb0 -j ACCEPT iptables -A FORWARD -d 172.16.42.0/24 -m state --state ESTABLISHED,RELATED -i usb0 -j ACCEPT Of course, you will need to adjust these to your liking.. Quote Link to comment Share on other sites More sharing options...
inTheDMZ Posted February 15, 2013 Author Share Posted February 15, 2013 Cheers Seb, Am I correct in saying the pineapple automatically detects usb0 and sets up iptable rules according? Quote Link to comment Share on other sites More sharing options...
Sebkinne Posted February 15, 2013 Share Posted February 15, 2013 Cheers Seb, Am I correct in saying the pineapple automatically detects usb0 and sets up iptable rules according? Actually not right now but it will in 2.8.0. You can fulfil that requirement by having a postup part in your network config. I have edited my previous reply. Quote Link to comment Share on other sites More sharing options...
inTheDMZ Posted February 15, 2013 Author Share Posted February 15, 2013 'postup' - my google keyword! Cheers Seb! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.