Difference between revisions of "Bridge with netctl"

From ArchWiki
Jump to: navigation, search
m (Installation: Name package)
(Configuration: Adapted to netctl)
Line 8: Line 8:
  
 
==Configuration==
 
==Configuration==
* Load the {{ic|bridge}} kernel module and configure it to be loaded at boot.
 
 
Read [[Kernel modules]] for more information.
 
  
 
* [[pacman|Install]] the {{Pkg|bridge-utils}} package from the [[Official Repositories|official repositories]].
 
* [[pacman|Install]] the {{Pkg|bridge-utils}} package from the [[Official Repositories|official repositories]].
  
* Create a bridge called {{ic|br0}} to have, at least, your real Ethernet adapter (assuming {{ic|eth0}}):
+
* Copy {{ic|/etc/netctl/examples/bridge}} to {{ic|/etc/netctl/bridge}}.
 +
 
 +
* Create a bridge called {{ic|br0}} to have, at least, your real Ethernet adapter (assuming {{ic|eth0}}) and optionally a tap device (assuming {{ic|tap0}}):
 
{{hc|
 
{{hc|
/etc/network.d/bridge|<nowiki>
+
/etc/netctl/bridge|<nowiki>
INTERFACE="br0"
+
Description="Example Bridge connection"
CONNECTION="bridge"
+
Interface=br0
DESCRIPTION="Bridge"
+
Connection=bridge
IP='dhcp'
+
BindsToInterfaces=(eth0 tap0)
 
+
IP=dhcp
#Uncomment this fields as necessary if you are using a static ip instead
+
## sets forward delay time
#IP='static'
+
#FwdDelay=0
#ADDR='10.0.0.1'
+
## sets max age of hello message
#GATEWAY='10.0.0.1'
+
#MaxAge=10
#DNS=('8.8.8.8')
+
  
# Add your network adapter(s) here, separated by spaces.
+
</nowiki>}} If you are using an static ip see man pages of [[netctl]], also edit {{ic|/etc/resolv.conf}} as necessary.
BRIDGE_INTERFACES="eth0"
+
* You can bridge any combination of network devices editing "BindsToInterfaces" option.
</nowiki>}} If you are using an static ip, also edit {{ic|/etc/resolv.conf}} as necessary.
+
* If any of the bridged devices (eth0,tap0,...) had [[dhcpcd]] enabled, [[Daemon|disable and stop]] the {{ic|dhcpcd@eth0.service}} daemon. Or set {{ic|IP<nowiki>=</nowiki>no}} to the netctl profiles.
* If {{ic|eth0}} had [[dhcpcd]] enabled, [[Daemon|disable and stop]] the {{ic|dhcpcd@eth0.service}} daemon.
+
* Finally, [[Netctl#Just_One_Profile|enable and start]] your {{ic|/etc/netctl/bridge}}.
* Finally, [[Daemon|enable and start]] your {{ic|netcfg@bridge.service}}.
+
  
 
==Tips and Tricks==
 
==Tips and Tricks==

Revision as of 08:03, 11 June 2013

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 netctl package from the official repositories.

Configuration

  • Copy /etc/netctl/examples/bridge to /etc/netctl/bridge.
  • Create a bridge called br0 to have, at least, your real Ethernet adapter (assuming eth0) and optionally a tap device (assuming tap0):
/etc/netctl/bridge
Description="Example Bridge connection"
Interface=br0
Connection=bridge
BindsToInterfaces=(eth0 tap0)
IP=dhcp
## sets forward delay time
#FwdDelay=0
## sets max age of hello message
#MaxAge=10

If you are using an static ip see man pages of netctl, also edit /etc/resolv.conf as necessary.
  • You can bridge any combination of network devices editing "BindsToInterfaces" option.
  • If any of the bridged devices (eth0,tap0,...) had dhcpcd enabled, disable and stop the dhcpcd@eth0.service daemon. Or set IP=no to the netctl profiles.
  • Finally, enable and start your /etc/netctl/bridge.

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