0 Replies Latest reply on Jun 3, 2015 7:46 PM by Selenium

    USB Ethernet Bridging with WiFi AP

    Selenium

      Scenario

      The Edison is configured to be a WiFi Access Point (AP) via wlan0. It is also connected to the internet with a usb-ethernet device via usb0. Users who connect to the Edison AP will not be able to browse the internet unless a bridge is made between wlan0 and usb0. We want to create the bridge and have it obtain the network configuration from DHCP over the usb-ethernet device.

       

      These instructions configure the bridge and install a systemd service for bringing up the bridge during system boot.

      All files are attached for convenience while the content of those files are also presented here just in case they become unavailable as attachments for some unforeseen reason.

       

      There are undoubtedly alternative methods to achieve the same outcome. Let's share and discuss them

       

      Note: The instructions were originally written in markdown, however these forums do not support it. Furthermore, using <pre><code> tags do not render the code blocks as expected.

      Please understand I'm attempting to reformat the instructions for these forums.

       

      Enable WiFi AP mode

      • systemctl stop wpa_supplicant.service
      • systemctl disable wpa_supplicant.service
      • systemctl enable hostapd.service
      • systemctl start hostapd.service
      • reboot
      • connect mobile device to the edison AP
      • verify ability to browse to http://edison.local

       

      Enable USB-Ethernet bridging

      autoconf -o configure configure.in &&

      ./configure --prefix=/usr &&

      make &&

      make install

      • cd /etc/systemd/network/
      • create the bridge device and network
        • vi br0.netdev

      [NetDev]

      Name=br0

      Kind=bridge

        • vi br0.network

      [Match]

      Name=br0

       

      [Network]

      DHCP=ipv4

       

      • change usb0.network to use the bridge
        • vi usb0.network

      [Match]

      Name=usb0

       

      [Network]

      Bridge=br0

      - make hostapd use the bridge

      • make hostapd attach wlan0 to the bridge
        • vim /etc/hostapd/hostapd.conf
          • uncomment the line for `bridge=br0`

       

      Install systemd service for usb-ethernet bridge

      • vim /lib/systemd/system/udhcpc-for-br0.service

      [Unit]

      Description=udhcp client for usb ethernet bridge

      Requires=hostapd.service

      After=hostapd.service

      StopWhenUnneeded=true

       

      [Service]

      Type=simple

      ExecStart=/sbin/udhcpc -i br0 -p /var/run/udhcpc-br0.pid -S

      Restart=on-failure

      RestartSec=1

       

      [Install]

      WantedBy=multi-user.target

      • enable the service file
        • systemctl enable udhcpc-for-br0.service

       

      Reboot the system and verify bridge is working

      • connect a usb ethernet device to the OTG port
      • reboot
      • brctl show

              bridge name     bridge id               STP enabled     interfaces

              br0             8000.0200860edb75       no              usb0

                                                                                          wlan0

      • ifconfig br0

            br0       Link encap:Ethernet  HWaddr 02:00:86:0e:db:75

            inet addr:192.168.2.4  Bcast:0.0.0.0  Mask:255.255.255.0

            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

            RX packets:77 errors:0 dropped:0 overruns:0 frame:0

            TX packets:379 errors:0 dropped:0 overruns:0 carrier:0

            collisions:0 txqueuelen:0

            RX bytes:13645 (13.3 KiB)  TX bytes:22073 (21.5 KiB)

      • curl -4 icanhazip.com
      • connect mobile device to the edison AP
      • clear browser cache or browse to web page you never use, like www.yahoo.com
        • this ensures you are definitely browsing the internet and not hitting cache