Hi Sanjeev,

First of all, please do not piggyback old threads. Always start a new 
discussion if the topic is different. The reason is that people do not 
necessarily follow each post and only follow according to the subject line. Now 
onto your problem.

On Thursday, 26 June 2008, sanjeev shrestha wrote:

> Can any one help me?
> 
> I have 2 PCs here at home, I use Ubuntu and my sister uses windows, I
> want
> to share the internet connection from ubuntu to the PC running
> windows.

So, your setup is ISP<->modem<-cable->Ubuntu<-cable->windows if I got that 
right?
 
Can you tell me which is external and internal network? For e.g., eth0 is your 
external connected to ISP and eth1 is your private LAN (windows box)?
 
> Though I found a tutorial that taught to share the internet
> connection, I
> could not fix the problem
> 
> Here is what I tried on terminal
> 
> # sudo ifconfig eth1 192.168.1.1

Yup.

> # sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Before setting up masquerade, I recommend you to flush (iptables -F), enable 
nat and forwarding in your interfaces and start fresh.

There are few iptables rules and modules you need to be aware of before 
masquerading. Take a read at 
http://newbiedoc.sourceforge.net/networking/homegateway.html

> # sudo apt-get install dnsmasq ipmasq

Yes sir! that is correct. dnsmasq can be used instead of bind and on top of 
that it also provides dhcp to your client computers (in your case I assume MS 
windows) in your home network.
 
> # sudo /etc/init.d/dnsmasq restart

Try to fire up a network protocol analyser (keepin it handy is always a wise 
idea). One good one I use is tcpdump which you dump to ethereal/wireshark for 
investigating the problem further but a good way is just use command line:
$ sudo tcpdump -i any -p -n EXPRESSION
where EXPRESSION can be such as 'not src ip a.b.c.d' for example. More info is 
tcpdump man page.


> # sudo dpkg-reconfigure ipmasq

On my network, I never use ipmasq. I use only iptables and go straight for 
static IPs in clients (for e.g., windows) and the gateway (for e.g., ubuntu). 
On any client, you need make sure you you set the gateway,netmask and DNS 
correctly. The gateway is usually the ubuntu box's internal interface address 
for simple home networking and dns can set be your ISP dns or the ubuntu box IP.
 
> and then again
> 
> # sudo ifconfig eth1 192.168.1.1

Why is eth1 192.168.1.1 as well? If this is internal LAN, it should have 
different IP address. For e.g., you could have it as 10.1.1.1 (which IANA 
allows for private IP such as home networking) and is usually blackholed at 
border gateways and your external IP as 192.168.1.101 that is available from 
your router (the route that connects to your ISP).

> # sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Go through http://newbiedoc.sourceforge.net/networking/homegateway.html. This 
was the article I started with some winter back.

> Added the line "net.ipv4.ip_forward = 1" to /etc/sysctl.conf

Yes. That's correct. You can change it dynamically via 
/proc/sys/net/ipv4/ip_forward (by doing " echo 1 > /proc/sys/net/ipv4/ip_forwar 
") but at the moment it is fine also.
 
> And rebooted.

No need to reboot for Ubuntu box. Reboot for MS Windows should also be not 
needed.

> Still I could not share the internet.

Also, there is a seperate proper mailing list for Ubuntu discussion - [EMAIL 
PROTECTED] and [EMAIL PROTECTED] Have a look @ http://wiki.ubuntu.org.np and 
http://wiki.ubuntu.com.

Goodluck and always post a new thread how it goes. Please do not piggyback old 
one. :)

-- 
cheers
#define HIGH 0xcoffee

Attachment: signature.asc
Description: Digital signature

Reply via email to