T60 as Pi Ethernet-WiFi-Bridge: Difference between revisions

From Wurst-Wasser.net
Jump to navigation Jump to search
No edit summary
 
Line 6: Line 6:
=== enableBridge.sh ===
=== enableBridge.sh ===
The bridge itself is setup by <tt>hostapd</tt>. But it is only linked to the WiFi-Interface. So this script is launched after <tt>hostapd</tt>:
The bridge itself is setup by <tt>hostapd</tt>. But it is only linked to the WiFi-Interface. So this script is launched after <tt>hostapd</tt>:
  DEVWIFI="wlx00e04c0f4ac0"
  DEVWIFI="wlx00e04c0f4ac0"
  DEVETH="ens2"
  DEVETH="ens2"
  DEVBR="br0" # generated by hostapd
  DEVBR="br0" # generated by hostapd
# This is how it works for the T60-2008:
# 0: Check wether hostapd is running yet
/usr/sbin/service hostapd status | /bin/grep "Active:" | /bin/grep running > /dev/null 2>&1
if [ "$?" -ne 0 ]; then
  logger "hostapd is (not yet) running. Exiting."
  exit 0
fi
   
   
  # 1: give the Bridge an IPA
  # 1: give the Bridge an IPA
  /sbin/ifconfig $DEVBR | grep inet | grep 10.178 > /dev/null 2>&1
  /sbin/ifconfig $DEVBR | /bin/grep inet | /bin/grep 10.178 > /dev/null 2>&1
  if [ "$?" -ne 0 ]; then
  if [ "$?" -ne 0 ]; then
   ifconfig br0 10.178.111.242 netmask 255.255.255.0
   /sbin/ifconfig br0 10.178.111.242 netmask 255.255.255.0
   route add default gw 10.178.111.1
   /sbin/route add default gw 10.178.111.1
   logger "Added $DEVBR IPA."
   logger "Added $DEVBR IPA."
  fi
  fi
   
   
  # 2: remove ens2's IPA
  # 2: remove ens2's IPA
  /sbin/ifconfig $DEVETH | grep inet | grep 10.178 > /dev/null 2>&1
  /sbin/ifconfig $DEVETH | /bin/grep inet | /bin/grep 10.178 > /dev/null 2>&1
  if [ "$?" -eq 0 ]; then
  if [ "$?" -eq 0 ]; then
     ip addr flush dev $DEVETH
     /sbin/ip addr flush dev $DEVETH
     logger "Flushed $DEVETH IPA."
     logger "Flushed $DEVETH IPA."
  fi
  fi

Latest revision as of 20:56, 18 September 2019

I used a Lenovo Thinkpad T60 (Model #2008) to supersede the Pi3. Main cause was that the Pi3 is a bit too slow, leading to a load of 4 when around 30.000 packets/minute are transferred whereas the T60's load is just 0.6. And that from a 2006-2007-built computer.

Setup

The setup is exactly the same as this: Raspberry as Pi Ethernet-WiFi-Bridge, with a few exceptions:

enableBridge.sh

The bridge itself is setup by hostapd. But it is only linked to the WiFi-Interface. So this script is launched after hostapd:

DEVWIFI="wlx00e04c0f4ac0"
DEVETH="ens2"
DEVBR="br0" # generated by hostapd

# This is how it works for the T60-2008:

# 0: Check wether hostapd is running yet
/usr/sbin/service hostapd status | /bin/grep "Active:" | /bin/grep running > /dev/null 2>&1
if [ "$?" -ne 0 ]; then
  logger "hostapd is (not yet) running. Exiting."
  exit 0
fi

# 1: give the Bridge an IPA
/sbin/ifconfig $DEVBR | /bin/grep inet | /bin/grep 10.178 > /dev/null 2>&1
if [ "$?" -ne 0 ]; then
  /sbin/ifconfig br0 10.178.111.242 netmask 255.255.255.0
  /sbin/route add default gw 10.178.111.1
  logger "Added $DEVBR IPA."
fi

# 2: remove ens2's IPA
/sbin/ifconfig $DEVETH | /bin/grep inet | /bin/grep 10.178 > /dev/null 2>&1
if [ "$?" -eq 0 ]; then
    /sbin/ip addr flush dev $DEVETH
    logger "Flushed $DEVETH IPA."
fi

# 3: Add Ethernet to bridge
/sbin/brctl show $DEVBR | /bin/grep $DEVETH > /dev/null 2>&1
if [ "$?" -ne 0 ]; then
 # do it
 echo "Adding ethernet to the bridge..." | logger
 /sbin/brctl addif $DEVBR $DEVETH
 /bin/sleep 1
fi

hostapd.conf

interface=wlx00e04c0f4ac0
#interface=wls3
#driver=nl80211
#driver=iwl3945 ist in dem hostapd nicht einkompiliert
bridge=br0
hw_mode=g
channel=7
ieee80211n=1
wmm_enabled=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
ssid=HeartOfGold
wpa_passphrase=42_42_42_42

If you set driver=, make sure you use the correct one. You can find out which driver is used by the OS by: readlink /sys/class/net/wls3/device/driver

Power Consumption

tbd

Troubleshooting Tips

hostapd not working

service hostapd stop
hostapd -d /etc/hostapd/hostapd.conf

Read the output thoroughly. There is a clue!

In my case I needed to mark the WiFi-device (wlx00e04c0f4ac0) as unmanaged in /etc/NetworkManager/NetworkManager.conf:

[keyfile]
unmanaged-devices=interface-name:wlx00e04c0f4ac0;interface-name:wls3

RF-Kill?

If you get...

SIOCSIFFLAGS: Operation not possible due to RF-kill

...it might mean the RF-Kill-Switch of your Thinkpad is set on. But it can also mean that you just disabled WiFi in Network Manager[1].



  1. Meaning the switch in the UI, where you can disable WiFi (and all WiFi devices)