Computing.Net > Forums > Linux > Internet sharing between 2 Linux PC

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Internet sharing between 2 Linux PC

Reply to Message Icon

Name: Sneha
Date: September 22, 2003 at 16:30:00 Pacific
OS: Debian Linux 3.0
CPU/Ram: P4 1.5 GHz
Comment:

Hi All,
I have 2 machines both running Debian Linux 3.0.
Right now, I have one of them connected to the internet through a cable modem.
Any ideas about how I can share internet access between two PCs.
I do have 2 NICs in one of the PCs.
Any help will be appreciated.
Thanks.




Sponsored Link
Ads by Google

Response Number 1
Name: Guido
Date: September 22, 2003 at 18:02:48 Pacific
Reply:

Configure and start squid as proxyserver on the machine who has direct acces to the internet. Tell the browser on the other machine to use proxyconnection (http port is configured in the configuration file at the server, the browser on the other machine also needs to know this, also don't close this port in your firewall if you have one inside your internal net).

Wouldn't be too surprised if squid is already waiting on your hardisk to be configured and started.

You might want to check out:

www.squid-cache.org

Other option is to do it by routing, at www.tldp.org howto's are available. Check the catagory network - routing/ip masquerading.


0

Response Number 2
Name: C_Legend
Date: September 23, 2003 at 00:54:19 Pacific
Reply:

Routing / IP Masquerading option:

Enter these 3 lines on the machine connected to the internet:

modprobe iptable_nat
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

(note: the 2nd line may be wrapping, as there's a space between "-j" and "MASQUERADE")

To make it more permanent, I enter them in a script I call "ipmasq" (due to the ip masquerading), then make it executable (chmod +x ipmasq), and then execute this in my /etc/rc.d/rc.local (may be different in debian) file so it will load upon boot.

On the other machine, simply make the above server your default route ("route add default gw 10.10.10.1 eth0", replacing 10.10.10.1 with your server's ip address).

That's it, and no need to mess with proxy settings in your browser or other internet software. Squid will work, but I think this is easier. The main advantage to using Squid is the caching, but will less useful with only 2 machines.

Note: I'm using Redhat 8, but this should work with any distribution with iptables and later 2.4 kernels. Use "ipfwadm" (2.0 kernel) or "ipfwadm-wrapper" (2.2 kernel) instead of iptables to port this solution to older distributions.

Good luck.


0

Response Number 3
Name: C_Legend
Date: September 23, 2003 at 00:59:02 Pacific
Reply:

Oops. You may need to modify that 2nd line (of the important 3) to be your ethernet interface (ie eth0) instead of "ppp0". I missed the "through a cable modem" portion of your post. Sorry.


0

Response Number 4
Name: Sneha
Date: September 24, 2003 at 11:30:46 Pacific
Reply:

A very basic question? how do i connect the 2 computers?
I have a cable going to the cable modem from the main 'server' machine.
Now, do i connect a crossover cable between the 2 machines?
Like I said before, my main 'server' machine has 2 NICs.
Thanks.



0

Response Number 5
Name: C_Legend
Date: September 24, 2003 at 19:21:08 Pacific
Reply:

Yes, you can do the crossover cable thing, or you can have both machines connect to a hub or switch, which would give you the option to add more machines in the future.

You could also have the cable modem connect to the hub/switch and then have the two (or more) computers also connected to the hub/switch, then you wouldn't have to have 2 NICs in the "server".


0

Related Posts

See More



Response Number 6
Name: Yohanes
Date: October 18, 2003 at 02:19:01 Pacific
Reply:

hi All,

I have some questions about Linux and Windows 2000.

I want to share my internet connection to my windows. Let says, i want to make my Linux as a server and my windows 2000 as a working station.

Before i share the internet, do i have to change the configuration of the network for both operating system ??

Second question, how can i share internet connection from Linux to Windows 2000 ??

Do you have any good and understanding refference for it ??

Thank you very much,

Yohanes


0

Response Number 7
Name: Yohanes
Date: October 18, 2003 at 02:20:38 Pacific
Reply:

Opps,

Sorry, i forget to put information the linux distribution that i have is Red Hat Linux 9.

thanks for your help.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: Internet sharing between 2 Linux PC

connecting 2 Linux PCs from GUI www.computing.net/answers/linux/connecting-2-linux-pcs-from-gui/16429.html

2 Linux flavors Boot problem www.computing.net/answers/linux/2-linux-flavors-boot-problem/10467.html

Internet Sharing Linux / Win2000 www.computing.net/answers/linux/internet-sharing-linux-win2000/4274.html