LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-03-2013, 02:50 PM   #1
klglhqcw
LQ Newbie
 
Registered: Oct 2013
Posts: 4

Rep: Reputation: Disabled
Manually sharing Internet connection with phone via USB


Hi.

I'm not a total newcomer to Linux, but to networking, with which I have a very small problem, it sadly is so.

I have a phone (SE J108i) which I want to use my PC's Internet connection via USB. The phone has that feature, and in fact, it works on Ubuntu, easily (auto)configured in its GUI according to this page I found:

http://kenyangeekboy.blogspot.com/20...son-w890i.html

Thing is, I use Slackware 14, and I'd rather not install any extra software for that purpose, GUI or not. So, my question is: how to enable that sharing on it manually (say, in a script) after I plug the phone in?

Here are the details of the connection on Ubuntu:

Ethernet (usb0)
hardware address: 02:80:37:ec:02:00
driver: cdc_ether
IP: 10.42.0.1
broadcast address: 10.42.0.255
subnet mask: 255.255.255.0
"IPv4 Settings: Shared to other computers"
(that line I believe might be the most important)

How can I recreate that manually? The furthest I found was that after
ifconfig usb0 10.42.0.1
I could ping 10.42.0.1 and the phone would respond. But I don't know what to do next. If I knew which files contain the relevant network settings, I could compare them between the systems, but I don't.

I'm sorry for such a direct request for such a small problem, but I'd really like to have that feature.

Thanks.

Last edited by klglhqcw; 10-03-2013 at 02:52 PM.
 
Old 10-03-2013, 04:00 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
If you are seeing your usb0 device, you should be able to run dhcpcd on that device, and have it use your phone as the gateway, and should be good. Once you get to the point where you can see usb0 in your ifconfig output, run "dhcpcd usb0", and check the output of the "route" command - you should see a reference to the gateway (phone)
 
Old 10-03-2013, 04:34 PM   #3
klglhqcw
LQ Newbie
 
Registered: Oct 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by corp769 View Post
have it use your phone as the gateway
But it's my PC that's the gateway, IIUC. It's it that provides the connection to the phone.

Besides, I'm not sure what DHCP has to do with anything. After the Googling I did today, I came to imagine that ifconfig can be used to provide the phone with the data that's normally provided with DHCP, as quoted in my first post. But I might be wrong here.

Meanwhile, here's the output of route and iptables -L (which I Googled might have to do with it, too) on Ubuntu, if it helps:
http://pastebin.com/ntZVczMZ

I'm trying to think of ways in which I could discover what the Ubuntu network manager is doing when I set the "Shared to other computers" option (which in fact is the only thing that I have to do manually for the sharing to work).

Oh, and one more thing: the live Ubuntu that I'm using actually has neither dhcpd nor dhcpcd installed at all. So whatever it does, it does without them.

Last edited by klglhqcw; 10-03-2013 at 04:44 PM.
 
Old 10-03-2013, 07:43 PM   #4
klglhqcw
LQ Newbie
 
Registered: Oct 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Also, I found

http://forum.xda-developers.com/show....php?t=2287494 ,

which basically says (claiming confidently that nothing more is needed)

sudo /etc/rc.d/rc.ip_forward start # i.e., echo 1 > /proc/sys/net/ipv4/ip_forward
sudo ifconfig usb0 10.42.0.1 netmask 255.255.255.0
sudo iptables -t nat -F
sudo iptables -t nat -A POSTROUTING -j MASQUERADE


Now, although my phone's OS isn't Android I think (which is the system that that guide assumes), the fact the IP address mentioned in it is the same that Ubuntu automatically assigns to the phone suggests that this might be close to what should be done. But it doesn't work (although in route output on Slackware there appeared a line identical to the line in Ubuntu's output from my previous post, only with metric = 0 instead of 1). Still, I'm posting it hoping that maybe it's missing something obvious, which somebody will point out.

(In fact, I made two changes; I replaced the penultimate line with
Quote:
sudo iptables -F
sudo iptables -X
sudo iptables -t nat -F
sudo iptables -t nat -X
, for a good measure, and the ultimate line with
Quote:
sudo iptables -t nat -A POSTROUTING -j MASQUERADE -o wlan0
sudo iptables -A FORWARD -j ACCEPT -i usb0
, a similar code that I found here on LQ, because the original broke my PC's Internet connection.

Last edited by klglhqcw; 10-03-2013 at 07:59 PM.
 
Old 10-04-2013, 02:29 AM   #5
klglhqcw
LQ Newbie
 
Registered: Oct 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Sorry for bumps.

Solved.

It appears, naturally, that you were right about DHCP being involved/invoked, corp769 - sorry for that.

I read Ubuntu logs and used ps to look for programs that its network manager runs in the background, and included them in my script. Here it is:

Code:
sudo /etc/rc.d/rc.ip_forward start

sudo ifconfig usb0 10.42.0.1 netmask 255.255.255.0

sudo iptables -t filter -F
sudo iptables -t filter -X
sudo iptables -t nat -F
sudo iptables -t nat -X

sudo iptables --table filter --insert INPUT --in-interface usb0 --protocol tcp --destination-port 53 --jump ACCEPT
sudo iptables --table filter --insert INPUT --in-interface usb0 --protocol udp --destination-port 53 --jump ACCEPT
sudo iptables --table filter --insert INPUT --in-interface usb0 --protocol tcp --destination-port 67 --jump ACCEPT
sudo iptables --table filter --insert INPUT --in-interface usb0 --protocol udp --destination-port 67 --jump ACCEPT
sudo iptables --table filter --insert FORWARD --in-interface usb0 --jump REJECT
sudo iptables --table filter --insert FORWARD --out-interface usb0 --jump REJECT
sudo iptables --table filter --insert FORWARD --in-interface usb0 --out-interface usb0 --jump ACCEPT
sudo iptables --table filter --insert FORWARD --source 10.42.0.0/255.255.255.0 --in-interface usb0 --jump ACCEPT
sudo iptables --table filter --insert FORWARD --destination 10.42.0.0/255.255.255.0 --out-interface usb0 --match state --state ESTABLISHED,RELATED --jump ACCEPT
sudo iptables --table nat --insert POSTROUTING --source 10.42.0.0/255.255.255.0 ! --destination 10.42.0.0/255.255.255.0 --jump MASQUERADE

sudo dnsmasq --conf-file --no-hosts --bind-interfaces --except-interface=lo --clear-on-reload --strict-order --listen-address=10.42.0.1 --dhcp-range=10.42.0.10,10.42.0.100,60m --dhcp-option=option:router,10.42.0.1 --dhcp-lease-max=50 --pid-file=/var/run/nm-dnsmasq-usb0.pid
(Only dnsmasq was originally run with --keep-in-foreground).

There surely are problems with that script, but I'll manage that now.

Last edited by klglhqcw; 10-04-2013 at 02:41 AM.
 
Old 10-04-2013, 12:20 PM   #6
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
It's all good! And cheers figuring it out!

Josh
 
  


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
sharing internet connection to usb phone djevilx Linux - Networking 0 04-15-2008 08:12 AM
problems with internet connection sharing via a usb modem Syathon Linux - Networking 6 03-31-2007 05:45 PM
USB Virtual Network Adapter Internet Connection Sharing Suse 10.2 and Windows, How??? tfm1 Linux - Networking 1 12-25-2006 03:41 PM
How to set up internet connection manually in FC5 jojojo Linux - Newbie 2 06-03-2006 11:27 AM
Internet connection sharing help...using USB modem & Network card Daz155HGT Linux - Networking 6 04-28-2004 02:44 PM


All times are GMT -5. The time now is 07:37 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration