PDA

View Full Version : [ubuntu] Internet sharing issue



gegadeath
March 13th, 2009, 08:09 PM
Hi everybody,

I'm new to this forum and need your help. I have a laptop with ubuntu connected to internet via Wifi and I have another desktop one with windows on it. Could you please show me how to share internet with the windows one via ethernet. Thanx in advance guys !

puppywhacker
March 13th, 2009, 09:52 PM
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sysctl -w net.ipv4.conf.all.forwarding=1
iptables-save

gegadeath
March 14th, 2009, 09:52 PM
Hi, thanx for your response
I did what you suggest and I unfortunately lost my wifi connexion. In other words the wifi gets connected but can't browse internet or access my router's interface
Can you react towards that please?
otherwise, could you please show me how to cancel the configuration you gave me.
thanx inadvance !!!

puppywhacker
March 14th, 2009, 11:08 PM
the iptables masquerading will not loose your internet connection. if you face problems it must be related to something else

flushing the firewall tables can be done like this:


iptables -F
iptables-save

if this solves your issue you are probably having troubles with the firewall rules from firestarter.

gegadeath
March 15th, 2009, 11:48 PM
Thanx for ur fast reply man !

I was obliged to reinstall ubuntu due to another technical problem.my internet connection is working again.now.

Thanx for the help anyway !

gegadeath
March 16th, 2009, 02:43 PM
hello i'm sorry for showing up again ;)

I managed somehow to connect to my router's interface from my XP computer.
The problem is once the ethernet cable is plugged in I can't browse internet, I find it strange that I can access the router's interface on both computers but no internet on both of them though :(

I need your help ! please reply !

P.S : I'm using firestarter

puppywhacker
March 16th, 2009, 05:12 PM
Connecting to your adslmodem means that you have to set the ip-address of the client in the same range as your adslmodem. This will also automatically create a route to the adslmodem. This works because the network is on the same link.

The internet is beyond your router and your clients need to learn that, so either statically you define the ip-address and the default route and the dns resolving. Or you can let it assign automatically using DHCP.

Situations differ per setup. post your network confiugrations and we can think of a solution


ifconfig
route -n
cat /etc/resolv.conf

gegadeath
March 16th, 2009, 05:22 PM
Hello thnx for ur reply; here is my conf :

ifconfig :


ath0 Link encap:Ethernet HWaddr 00:23:4d:64:21:01
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::223:4dff:fe64:2101/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:36100 errors:0 dropped:0 overruns:0 frame:0
TX packets:17973 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:34822870 (34.8 MB) TX bytes:3292855 (3.2 MB)

eth0 Link encap:Ethernet HWaddr 00:1d:72:7f:e8:65
inet6 addr: fe80::21d:72ff:fe7f:e865/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:534 errors:0 dropped:172758917 overruns:0 frame:0
TX packets:785 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:61749 (61.7 KB) TX bytes:512518 (512.5 KB)
Interrupt:220 Base address:0x4000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:20055 errors:0 dropped:0 overruns:0 frame:0
TX packets:20055 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1362481 (1.3 MB) TX bytes:1362481 (1.3 MB)

wifi0 Link encap:UNSPEC HWaddr 00-23-4D-64-21-01-00-00-00-00-00-00-00-00-00-00
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:113845 errors:0 dropped:0 overruns:0 frame:6361
TX packets:22162 errors:89 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:280
RX bytes:26361875 (26.3 MB) TX bytes:3886007 (3.8 MB)
Interrupt:17


route -n :


Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 2 0 0 ath0
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 ath0

cat /etc/resolv.conf :


# Generated by NetworkManager
nameserver 192.168.1.1

hope this helps u helping me lol. waiting for ur reply ;)

PS : commands were typed without plugging the ethernet cable in.

puppywhacker
March 16th, 2009, 05:53 PM
ok, so your wireless gets the address 192.168.1.2 and default route points to your adslmodem at 192.168.1.1

I guess that when you connect the ethernet cable it will also be configured. But since the wireless was configured first it will remain the default route.

can you
1. connect the ethernet and do the same printouts
2. experiment by right-clicking the network icon on the right-top and disabling wireless and enabling it again (this should make ethernet the default route)
3. experiment with the firestarter down
4. explain again your network setup, because I'm slightly confused e.g. is it like this:

winxp wired_____
|___ adslmodem as ethernet switch
ubuntu eth0____|
ubuntu ath0____
|___ same adslmodem but now wireless ____ to internet

gegadeath
March 16th, 2009, 06:29 PM
Hello thnx for ur reply; here is my conf with the ethernet cable connected:

ifconfig :


ath0 Link encap:Ethernet HWaddr 00:23:4d:64:21:01
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::223:4dff:fe64:2101/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:39564 errors:0 dropped:0 overruns:0 frame:0
TX packets:19553 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:38846060 (38.8 MB) TX bytes:3488335 (3.4 MB)

eth0 Link encap:Ethernet HWaddr 00:1d:72:7f:e8:65
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::21d:72ff:fe7f:e865/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:577 errors:0 dropped:192426534 overruns:0 frame:0
TX packets:819 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:68035 (68.0 KB) TX bytes:517142 (517.1 KB)
Interrupt:220 Base address:0x4000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:20083 errors:0 dropped:0 overruns:0 frame:0
TX packets:20083 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1364193 (1.3 MB) TX bytes:1364193 (1.3 MB)

wifi0 Link encap:UNSPEC HWaddr 00-23-4D-64-21-01-00-00-00-00-00-00-00-00-00-00
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:152588 errors:0 dropped:0 overruns:0 frame:7457
TX packets:25458 errors:91 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:280
RX bytes:31465961 (31.4 MB) TX bytes:4197951 (4.1 MB)
Interrupt:17

route -n :


Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 2 0 0 ath0
192.168.0.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0

cat /etc/resolv.conf :


# Generated by NetworkManager
nameserver 192.168.1.1


I'll explain to you the connection i have :



Ubuntu Laptop(via wifi) <_________ Adsl Router (internet soource)
|
|
|
Xp Desktop (via ethernet)

Hope the view's quite clear now. Waiting for ur reply ! thnx !

puppywhacker
March 16th, 2009, 06:58 PM
The situation is now perfectly clear to me. Ubuntu changes the default route towards the Windows xp machine and that is why it can't connect to the internet anymore, but can still connect to the router at 192.168.1.1


Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 2 0 0 ath0
192.168.0.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
(should have been 192.168.1.1)

The thing is that by magic eth0 gets the ip-address 192.168.0.1 and the default gateway becomes 192.168.0.1 reachable over the ethernet as well. This is where the voodoo goes wrong, since routes to yourself are loops. (much like a dog chasing its own tail) You have to configure the eth0 as static in the NetworkManager. You can do the same (assign ip-address) in windows as well. In windows also add the default gateway to point to ubuntu.


______________ ___________________________ _____________
windows xp | | ubuntu | | adslmodem
wired |----| eth0 ath0 |---|
192.168.0.2 | | 192.168.0.1 192.168.1.2 | | 192.168.1.1
gw 192.168.0.1| | gw 192.168.1.1 | |
______________| |___________________________| |____________


and when you can connect from one side to the other you can give masquerading another shot

iptables -t nat -A POSTROUTING -o ath0 -j MASQUERADE
iptable-save
sysctl -w net.ipv4.conf.all.forwarding=1

gegadeath
March 16th, 2009, 10:14 PM
I'm so sorry for bothering you with this but the situation has become worse. I followed the steps very carefully but I only can connect to the routers setup page on both computers. and there is no internet on the ubuntu's computer even with disconnected ethernet.

Thanx for ur reply buddy !

Save.Our.Souls

gegadeath
March 17th, 2009, 02:24 PM
Hello, good news good people !

I managed to configure internet sharing following this tutorial :

http://ubuntuforums.org/showthread.php?t=713874

Thanks a bunch for your help; I appreciate it buddy ;)