* The machine acting as server should have an additional network device

* The machine acting as server should have an additional network device

−

* That network device should be connected to the machines that are going to receive internet access. They can be one or more machines. To be able to share internet to several machies a [[Wikipedia:Network switch|switch]] is required. If you are sharing to only one machine, a [[Wikipedia:Ethernet crossover cable|crossover cable]] is sufficient

+

* That network device should be connected to the machines that are going to receive internet access. They can be one or more machines. To be able to share internet to several machines a [[Wikipedia:Network switch|switch]] is required. If you are sharing to only one machine, a [[Wikipedia:Ethernet crossover cable|crossover cable]] is sufficient

{{Note|If one of the two computers has a gigabit ethernet card, a crossover cable is not necessary and a regular ethernet cable should be enough}}

{{Note|If one of the two computers has a gigabit ethernet card, a crossover cable is not necessary and a regular ethernet cable should be enough}}

Revision as of 15:55, 7 May 2013

This article explains how to share the internet connection from one machine to other(s).

Contents

Requirements

The machine acting as server should have an additional network device

That network device should be connected to the machines that are going to receive internet access. They can be one or more machines. To be able to share internet to several machines a switch is required. If you are sharing to only one machine, a crossover cable is sufficient

Note: If one of the two computers has a gigabit ethernet card, a crossover cable is not necessary and a regular ethernet cable should be enough

Configuration

Using Udev#Setting static device names, name the network device connected to the other computer(s) as net0 and the network device connected to the internet as internet0.

Static IP address

Assign an static IPv4 address to the interface connected to the other machines. The first 3 bytes of this address cannot be exactly the same as those of another interface.

You can figure out the address of the nameserver by looking into the /etc/resolv.conf of the server, if its Internet connection is already established. If you don't have a nameserver, you can use Google Public DNS which is relatively fast. Its addresses are 8.8.8.8 and 8.8.4.4.

That's it. The client PC should now have Internet.

Troubleshooting

If you are able to connect the two PCs but cannot send data (for example, if the client PC makes a DHCP request to the server PC, the server PC receives the request and offers an IP to the client, but the client does not accept it, timing out instead), check that you don't have other Iptables rules interfering.