Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old November 17th, 2005   #1
anaoum
Just Give Me the Beans!
 
Join Date: Jun 2005
Location: Australia
Beans: 81
Lightbulb

Hello,

The following will explain how to share your Internet connection:

Note: Type all the following commands in a root terminal, DO NOT use sudo.

1. Start by configuring the network card that interfaces to the other computers on you network:

# ifconfig ethX ip

where ethX is the network card and ip is your desired server ip address (Usually 192.168.0.1 is used)

2. Then configure the NAT as follows:

# iptables -t nat -A POSTROUTING -o ethX -j MASQUERADE

where ethX is the network card that the Internet is coming from

# echo 1 > /proc/sys/net/ipv4/ip_forward

3. Install dnsmasq and ipmasq using apt-get:

# apt-get install dnsmasq ipmasq

4. Restart dnsmasq:

# /etc/init.d/dnsmasq restart

5. Reconfigure ipmasq to start after networking has been started:

# dpkg-reconfigure ipmasq

6. Repeat steps 1 and 2.

7. Add the line "net.ipv4.ip_forward = 1" to /etc/sysctl.conf

# gedit /etc/sysctl.conf

8. Reboot. (Optional)

I hope this helps.

Good luck!

Last edited by anaoum; January 30th, 2006 at 12:33 AM.. Reason: update
anaoum is offline   Reply With Quote
Old November 17th, 2005   #2
Squirreli
First Cup of Ubuntu
 
Join Date: Nov 2005
Location: Finland
Beans: 2
Ubuntu Breezy 5.10
Re: Howto Share internet connection

By following your instructions (after a long while spent at the ages-old art of trial-and-error I got as far as this:

eth0 connects me to the Internet.
eth2 connects me to my winxp machine.
ping gets reply both ways and my winxp is hosting ftp server which is reachable.
winxp firewall is disabled (just in case)

Xp machine, however, does NOT reach Internet. Possible reason for this could be in the way I've set up the xp machine's networking. You did not give specifics as to how those should be set up, but I've tested both fixed ip and DHCP. Also, the networking adapters and cables im using are reliable... Any ideas?

-Squirreli

PS. I do have a slight virus problem on the XP machine's lsass.exe, but it connects to Internet just fine when there's no linux box between it and the Internet, so I don't believe that to be the trouble.
Squirreli is offline   Reply With Quote
Old June 13th, 2007   #3
spleecho
First Cup of Ubuntu
 
Join Date: Nov 2006
Beans: 2
Re: Howto Share internet connection

ok i spent hours trying to do all this, my situation is a bit more complicated, i use evdo card as my internet, can you please tell me how to undo all these settings for the ethernet interface?
thanks
spleecho is offline   Reply With Quote
Old November 18th, 2005   #4
anaoum
Just Give Me the Beans!
 
Join Date: Jun 2005
Location: Australia
Beans: 81
Re: Howto Share internet connection

Hello,

On your winxp machine configure it with a static ip (make it similar to the ip on your server. eg if server ip is 192.168.0.1, then make your ip 192.168.0.10). Also make sure that you set the "Default Gateway" and "Preffered DNS" to the ip on your ubuntu machine (the one that's sharing the internet connection). It should work fine after that.

Good luck

Last edited by anaoum; November 18th, 2005 at 05:50 PM..
anaoum is offline   Reply With Quote
Old November 18th, 2005   #5
Squirreli
First Cup of Ubuntu
 
Join Date: Nov 2005
Location: Finland
Beans: 2
Ubuntu Breezy 5.10
Re: Howto Share internet connection

Ha! Now it works.
Setting default gateway didn't help, but didn't do any harm either. Setting preferred DNS server did the trick... So, these XP comp tcp/ip settings made it work.
-fixed ip:192.168.0.1 (subnet mask 255.255.255.0)
-default gateway:192.168.0.2
-preferred DNS server:192.168.0.2

Paljon kiitoksia/Thank you very much

-Squirreli
Squirreli is offline   Reply With Quote
Old November 18th, 2005   #6
anaoum
Just Give Me the Beans!
 
Join Date: Jun 2005
Location: Australia
Beans: 81
Re: Howto Share internet connection

No worries. I'm glad it has helped!
anaoum is offline   Reply With Quote
Old December 4th, 2005   #7
nicholaspaul
A Carafe of Ubuntu
 
nicholaspaul's Avatar
 
Join Date: Jan 2005
Location: Calgary AB
Beans: 133
Ubuntu 9.04 Jaunty Jackalope
Send a message via MSN to nicholaspaul
Re: Howto Share internet connection

I'm having some fun with this -
set up is a PPC laptop that needs the internet from a x86 desktop (which gets the internet with ath0 , a wifi adapter, and is sharing with eth0), both running Breezy. Is it a matter of just changing Network settings?

So far, the laptop can ping x86 when static IP and DNS is set to the x86 IP (192.168.0.2), but cant get to the internet. Also x86 cant get to the internet while eth0 is activated .
Should I also change submasks?

PLUS when I restart dnsmasq I get :

Restarting DNS forwarder and DHCP server: dnsmasqstart-stop-daemon: warning: failed to kill 8006: Operation not permitted
rm: cannot remove `/var/run/dnsmasq.pid': Permission denied
dnsmasq: failed to bind listening socket: Permission denied
(failed to start).

I'm also using a crossover cable - thats right isnt it?
nicholaspaul is offline   Reply With Quote
Old December 4th, 2005   #8
anaoum
Just Give Me the Beans!
 
Join Date: Jun 2005
Location: Australia
Beans: 81
Re: Howto Share internet connection

Hello nicholaspaul,

Make sure that the subnet masks on your ppc are set to 255.255.255.0.

Also make sure that the Default Gateway on the ppc is set to the ip of the x86 (192.168.0.2)

About restarting dnsmasq, are you sure you are executing the command as root user?
anaoum is offline   Reply With Quote
Old April 30th, 2006   #9
mybers
First Cup of Ubuntu
 
Join Date: Nov 2005
Beans: 6
Re: Howto Share internet connection

Quote:
Originally Posted by anaoum
Hello,

On your winxp machine configure it with a static ip (make it similar to the ip on your server. eg if server ip is 192.168.0.1, then make your ip 192.168.0.10). Also make sure that you set the "Default Gateway" and "Preffered DNS" to the ip on your ubuntu machine (the one that's sharing the internet connection). It should work fine after that.

Good luck

Hello

Kinda still new on this so i hope ud help me as well on this.

Im connected to a wifi/DSL line with gives me a Dynamic IP to my ubuntu (internet sharing server). I followed the earlier post and it did installed everything i hope.

This Ubuntu PC connects to the internet nicely but my Winxp and other Linux PC wont have any access yet. Probably still having problems with what is the right settings I should set up on those workstations?

My eth1=connects to the DSL (set to DHCP), Default gateway
eth0= connects to the LAN network (set to DHCP)

what should I set in for the Winxp Lan card?
How can I get /validate the DNS server and or the Gateway?

Thanks a lot! hope this post is understandable...


mybers
mybers is offline   Reply With Quote
Old December 4th, 2005   #10
nicholaspaul
A Carafe of Ubuntu
 
nicholaspaul's Avatar
 
Join Date: Jan 2005
Location: Calgary AB
Beans: 133
Ubuntu 9.04 Jaunty Jackalope
Send a message via MSN to nicholaspaul
Re: Howto Share internet connection

Quote:
Originally Posted by anaoum

2. Then configure the NAT as follows:

# iptables -t nat -A POSTROUTING -o ethX -j MASQUERADE

where ethX is the network card that the Internet is coming from

# echo 1 > /proc/sys/net/ipv4/ip_forward
Oh wait a minute - should ethX be the interface that gets x86 the internet, or the one I'm sharing with?
nicholaspaul is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:11 AM.


vBulletin ©2000 - 2009, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry