Sharing Internet connection using bridge mode
Internet connection can be shared with another computer if you have a free Ethernet port
Sharing via bridge mode
When using a box, first activate the router functions of your box so that it can assign different IP to each PC.
E.g
Imagine that you have a PC with 2 Ethernet interface:
eth0 is connected to the Internet (and is automatically assigned IP 192.168.0.x by the dhcp.
eth1 is a free interface (configured with a fixed IP 10.0.0.1).
Your
/etc/network/interfaces file must look like this:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 10.0.0.1
netmask 255.255.255.0
We will connect a second PC to the eth1 port like this:
Making use of the bridge implies that any Ethernet frame received on an ethernet interface (eth0 or eth1) will be re-issued on the other. Just like hen connecting 2 PC via a hub.
PC2 will have its IP address automatically assigned by the box, and can connect directly to the Internet.
Installation
Installing bridge-utils
Type:
sudo apt-get install bridge-utils
Change the configuration
Modify the
/etc/network/interfaces file
auto lo
iface lo inet loopback
auto br0
iface br0 inet dhcp
bridge_ports eth0 eth1
auto eth1
iface eth1 inet static
address 10.0.0.1
netmask 255.255.255.0
Notes
To validate this configuration, type: sudo /etc/init.d/networking restart
The bridge br0 is configured to obtain IP address via DHCP and then is asked to connect "virtually" eth0 and eth1 with using the following command: bridge_ports eth0 eth1.
On PC2, you just have to configure it with DHCP (automatic IP address).