0% found this document useful (0 votes)
78 views5 pages

Quick Start Guide For Bridge

This document provides instructions for setting up a Soft-AP or station in bridge mode on Linux. It describes adding a bridge interface and making wireless and Ethernet interfaces part of the bridge. For Soft-AP in bridge mode, it notes to add a bridge configuration parameter to hostapd. For station in bridge mode, it explains starting wpa_supplicant with a bridge option and potential issues on some kernels requiring modifications. It also covers assigning IP addresses to the bridge instead of individual interfaces.

Uploaded by

Cyber Bellaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views5 pages

Quick Start Guide For Bridge

This document provides instructions for setting up a Soft-AP or station in bridge mode on Linux. It describes adding a bridge interface and making wireless and Ethernet interfaces part of the bridge. For Soft-AP in bridge mode, it notes to add a bridge configuration parameter to hostapd. For station in bridge mode, it explains starting wpa_supplicant with a bridge option and potential issues on some kernels requiring modifications. It also covers assigning IP addresses to the bridge instead of individual interfaces.

Uploaded by

Cyber Bellaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Quick Start Guide for starting Soft-AP or station in bridge mode

(A) How to add bridge:


# The command creates a new instance of the Ethernet bridge
brctl addbr br0

# The command will make the interface wlan0 a port of the bridge br0. This means
that all frames received on wlan0 will be processed as if destined for the bridge.
brctl addif br0 wlan0

# You may get the error message “can't add wlan0 to bridge br0: Operation not
supported” when the driver uses CFG80211, the Linux kernel version is greater than
2.5.35.1 and the wlan0 interface is not AP mode. You can modify kernel to remove
the limitation of cfg80211 module and below is a modification sample of
linux-3.10.63.
--- D: /linux-3.10.63/net/ wireless/util.c
+++ D: /linux-3.10.63/net/ wireless/util.c
@@ -815,11 +815,11 @@
return -EOPNOTSUPP;

/* if it's part of a bridge, reject changing type to station/ibss */


- if ((dev->priv_flags & IFF_BRIDGE_PORT) &&
+ /*if ((dev->priv_flags & IFF_BRIDGE_PORT) &&
(ntype == NL80211_IFTYPE_ADHOC ||
ntype == NL80211_IFTYPE_STATION ||
ntype == NL80211_IFTYPE_P2P_CLIENT))
- return -EBUSY;
+ return -EBUSY;*/

if (ntype != otype && netif_running(dev)) {


mutex_lock(&rdev->devlist_mtx);
@@ -870,7 +870,7 @@
/* fall through */
case NL80211_IFTYPE_P2P_CLIENT:
case NL80211_IFTYPE_ADHOC:
- dev->priv_flags |= IFF_DONT_BRIDGE;
+ //dev->priv_flags |= IFF_DONT_BRIDGE;
break;
case NL80211_IFTYPE_P2P_GO:
case NL80211_IFTYPE_AP:

--- D: /linux-3.10.63/net/wireless/core.c
+++ D: /linux-3.10.63/net/wireless/core.c
@@ -948,10 +948,10 @@
netdev_set_default_ethtool_ops(dev, &cfg80211_ethtool_ops);

- if ((wdev->iftype == NL80211_IFTYPE_STATION ||
+ /*if ((wdev->iftype == NL80211_IFTYPE_STATION ||
wdev->iftype == NL80211_IFTYPE_P2P_CLIENT ||
wdev->iftype == NL80211_IFTYPE_ADHOC)
&& !wdev->use_4addr)
- dev->priv_flags |= IFF_DONT_BRIDGE;
+ dev->priv_flags |= IFF_DONT_BRIDGE;*/
break;
case NETDEV_GOING_DOWN:
cfg80211_leave(rdev, wdev);

# The command will make the interface eth0 a port of the bridge br0.
brctl addif br0 eth0

# The command sets the bridge's “bridge forward delay” to zero seconds
brctl setfd br0 0

(B) Soft-AP in bridge mode:


(1) Add an additional configuration parameter, bridge, in the rtl_hostapd.conf file
bridge=br0

(2) The others are the same with normal Soft-AP mode. Please reference
“Quick_Start_Guide_for_SoftAP.pdf” to get complete information.

(C) The station in bridge mode:


(1) start wpa_supplicant daemon with bridge name to replace one without bridge
name in the background
wpa_supplicant -Dwext -iwlan0 -c /tmp/net/wpa.conf -b br0 -B

(2) The wpa_supplicant may receive EAPOL packet fail in Linux kernel 3.9.1 ~ 4.0.5.
You still can modify kernel to remove the limitation of bridge module and below
is a modification sample of linux-3.10.63.
--- D: /linux-3.10.63/net/bridge/br_if.c
+++ D: /linux-3.10.63/net/bridge/br_if.c
@@ -75,7 +75,7 @@
return;

spin_lock_bh(&br->lock);
- if (netif_running(dev) && netif_oper_up(dev)) {
+ if (netif_running(dev)) {
if (p->state == BR_STATE_DISABLED)
br_stp_enable_port(p);
} else {
@@ -387,7 +387,7 @@
spin_lock_bh(&br->lock);
changed_addr = br_stp_recalculate_bridge_id(br);

- if (netif_running(dev) && netif_oper_up(dev) &&


+ if (netif_running(dev) &&
(br->dev->flags & IFF_UP))
br_stp_enable_port(p);
spin_unlock_bh(&br->lock);

--- D: /linux-3.10.63/net/bridge/br_notify.c
+++ D: /linux-3.10.63/net/bridge/br_notify.c
@@ -82,7 +82,7 @@
break;

case NETDEV_UP:
- if (netif_running(br->dev) && netif_oper_up(dev)) {
+ if (netif_running(br->dev)) {
spin_lock_bh(&br->lock);
br_stp_enable_port(p);
spin_unlock_bh(&br->lock);

--- D: /linux-3.10.63/net/bridge/br_stp_if.c
+++ D: /linux-3.10.63/net/bridge/br_stp_if.c
@@ -54,7 +54,7 @@
br_config_bpdu_generation(br);

list_for_each_entry(p, &br->port_list, list) {


- if (netif_running(p->dev) && netif_oper_up(p->dev))
+ if (netif_running(p->dev))
br_stp_enable_port(p);

If the Linux kernel version is greater than 3.16 you may not find the following file
br_notify.c Please refer to (3)
(3)
--- D: /linux-3.16.51/net/bridge/br.c
+++ D: /linux-3.16.51/net/bridge/br.c
@@ -82,7 +82,7 @@
break;

case NETDEV_UP:
- if (netif_running(br->dev) && netif_oper_up(dev)) {
+ if (netif_running(br->dev)) {
spin_lock_bh(&br->lock);
br_stp_enable_port(p);
spin_unlock_bh(&br->lock);

(4) The others are the same with normal station mode. Please reference
“wpa_cli_with_wpa_supplicant.pdf” to get complete information.

(D) wlan0 and eth0 don’t need IP address.


ifconfig wlan0 0.0.0.0
ifconfig eth0 0.0.0.0

(E) The bridge br0 may include multiple ports. Suggest set IP address at br0.
(1) Static ip address
ifconfig br0 192.168.0.1

(2) DHCP get ip address from DHCP server


dhclient br0

(F) How to recompile and reinstall cfg80211 and bridge module:


#recompile cfg80211 module
make clean -C /usr/src/linux-3.10.63 SUBDIRS=/usr/src/linux-3.10.63/net/wireless/
modules

#reinstall cfg80211 module


rmmod cfg80211.ko
insmod /usr/src/linux-3.10.63/net/wireless/cfg80211.ko

#recompile bridge module


make clean -C /usr/src/linux-3.10.63 SUBDIRS=/usr/src/linux-3.10.63/net/bridge/
modules

#reinstall cfg80211 module


rmmod bridge.ko
insmod /usr/src/linux-3.10.63/net/bridge/bridge.ko

You might also like