From 3e45e17626f384028208e38b14cf688f9da22b63 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sun, 14 Apr 2019 19:03:54 +0000 Subject: [PATCH] First historical article --- 2016-05-17-wifi-bridging-redux.html | 60 +++++++++++++++++++++++++++-- include/article-header.html | 2 +- include/bottom.html | 4 ++ include/page-head.html | 2 +- include/style.css | 23 ++++++++++- include/top.html | 4 ++ index.html | 1 + 7 files changed, 89 insertions(+), 7 deletions(-) diff --git a/2016-05-17-wifi-bridging-redux.html b/2016-05-17-wifi-bridging-redux.html index fee04c3..df73bf5 100644 --- a/2016-05-17-wifi-bridging-redux.html +++ b/2016-05-17-wifi-bridging-redux.html @@ -7,17 +7,71 @@

You can copy the hardware from the router post, or use what you’ve got; I don’t believe this is driver-specific.

-

Your access point, however, does require support for this to work. It needs to: +

Your access point, however, does require support for this to work. It needs to:

-

Bridging

Linux supports bridging. There’s a bridge-utils package in Ubuntu with the tools you need: +sudo apt-get install bridge-utils

+ +

To see current bridges, run: +brcrl show

+ +

However, you can’t normally add a WiFi interface to a bridge: +$ sudo brctl addif br0 eth0 wlan0 +can't add wlan0 to bridge br0: Operation not supported

+ +

Googling this error produces a wide range of well-meaning yet completely unhelpful results.

+ +

Enable 4 address mode

+ +

To be able to add a WiFi interface to a bridge, you have to put it into 4-address mode first: +# If necessary: +# sudo apt-get install iw +sudo iw dev wlan0 set 4addr on

+ +

From that point forward, the interface won’t be able to talk normally, and wpa_supplicant is likely to time out in the association phase (run “sudo wpa_cli” to watch its logs).

+ +

Now add the interface to a bridge: +sudo brctl addif br0 wlan0

+ +

You should now be able to fetch an IP on br0 via DHCP. Unless, of course, you need wpa_supplicant to work…

+ +

wpa_supplicant

+ +

wpa_supplicant needs to be bridge-aware to work with 4-address mode. Fortunately, it has a flag (-b) to set the bridge interface. Unfortunately, this flag is broken in 2.1, the version in Ubuntu Trusty. I verified that it works in wpa_supplicant 2.5 built from source; I haven’t verified 2.4 from Xenial.

+ +

A wpa_supplicant commandline looks something like: +wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -C /var/run/wpa_supplicant -P /var/run/wpa_supplicant.wlan0.pid -b br0

+ +

With that working, the interface should get to wpa_state=COMPLETED, and br0 should work normally. Remember that wlan0 will still be unusable directly.

+ +

Ordering

+ +

Bringing up these interfaces is tricky; the ordering is annoying.

+ + +

Putting it together

+ +

Because of the ordering issues, it’s easier to treat this all as one interface that has to come up together. Here’s an example interface stanza that does this: +auto br0 +iface br0 inet dhcp + pre-up /sbin/iw dev wlan0 set 4addr on + pre-up /sbin/brctl addbr $IFACE || true + pre-up /sbin/start-stop-daemon --start --pidfile=/var/run/wpa_supplicant.wlan0.pid --exec=/usr/local/sbin/wpa_supplicant --user=root -- -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -C /var/run/wpa_supplicant -P /var/run/wpa_supplicant.wlan0.pid -b $IFACE + bridge_ports eth0 eth1 wlan0 + post-down /sbin/start-stop-daemon --stop --pidfile=/var/run/wpa_supplicant.wlan0.pid --exec=/usr/local/sbin/wpa_supplicant --user=root + post-down /sbin/iw dev wlan0 set 4addr off

+ +

We use start-stop-daemon because it provides idempotence and safety from stale PID files.

-

diff --git a/include/article-header.html b/include/article-header.html index 7166de3..6b41844 100644 --- a/include/article-header.html +++ b/include/article-header.html @@ -5,7 +5,7 @@ -

+


diff --git a/include/bottom.html b/include/bottom.html index 75f0619..f6187e2 100644 --- a/include/bottom.html +++ b/include/bottom.html @@ -1,5 +1,9 @@ + + + + diff --git a/include/page-head.html b/include/page-head.html index 9a5facf..9ab0609 100644 --- a/include/page-head.html +++ b/include/page-head.html @@ -3,7 +3,7 @@ - <!--# echo var="title" default="where the flamingcow roams" --> diff --git a/include/style.css b/include/style.css index 94446e8..cc6199e 100644 --- a/include/style.css +++ b/include/style.css @@ -52,13 +52,14 @@ h2 { font-size: 16px; font-weight: bold; text-transform: uppercase; - margin-block-start: 0.5em; - margin-block-end: 0.5em; + margin-top: 0.5em; + margin-bottom: 0.5em; } h3 { font-size: 16px; font-weight: bold; + margin-top: 2em; } h4 { @@ -74,3 +75,21 @@ h4 { ul li { margin-bottom: 10px; } + +code { + display: block; + white-space: pre; + + font-family: Monospace, Courier; + font-size: 16px; + + background-color: #e8e8e8; + color: black; + + border: 1px solid black; + + padding: 1ch; + margin: 1ch; + + overflow: scroll; +} diff --git a/include/top.html b/include/top.html index 83bb43f..66e8421 100644 --- a/include/top.html +++ b/include/top.html @@ -5,5 +5,9 @@
+ +
+ + diff --git a/index.html b/index.html index 4097695..a1df2ed 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,7 @@
  1. 2019-Apr-14: Reboot
  2. +
  3. 2016-May-17: WiFi bridging redux