Networking : how to bridge two NICs to share internet access ?

Guido Heumann listguido at web.de
Fri Aug 26 14:52:11 UTC 2005


Am Donnerstag, 25. August 2005 21:44 schrieb Vincent Trouilliez:
> Guys, thanks you very much for all the info, but I think I have gathered
> enough information to make my own decision now.
> You all seem very knowledgeable and you got too carried away in the
> complexity department !
>
>
> The only feature I (will) really NEED is to connect to my main desktop
> machine to back-up files at night on a head/keyboard/mouse less tiny
> slim case desktop linux box (hence will need SSH or something like that
> too I guess, to administer it) and possibly connect my laser printer to
> the network as well so I can free the parport of my main desktop
> machine, as I am going to need this port for something else. If I can do
> more than that, it will be fun, but not mandatory.
[...]

Hi Vince,

there is really a lot of good information in this thread, and I'm even going 
to add some more "noise" to it ;-) But I try to make a really minimalistic 
proposal...

For sharing your internet connection all you need is a crossover ethernet 
cable between your two PCs, and IP-forwarding and masquerading an your main 
machine. And the right IP gateway setting on the second machine:

- set the IP adress of the main machine's second NIC to 
192.168.0.1/255.255.255.0 

- on the second PC, set a fixed IP adress to 192.168.0.2 and the default 
gateway to the main machine's fixed IP, 192.168.0.1

on the main machine:

- activate IP forwarding:  
type "echo 1 > /proc/sys/net/ipv4/ip_forward" as root on the main
(this will get lost on next reboot, see /etc/network/options)

- activate IP masquerading for the dialup device: 
type "iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE" as root

That should be enough to reach the internet from the second PC. 
It's very basic and not "secure" and won't work after a reboot, but you see it 
doesn't need to be that complex ;-) 
I can also really recommend /usr/share/doc/iptables/README.Debian.gz, 
especially the intro and quickstart sections. 

And concerning your laserprinter plans, I think you have two options to free 
the parport on your main workstation: connect the printer to the now 
connected second PC's parport ;-), or buy a "printserver" box like e.g. one 
of the HP JetDirect series. 
The first doesn't cost any money, but you need to power on the second pc evry 
time you want to print something.
The printserver option is very nice and flexible, the printer will basically 
get it's own IP adress and NIC, and can operate "standalone". But it will 
cost some euros, even if second-hand.

Oh well, this mail got longer than the intended mini tip... Hope it helps 
though.

cheers,
Guido






More information about the ubuntu-users mailing list