You are not logged in.

#1 2010-04-03 14:51:05

davidlondonuk
Member
Registered: 2009-06-24
Posts: 49

sharing wifi connection with lan? [solved]

Hi,

I am changing isps so at the moment i don't have an adsl connection.

I can get internet on my laptop using a netgear wifi card which connects to my landlords wifi, my laptop also has a NIC: so I have internet on wlan0 (10.0.0.0) and eth0 which is on a 192.168.0.0 network.

The eth0 interface is connected to a netgear router here's a little picture:

      LAPTOP---eth0 wired (192.168.0.2)-----NETGEAR ROUTER-----UBUNTU SERVER(fixed ip 192.168.0.100)
           |
           |
   NETGEAR WIFI CARD
        wlan0 internet on  10.0.0.0 network

I am trying to share the laptops internet connection via the wifi card with my internal net which in this case is the ubuntu server. I have configured my firewall to do NAT and share laptops wlan0 internet with internal lan on 192.168.0.0 network.

It's not working. I can access the internal network eg I can ssh into the ubuntu server but the server cannot access the internet?

Is this possible or have I just gone wrong somewhere?

Thanks for any help

SOLVED:

Thanks guys, what confused me was that I could not connect to some sites using dyndns but when I just tried updating the ubuntu server it had a connection. Changing the gateway on ubuntu to 192.168.0.2 did work after all.

Last edited by davidlondonuk (2010-04-04 15:02:54)

Offline

#2 2010-04-03 16:16:02

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,822

Re: sharing wifi connection with lan? [solved]

Some thoughts.  Can you ping 192.168.0.100 from the laptop?
Can you ping 192.168.0.2 from Ubuntu?
What is the default gateway on Ubuntu? (I'll bet it's 192.168.0.1, not 192.168.02)

If so, problem may be the router.  It does not know which of its ports leads to the internet --They usually have one port dedicated to connection to the "Internet" (i.e. the device provided by your ISP).  You may be able to tell it to use 192.168.0.2 as that path, but many home routers don't have that versatility.


You could try plugging the dedicated Internet port of the router into the laptop, and then configuring the router to used a fixed 192.168.0.x external address.  This would allow packets from Ubuntu to find their way to the Internet via NAT on the laptop. 

If you needed to communicate from the laptop to Ubuntu, you will need to open holes in the router firewall (since Ubuntu is now behind the router's firewall).  For your purpose, the easy solution might just be to configure to set up a DMZ for the Ubuntu machine's address.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2010-04-03 16:26:27

arch0r
Member
From: From the Chron-o-John
Registered: 2008-05-13
Posts: 597

Re: sharing wifi connection with lan? [solved]

here is a script i found some time ago on the arch forums. it shares wlan0 to eth0:

#!/bin/bash
# Shares internet from wlan0 through eth0

case "$1" in 
    start)
ifconfig eth0 up
ifconfig eth0 192.168.0.1
iptables --table nat --append POSTROUTING --out-interface wlan0 -j MASQUERADE
iptables --append FORWARD --in-interface eth0 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
echo "set other computers in the range of"
echo "192.168.0.0 255.255.255.0"
echo "gateway 192.168.0.1"
echo "dns 192.168.10.1"  #this is my router's ip, you should use yours or another dns server
;;
    stop)
echo 0 > /proc/sys/net/ipv4/ip_forward
ifconfig eth0 down
iptables --table nat --delete POSTROUTING --out-interface wlan0 -j MASQUERADE
;;
    *)
echo "usage: $0 {start|stop}"
;;
esac

I hope it will help you :>

Offline

#4 2010-04-03 18:49:01

davidlondonuk
Member
Registered: 2009-06-24
Posts: 49

Re: sharing wifi connection with lan? [solved]

Thanks for the reply guys,

The laptop is running arch (of course).

The router is a netgear 4 port adsl modem/router which is set to 192.168.0.1 so at the moment the setup is:

laptop wifi card on wlan0 network is 10.0.0.0 gets the internet

laptop eth0 wired connection to router ip is 192.168.0.2
ubuntu server eth0 wired connection to router with fixed ip of 192.168.0.100 and gateway 192.168.0.1

router ip address is 192.168.0.1 which makes sense if it is the gateway?

I have turned off the routers dhcp server and set arno's iptables firewall on laptop to do NAT masquerade for internal lan (laptop eth0 and ubuntu eth0 both wired to the router) via laptop wlan0.

Ubuntu can ping the laptop
laptop cannot ping ubuntu- yet I can ssh into the server from the laptop.

Offline

#5 2010-04-03 21:06:42

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,822

Re: sharing wifi connection with lan? [solved]

I think that the problem is that the gateway for Ubuntu needs to be 192.168.0.2

Edit: fixed typo

Last edited by ewaller (2010-04-03 21:07:36)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#6 2010-04-04 08:10:41

davidlondonuk
Member
Registered: 2009-06-24
Posts: 49

Re: sharing wifi connection with lan? [solved]

Hi,

I tried changing ubuntu gateway to 192.168.0.2 but still not working also tried the script above (after changing settings in firewall and restarting) didn't work. I must admit to being a bit stumped.

I can access sites on the server like web accounts eg http://192.168.0.100/whatever but nothing on the net. I can ssh into the server-the NAT masquerading should be working but I have made a mistake somewhere.

Thanks for the help though.

Offline

#7 2010-04-04 11:43:07

davidlondonuk
Member
Registered: 2009-06-24
Posts: 49

Re: sharing wifi connection with lan? [solved]

Hi,

I was wondering what to set in the router. At the moment it is set to get an ip from my old ISP but that won't work anymore-I have unpluged the adsl. I can also set a paswordless config either dynamic or fixed-the fixed option has a gateway entry box.

The wlan0 gateway is 10.128.128.128 and this is the entry in the arch laptop resolv.conf.

How do I get the router to see the right gateway?

Thanks for any ideas.

Offline

Board footer

Powered by FluxBB