LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Create a Wired-Wireless bridge (https://www.linuxquestions.org/questions/linux-networking-3/create-a-wired-wireless-bridge-921841/)

schigger 01-03-2012 02:36 PM

Create a Wired-Wireless bridge
 
Hi,

I have very poor wireless access in my room - I can connect only with an USB-wifi-stick - but multiple network devices (printer, notebook, PC). In order to be able to access the network with all of those, I linked them via ethernet and set up a network bridge between wired (connected to the devices in my room) and wireless (connected to my AP) network on the PC (Windows XP), which was working fine. But in this setup, the network printer is only available from the other parts of the network if the (loud) PC is running, so I wanted to run the bridge on an old but very quiet PC using Ubuntu on a Flash drive.

After some frustration that brctl won't let me add my wireless card to a bridge, I found out that bridging a wireless card in client mode is simply not supported because the specification does not allow the card to send packets from multiple MAC-addresses.

I'd accept this and would say "Just doesn't work", but as I said exactly the same setup is working under Windows XP by just right-clicking on the interfaces and adding them to a bridge. So is there any way to bypass the restriction in linux? And does anyone know if Windows take precautions to ensure compliance with the standard or if it just works out of luck?

agentbuzz 01-04-2012 08:19 AM

Add 802.11 NIC to bridge device?
 
schigger,
You could add the USB wireless NIC to a bond device and add the bond to a bridge. Of course you have to modprobe the bonding driver. I infer that you already have bridge-utils installed.

ifcfg-wlan0 would look like this:

Code:

DEVICE=wlan0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no

ifcfg-bond0 would look like this:

Code:

DEVICE=bond0
BRIDGE=br0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes

You only have one slave in the bond device. It should still work.

ifcfg-br0 would look like this:

Code:

DEVICE=br0
ONBOOT=yes
TYPE=Bridge
IPADDR=192.168.1.42
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

Flush your FORWARD chain and add this rule to it:

Code:

[wopr]# iptables -A FORWARD -m physdev --physdev-is-bridged -j ACCEPT
Save the firewall.

Code:

[wopr]# /sbin/service iptables save
Add a route that gets you to your network through br0:

Code:

[wopr]# route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1 dev br0
Create a route-br0 in /etc/sysconfig/network-scripts to make the route persistent:

Code:

ADDRESS0=192.168.1.0
GATEWAY0=192.168.1.1
NETMASK0=255.255.255.0

Restart your network and check everything with "ifconfig -a", "brctl show", "netstat -nr" and "iptables -L".

schigger 01-06-2012 08:43 AM

Thanks for the idea, I did not know about bonding interfaces. But unfortunately, this doesn't work for me either. When the bridge device goes up, at first it seems do work: "iwconfig" shows that the wireless interface is connected, "dmesg" tells that wpa_supplicant has finished the WPA authentication and "brctl show" says that eth0 and bond1 are part of the bridge. But ping to the acces point does not work, and about 30 second later, dmesg shows this line:

Code:

wlan1: deauthenticating from 00:24:01:e7:94:75 by local choice (reason=3)
and the wireless interface is down again.
Here is my /etc/network/interfaces file:

Code:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

#auto bond0
#iface bond0 inet manual
#        bond-slaves wlan0

auto bond1
iface bond1 inet manual
#        addres 192.168.2.28
#        netmask 255.255.255.0
#        gateway 192.168.2.1
        bond-slaves wlan1

auto wlan1
iface wlan1 inet manual
        #address 192.168.2.28
        #netmask 255.255.255.0
        #gateway 192.168.2.1
        wireless-essid <SSID>
        wpa-ssid <SSID>
        wpa-psk  <PSK>

#auto wlan0
#iface wlan0 inet manual


auto eth0
iface eth0 inet manual
        #address 192.168.2.26
        #netmask 255.255.255.0

auto br0
iface br0 inet static
        pre-up iwconfig wlan1 essid <SSID>
        bridge_hw 00:27:19:f5:fc:ed
        address 192.168.2.25
        netmask 255.255.255.0
        gateway 192.168.2.1
        bridge-ports bond1 eth0

(bond0 and wlan0 are supposed to work as an wireless access point in my room later, when ethernet works)

schigger 01-07-2012 05:48 PM

As it seems, bonding also does not work with wireless interfaces (or at least my interface): when I disable everything that is related to bridging, bring wlan1 up and type
Code:

ifenslave bond0 wlan1
wlan1 disconnects. After removing it from the bond interface, everything works again:

/var/log/syslog:
Code:


Jan  8 00:15:00 OmaWetterwachs kernel: [ 5603.852527] ADDRCONF(NETDEV_UP): bond0: link is not ready
Jan  8 00:15:06 OmaWetterwachs ntpdate[10918]: name server cannot be used: Temporary failure in name resolution (-3)
Jan  8 00:15:07 OmaWetterwachs wpa_supplicant[10410]: CTRL-EVENT-DISCONNECTED bssid=<AP_MAC> reason=3
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.240429] wlan1: deauthenticating from <AP_MAC> by local choice (reason=3)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.298069] cfg80211: All devices are disconnected, going to restore regulatory settings
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.298081] cfg80211: Restoring regulatory settings
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.298097] cfg80211: Calling CRDA to update world regulatory domain
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.464284] bonding: bond0: Warning: failed to get speed and duplex from wlan1, assumed to be 100Mb/sec and Full.
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.464426] bonding: bond0: enslaving wlan1 as an active interface with an up link.
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.464708] ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517074] cfg80211: Updating information on frequency 2412 MHz for a 20 MHz width channel with regulatory rule:
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517085] cfg80211: 2402000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517090] cfg80211: Updating information on frequency 2417 MHz for a 20 MHz width channel with regulatory rule:
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517095] cfg80211: 2402000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517100] cfg80211: Updating information on frequency 2422 MHz for a 20 MHz width channel with regulatory rule:
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517105] cfg80211: 2402000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517110] cfg80211: Updating information on frequency 2427 MHz for a 20 MHz width channel with regulatory rule:
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517115] cfg80211: 2402000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517120] cfg80211: Updating information on frequency 2432 MHz for a 20 MHz width channel with regulatory rule:
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517125] cfg80211: 2402000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517129] cfg80211: Updating information on frequency 2437 MHz for a 20 MHz width channel with regulatory rule:
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517135] cfg80211: 2402000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517139] cfg80211: Updating information on frequency 2442 MHz for a 20 MHz width channel with regulatory rule:
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517145] cfg80211: 2402000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517149] cfg80211: Updating information on frequency 2447 MHz for a 20 MHz width channel with regulatory rule:
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517155] cfg80211: 2402000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517159] cfg80211: Updating information on frequency 2452 MHz for a 20 MHz width channel with regulatory rule:
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517164] cfg80211: 2402000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517169] cfg80211: Updating information on frequency 2457 MHz for a 20 MHz width channel with regulatory rule:
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517174] cfg80211: 2402000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517178] cfg80211: Updating information on frequency 2462 MHz for a 20 MHz width channel with regulatory rule:
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517184] cfg80211: 2402000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517188] cfg80211: Updating information on frequency 2467 MHz for a 20 MHz width channel with regulatory rule:
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517193] cfg80211: 2402000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517198] cfg80211: Updating information on frequency 2472 MHz for a 20 MHz width channel with regulatory rule:
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517203] cfg80211: 2402000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517207] cfg80211: Disabling freq 2484 MHz
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517215] cfg80211: World regulatory domain updated:
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517219] cfg80211:    (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517224] cfg80211:    (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517229] cfg80211:    (2457000 KHz - 2482000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517234] cfg80211:    (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517240] cfg80211:    (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Jan  8 00:15:07 OmaWetterwachs kernel: [ 5610.517245] cfg80211:    (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
Jan  8 00:15:17 OmaWetterwachs kernel: [ 5620.688016] bond0: no IPv6 routers present
Jan  8 00:15:53 OmaWetterwachs ntpdate[11010]: name server cannot be used: Temporary failure in name resolution (-3)
Jan  8 00:16:52 OmaWetterwachs ntpdate[11022]: name server cannot be used: Temporary failure in name resolution (-3)
Jan  8 00:17:01 OmaWetterwachs CRON[11025]: (root) CMD (  cd / && run-parts --report /etc/cron.hourly)
Jan  8 00:21:16 OmaWetterwachs kernel: [ 5979.803728] usb 1-5: USB disconnect, device number 4
Jan  8 00:22:33 OmaWetterwachs kernel: [ 6055.935829] bonding: bond0: Removing slave wlan1.
Jan  8 00:22:33 OmaWetterwachs kernel: [ 6055.935897] bonding: bond0: releasing active interface wlan1
Jan  8 00:22:33 OmaWetterwachs wpa_supplicant[10410]: CTRL-EVENT-TERMINATING - signal 15 received
Jan  8 00:22:36 OmaWetterwachs kernel: [ 6058.988198] ADDRCONF(NETDEV_UP): wlan1: link is not ready
Jan  8 00:22:37 OmaWetterwachs kernel: [ 6060.288494] init: ssh main process (10574) terminated with status 255
Jan  8 00:22:38 OmaWetterwachs wpa_supplicant[11062]: Trying to authenticate with <AP_MAC> (SSID='<SSID>' freq=2412 MHz)
Jan  8 00:22:38 OmaWetterwachs kernel: [ 6061.546828] wlan1: authenticate with <AP_MAC> (try 1)
Jan  8 00:22:38 OmaWetterwachs wpa_supplicant[11062]: Trying to associate with <AP_MAC> (SSID='<SSID>' freq=2412 MHz)
Jan  8 00:22:38 OmaWetterwachs kernel: [ 6061.548774] wlan1: authenticated
Jan  8 00:22:38 OmaWetterwachs kernel: [ 6061.549516] wlan1: associate with <AP_MAC> (try 1)
Jan  8 00:22:38 OmaWetterwachs kernel: [ 6061.564362] wlan1: RX AssocResp from <AP_MAC> (capab=0x431 status=0 aid=1)
Jan  8 00:22:38 OmaWetterwachs kernel: [ 6061.564371] wlan1: associated
Jan  8 00:22:38 OmaWetterwachs wpa_supplicant[11062]: Associated with <AP_MAC>
Jan  8 00:22:38 OmaWetterwachs kernel: [ 6061.569528] ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
Jan  8 00:22:38 OmaWetterwachs wpa_supplicant[11062]: WPA: Key negotiation completed with <AP_MAC> [PTK=CCMP GTK=TKIP]
Jan  8 00:22:38 OmaWetterwachs wpa_supplicant[11062]: CTRL-EVENT-CONNECTED - Connection to <AP_MAC> completed (auth) [id=0 id_str=]
Jan  8 00:22:49 OmaWetterwachs kernel: [ 6072.160022] wlan1: no IPv6 routers present



All times are GMT -5. The time now is 04:51 AM.