Sharing Internet connection using bridge mode

December 2016

Internet connections can be shared between multiple computers by using the bridge mode of the computer. To activate the bridge mode, a free Ethernet port is required. Individual computers can use this free port to transfer the internet connection from a single box interface. To execute this, the router capabilities of the box should be utilised and activated, so that it can assign unique IPs to the individual computers. Once the PCs and the box are in the same network , the connection sharing process is complete.


An 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 a different IP to each PC.

In the image below the PC has two ethernet sockets: eth0 and eth1.
  • 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)



The /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


In the next image, a second PC has been connected to the eth1 port.


Making use of the bridge means that any Ethernet frame received on an ethernet interface (eth0 or eth1) will be re-issued on the other. Just like when connecting two PCs using a hub.



PC2 will have its IP address automatically assigned by the box, and can connect directly to the Internet.

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 bra is configured to obtain the IP address via DHCP and is then asked to connect "virtually" eth0 and eth1 using the following command: "bridge_ports eth0 eth1"
  • On PC2, you just have to configure it with DHCP (automatic IP address)

Related :

This document entitled « Sharing Internet connection using bridge mode » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.