Difference between revisions of "Bridge with netctl"

From ArchWiki
Jump to: navigation, search
(Adding an explanation about what is a bridge)
m (Configuration: Fix daemon style)
Line 33: Line 33:
 
BRIDGE_INTERFACES="eth0"
 
BRIDGE_INTERFACES="eth0"
 
</nowiki>}} If you are using an static ip, also edit {{ic|/etc/resolv.conf}} as necessary.
 
</nowiki>}} If you are using an static ip, also edit {{ic|/etc/resolv.conf}} as necessary.
* If {{ic|eth0}} had [[dhcpcd]] enabled, disable and stop it:
+
* If {{ic|eth0}} had [[dhcpcd]] enabled, [[Daemon|disable and stop]] the {{ic|dhcpcd@eth0.service}} daemon.
{{bc|
+
* Finally, [[Daemon|enable and start]] your {{ic|netcfg@bridge.service}}.
# systemctl stop dhcpcd@eth0.service
+
 
# systemctl disable dhcpcd@eth0.service
+
}}
+
* Then enable and start your {{ic|br0}} bridge:
+
{{bc|
+
# systemctl start netcfg@bridge.service
+
# systemctl enable netcfg@bridge.service
+
}}
+
 
==Tips and Tricks==
 
==Tips and Tricks==
 
===Manually adding/removing network devices===
 
===Manually adding/removing network devices===

Revision as of 00:31, 22 December 2012

A bridge is a piece of software used to unite two or more network segments. A bridge behaves like a virtual network switch, working transparently (the other machines don't need to know or care about its existance). Real devices (like eth ones) and virtual devices (like tap ones) can be connected to it.

This article explains how to create a bridge that contains at least a ethernet device. This is useful for things like the bridge mode of qemu, setting a software based access point, etc.

Installation

Install the netcfg package from the official repositories.

Configuration

  • Enable the bridge module:
# modprobe bridge

And to make it permanent, add it to your /etc/modules-load.d:

echo bridge>/etc/modules-load.d/bridge.conf
  • Create a bridge called br0 to have, at least, your real Ethernet adapter (assuming eth0):
/etc/network.d/bridge
INTERFACE="br0"
CONNECTION="bridge"
DESCRIPTION="Bridge"
IP='dhcp'

#Uncomment this fields as necessary if you are using a static ip instead
#IP='static'
#ADDR='10.0.0.1'
#GATEWAY='10.0.0.1'
#DNS=('8.8.8.8')

# Add your network adapter(s) here, separated by spaces.
BRIDGE_INTERFACES="eth0"
If you are using an static ip, also edit /etc/resolv.conf as necessary.

Tips and Tricks

Manually adding/removing network devices

Install the bridge-utils package from the official repositories.

It provides brctl, to manipulate bridges. You can use it to add a device, like this:

# brctl addif br0 eth1

Read the manual for more info: man brctl