how can I share my phone internet at local network?

2

I have a wi-fi router, a linux machine (ubuntu) a Mac, and an iPhone. The router has the address 192.168.1.1, the ubuntu machine connect to that with ethernet (192.168.1.2) and the Mac connect to the router via Wi-fi (192.168.1.6.). Netmask is 255.255.255.0.

I share the 3G internet from the iPhone to the Mac via USB, and want to share it to the ubuntu machine too.

How can I do this ? route command output on ubuntu

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         router          0.0.0.0         UG    0      0        0 eth0
link-local      *               255.255.0.0     U     1000   0        0 eth0
192.168.1.0     *               255.255.255.0   U     1      0        0 eth0

ifconfig output is

eth0      Link encap:Ethernet  HWaddr 00:1d:60:93:bb:bb  
          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21d:60ff:fe93:bbbb/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:113 errors:0 dropped:0 overruns:0 frame:0
          TX packets:126 errors:0 dropped:0 overruns:0 carrier:1
          collisions:0 txqueuelen:1000 
          RX bytes:14751 (14.7 KB)  TX bytes:19834 (19.8 KB)

kissgyorgy

Posted 2011-10-28T23:17:51.930

Reputation: 612

Answers

1

First, configure the Mac share the internet connection.

Then, simply configure the default route (either on the router or the Ubuntu machine) to be the Mac. On the Ubuntu machine, enter the following in the shell:

sudo route del default
sudo route add default gw 192.168.1.6

You may also want to adapt the address of the DNS server. Use the following to set it to google's:

echo nameserver 8.8.8.8 | sudo tee /etc/resolv.conf

phihag

Posted 2011-10-28T23:17:51.930

Reputation: 2 557

@KissGyörgy First, keep your calm and don't panic. Disabling the internet sharing and running ifdown eth0 && ifup eth0 on the Ubuntu machine will restore the old state. Make sure you share the correct connection. Before you typed anything on the Ubuntu machine, could you still connect to the Mac, for example via ping? – phihag – 2011-10-29T00:04:55.127

I cannot log in to the ubuntu machine after I set up Internet sharing on the mac. (no screen on that machine) – kissgyorgy – 2011-10-29T00:23:16.943

@Walkman Are you configuring your Ubuntu machine via ssh from the Mac? If so, that's a pretty important detail you should have included in the question. What is the Mac's routing table before/after you enable internet sharing? – phihag – 2011-10-29T00:27:48.780

here is my local network: https://cacoo.com/diagrams/VcBnZIl1GB3EDsGv

– kissgyorgy – 2011-10-29T00:37:49.500

yes, I manage it via ssh. here are routing tables for Mac. http://pastie.org/2776130

– kissgyorgy – 2011-10-29T00:44:30.693

@Walkman If I'm reading these tables right (Is that the output of route or ip route?), the dropped route to 192.168.1.2 should have no effect, but is also not necessary for connection sharing. You may want to contact the experts over at http://apple.stackexchange.com/ .

– phihag – 2011-10-29T00:52:38.513

I cant even stop sharing from mac settings. It stays checked all the time... I have to restart because ifconfig en1 down and up dont do the trick... – kissgyorgy – 2011-10-29T00:52:57.420

its from netstat -nr – kissgyorgy – 2011-10-29T00:54:08.433

@Walkman If you can't stop sharing the network while you're sitting in front of the Mac, it's definitely a bug in OS X. Ask on http://apple.stackexchange.com why that's the case.

– phihag – 2011-10-29T01:00:14.213