1. ANC Clients

sudo iwconfig
ip a | grep inet.*wlan0; sudo iwconfig
ping 192.168.25.6

# Needed for Delta Linux Tools version 1.6.7 and earlier.
sudo apt-get install xorgxrdp xrdp

2. Configuration

  • Attache the EnGenius EUB9707, EnGenius 1T1R Mini Wireless USB Dongle to the TBHF-OPS-MRM server.

  • Attache the TP-Link TL-WN723N, Realtek RTL8188EU Wireless LAN 802.11n USB 2.0 Network Adapter to the TBHF-OPS-MRM server.

  • Enter the following commands at a Command Line.

    sudo apt-get install isc-dhcp-client
    
    sudo apt-get install firmware-atheros
    sudo apt-get install firmware-brcm80211
    sudo apt-get install firmware-iwlwifi
    sudo apt-get install firmware-ralink
    sudo apt-get install firmware-realtek
    
    # The iw package contains the iw command.
    # The wireless-tools package contains the iwconfig and iwlist commands.
    # The wpasupplicant package contains the wpa_cli command.
    sudo apt-get install iw
    sudo apt-get install rfkill
    sudo apt-get install wireless-tools
    sudo apt-get install wpasupplicant
    
    sudo rfkill list
    
    sudo systemctl --type=service           #  The networking.service is down.
                                            #  The systemd-networkd.service is up and running.
    lsusb
    ip address
    sudo iwconfig
    Bus 001 Device 028: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
    Bus 001 Device 035: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
    
    ##: wlxa0f3c12af53a: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
        link/ether a0:f3:c1:2a:f5:3a brd ff:ff:ff:ff:ff:ff
    ##: wlxa0f3c11850e5: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
        link/ether a0:f3:c1:18:50:e5 brd ff:ff:ff:ff:ff:ff
    
    wlxa0f3c12af53a  IEEE 802.11  ESSID:off/any
              Mode:Managed  Access Point: Not-Associated   Tx-Power=20 dBm
              Retry short  long limit:2   RTS thr:off   Fragment thr:off
              Encryption key:off
              Power Management:off
    
    wlxa0f3c11850e5  IEEE 802.11  ESSID:off/any
              Mode:Managed  Access Point: Not-Associated   Tx-Power=0 dBm
              Retry short limit:7   RTS thr=2347 B   Fragment thr:off
              Encryption key:off
              Power Management:on
    sudo ip link set dev wlxa0f3c12af53a up
    sudo ip link set dev wlxa0f3c11850e5 up
    
    sudo iwlist wlxa0f3c12af53a scan | grep ESSID
    sudo iw dev wlxa0f3c12af53a scan | grep SSID
    
    sudo iwlist wlxa0f3c11850e5 scan | grep ESSID
    sudo iw dev wlxa0f3c11850e5 scan | grep SSID
    
    # Private.
    wpa_passphrase Private <password> | tee /tmp/wpa_supplicant-Private.conf
    sudo wpa_supplicant -c /tmp/wpa_supplicant-Private.conf -i wlx00026fc8b97c                      # Not working.
    sudo wpa_supplicant -c /tmp/wpa_supplicant-Private.conf -i wlxa0f3c11850e5                      # Not working.
    
    # Guest.
    file="/tmp/wpa_supplicant-Guest.conf"
    cat << EOF | sed -e "s/^  //" > "${file}"
      network={
          ssid="Guest"
          group=CCMP TKIP
          key_mgmt=NONE
          scan_ssid=1
      }
    EOF
    sudo wpa_supplicant -c /tmp/wpa_supplicant-Guest.conf -i wlx00026fc8b97c                        # Not working.
    sudo wpa_supplicant -Dnl80211,wext -c /tmp/wpa_supplicant-Guest.conf -i wlx00026fc8b97c         # Not working.
    
    # 3BB.
    wpa_passphrase 3bb-wlan <password> | tee /tmp/wpa_supplicant-3BB.conf
    sudo wpa_supplicant -B -c /tmp/wpa_supplicant-3BB.conf -i wlx00026fc8b97c                       # Working.
    sudo wpa_supplicant -B -c /tmp/wpa_supplicant-3BB.conf -i wlx00026fc8b97c -Dnl80211,wext
    sudo wpa_supplicant -B -Dnl80211,wext -c /tmp/wpa_supplicant-3BB.conf -i wlx00026fc8b97c
    sudo iwconfig wlx00026fc8b97c
    
    ip address
    sudo dhclient wlx00026fc8b97c
    
    # Use square brackets around a character of the search pattern to exclude grep from ps command output.
    pid="$(ps ax | grep -w "[w]pa_supplicant" | sed "s/ .*//")"
    sudo kill -9 "${pid}"
    
    sudo ip link set dev wlx00026fc8b97c down
    sudo ip link set dev wlx788cb5ed6dc4 down
    iface="wlx00026fc8b97c"
    file="/etc/systemd/network/${iface}.network"
    # Do not use single quotes around EOF to allow interpreting variables.
    cat << EOF | sed -e "s/^  //" > "${file}"
      [Match]
      Name=${iface}
    
      [Network]
      DHCP=ipv4
    
      [DHCP]
      ClientIdentifier=mac
      RouteMetric=20
      UseDomains=yes
    EOF
    iface="wlx00026fc8b97c"
    file="/etc/udev/rules.d/95-wireless.rules"
    # See https://github.com/systemd/systemd/issues/2891
    # Do not use single quotes around EOF to allow interpreting variables.
    cat << EOF | sed -e "s/^  //" > "${file}"
      ACTION=="add", SUBSYSTEM=="net", KERNEL=="${iface}", TAG+="systemd", ENV{SYSTEMD_WANTS}="wpa_supplicant@${iface}.service"
    EOF
    file="/lib/systemd/system/wpa_supplicant@.service"
    # Back up original file if backup file is missing.
    if [ -f "${file}" ] && [ ! -f "${file}.org" ]; then cp -a "${file}" "${file}.org"; fi
    # Modify file if modification is missing.
    if ! grep -q "^ExecStartPre=/bin/dmesg --console-off$" "${file}"; then
      # Disable printing of messages to console.
      sed -i "/^ExecStart=/i ExecStartPre=/bin/dmesg --console-off" "${file}"
    fi
    # Modify file if modification is missing.
    if ! grep -q "^ExecStartPre=/sbin/modprobe -r b43$" "${file}"; then
      sed -i "/^ExecStart=/i ExecStartPre=/sbin/modprobe -r b43" "${file}"
    fi
    # Modify file if modification is missing.
    if ! grep -q "^ExecStartPre=/sbin/modprobe -r ssb$" "${file}"; then
      sed -i "/^ExecStart=/i ExecStartPre=/sbin/modprobe -r ssb" "${file}"
    fi
    # Modify file if modification is missing.
    if ! grep -q "^ExecStartPre=/usr/sbin/rfkill unblock wifi$" "${file}"; then
      sed -i "/^ExecStart=/i ExecStartPre=/usr/sbin/rfkill unblock wifi" "${file}"
    fi
    # Create configuration file for wpa-roam mode.
    iface="wlx00026fc8b97c"
    file="/etc/wpa_supplicant/wpa_supplicant-${iface}.conf"
    ssid1="Private"         # wap07smru
    ssid2="Guest"
    ssid3="3bb-wlan"        # 1111100000
    ssid4="TOT"             # admin1234
    # Generate WPA pre-shared key from 1st Wi-Fi SSID and 1st passphrase.
      psk1="$(wpa_passphrase "${ssid1}" "<password>" | grep "\spsk=" | sed "s/\spsk=//")"
    # Generate WPA pre-shared key from 3rd Wi-Fi SSID and 3rd passphrase.
      psk3="$(wpa_passphrase "${ssid3}" "<password>" | grep "\spsk=" | sed "s/\spsk=//")"
    # Generate WPA pre-shared key from 4th Wi-Fi SSID and 4th passphrase.
      psk4="$(wpa_passphrase "${ssid4}" "<password>" | grep "\spsk=" | sed "s/\spsk=//")"
    # Note: The "scan_ssid=1" line is needed when the Wi-Fi does not broadcast its SSID.
    # Do not use single quotes around EOF to allow interpreting variables.
    cat << EOF | sed -e "s/^  //" | sudo tee "${file}"
      ######################## Global Configuration Options ########################
    
      country=TH
      ctrl_interface=DIR=/run/wpa_supplicant GROUP=netdev
      update_config=1
    
      ######################## Network Block Configurations ########################
    
      network={
        ssid="${ssid1}"
        group=CCMP TKIP
        key_mgmt=WPA-PSK
        pairwise=CCMP TKIP
        priority=1
        proto=WPA2
        psk=${psk1}
        scan_ssid=1
      }
    
      network={
        ssid="${ssid2}"
        group=CCMP TKIP
        key_mgmt=NONE
        scan_ssid=1
      }
    
      network={
        ssid="${ssid3}"
        group=CCMP TKIP
        key_mgmt=WPA-PSK
        pairwise=CCMP TKIP
        priority=3
        proto=WPA2
        psk=${psk3}
        scan_ssid=1
      }
    
      network={
        ssid="${ssid4}"
        group=CCMP TKIP
        key_mgmt=WPA-PSK
        pairwise=CCMP TKIP
        priority=4
        proto=WPA2
        psk=${psk4}
        scan_ssid=1
      }
    
    EOF
    sudo chmod 600 "${file}"
    
    sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant-wlx00026fc8b97c.conf -i wlx00026fc8b97c

2.1. Script

  • Run the following script at a Command Line with root privileges.

    iface="wlxa0f3c12af53a"         # TP-LINK TL-WN727N Ralink Technology, Corp. RT5370 Wireless Adapter.
    iface="wlxa0f3c11850e5"         # TP-LINK TL-WN725N Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter.
    ssid="Private"
    pass="wap07smru"
    ssid="3bb-wlan"
    pass="1111100000"
    ssid="Guest"
    # Create WPA Supplicant configuration file.
    file="/tmp/wpa_supplicant-${ssid}.conf"
    if [ "${ssid}" = "Guest" ]; then
      # Do not use single quotes around EOF to allow interpreting variables.
      cat << EOF | sed -e "s/^  //" > "${file}"
      network={
          ssid="${ssid}"
          key_mgmt=NONE
          priority=1
          scan_ssid=1
      }
    EOF
    else
      # Generate WPA pre-shared key from 1st Wi-Fi SSID and 1st passphrase.
      psk="$(wpa_passphrase "${ssid}" "${pass}" | grep "\spsk=" | sed "s/\spsk=//")"
      # Do not use single quotes around EOF to allow interpreting variables.
      cat << EOF | sed -e "s/^  //" > "${file}"
      network={
          ssid="${ssid}"
          priority=1
          psk=${psk}
          scan_ssid=1
      }
    EOF
    fi
    ip link set dev "${iface}" up
    wpa_supplicant -B -c "${file}" -i "${iface}" > /dev/null
    dhclient "${iface}"
    ip="$(ip address show dev "${iface}" | grep "inet.*brd" | sed -e "s/^.*inet \([0-9.]\+\).*$/\1/")"
    if [ "${ssid}" = "3bb-wlan" ]; then
      if echo "${ip}" | grep -q "192\.168\.1\."; then echo "${ssid} is up"; else echo "${ssid} is down"; fi
    elif [ "${ssid}" = "Guest" ]; then
      if echo "${ip}" | grep -q "10\.10\.8\."; then echo "${ssid} is up"; else echo "${ssid} is down"; fi
    elif [ "${ssid}" = "Private" ]; then
      if echo "${ip}" | grep -q "10\.10\.1\."; then echo "${ssid} is up"; else echo "${ssid} is down"; fi
    fi
    null="$(dhclient -r "${iface}" 2>&1)"
    pids="$(ps ax | grep -w "[w]pa_supplicant" | sed "s/ .*//")"
    for pid in ${pids}; do kill -9 "${pid}"; done
    ip link set dev "${iface}" down
    rm -f "${file}"

3. Configuration

# Restart wireless networking.
# systemctl restart wpa_supplicant      # ???
wpa_cli -i wlan0 reconfigure
dhclient -r wlan0
dhclient -v wlan0

# Show wireless connection.
ifconfig wlan0
cat /lib/systemd/system/wpa_supplicant@.service
systemctl enable wpa_supplicant@wlan0.service
systemctl restart wpa_supplicant@wlan0.service
systemctl daemon-reload

systemctl restart wpa_supplicant@wlan0.service
systemctl status wpa_supplicant@wlan0.service

systemctl restart wpa_supplicant
systemctl status wpa_supplicant

4. Wifi drivers and firmware

4.1. Creation of USB device

  • Attach a USB device.

  • Create a "mikrotik" folder in the root directory of the USB device.

  • Copy the "mikrotik" file to the /mikrotik folder.

  • Copy the "python-httplib2_0.6.0-4_all.deb" file to the /mikrotik folder.

  • Copy the "python-httplib2_0.7.4-2_all.deb" file to the /mikrotik folder.

  • Detach the USB device.

  • Attach a USB device.

  • Create a "firmware" folder in the root directory of the USB device.

  • Extract the contents of the firmware.zip archive to the /firmware folder.

  • Detach the USB device.

5. Hotspot

5.1. Login script

5.1.1. Installation

  • Log in as user.

  • Start Terminal.

  • Attach the USB device with wifi drivers and wifi firmware.

  • Type sudo mount /dev/sdX# /mnt and press Enter.

  • Type sudo dpkg -i /mnt/firmware/firmware-ralink_0.36+wheezy.1_all.deb and press Enter.

  • Type sudo dpkg -i /mnt/firmware/firmware-realtek_0.36+wheezy.1_all.deb and press Enter.

    1. Type sudo dpkg -i /mnt/mikrotik/python-httplib2_0.6.0-4_all.deb and press Enter.

    2. Type sudo dpkg -i /mnt/mikrotik/python-httplib2_0.7.4-2_all.deb and press Enter.

  • Type sudo cp /mnt/mikrotik/mikrokit /usr/local/bin and press Enter.

  • Type sudo chmod 755 /usr/local/bin/mikrokit and press Enter.

  • Type sudo umount /mnt and press Enter.

  • Detach the USB device with wifi drivers and wifi firmware.

  • Optional: Type apt-get install wpasupplicant and press Enter.

  • Type sudo cp -a /usr/share/doc/wpasupplicant/examples/wpa-roam.conf /etc/wpa_supplicant and press Enter.

  • Type sudo cp -a /etc/wpa_supplicant/wpa-roam.conf /etc/wpa_supplicant/wpa-roam.conf.orig and press Enter.

  • Type sudo chmod 600 /etc/wpa_supplicant/wpa-roam.conf* and press Enter.

  • Type sudo cp -a /etc/network/interfaces /etc/network/interfaces.orig and press Enter.

  • Append the following lines to the /etc/network/interfaces file.

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
    wpa-roam /etc/wpa_supplicant/wpa-roam.conf

iface default inet dhcp
  • Type sudo invoke-rc.d networking restart and press Enter.

  • Type sudo ifconfig -a and press Enter.

  • Type sudo wpa_cli status and press Enter.

  • Optional: Type mikrotik <username> <password> to connect to the SMRU-Guest hotspot and press Enter.

  • Type ping www.google.com and press Enter.

  • Close Terminal.

6. USB Adapter

  • Note: For 3.6.11+ #538 and #541 use 8188eu-20130830.tar.gz For 3.6.11+ #524, #528 or #532 use 8188eu-20130815.tar.gz For 3.6.11+ #371 up to #520 use 8188eu-20130209.tar.gz

#577 - 8188eu-20131105.tar.gz https://dl.dropboxusercontent.com/u/80256631/8188eu-20131105.tar.gz
#579 - 8188eu-20131106.tar.gz https://dl.dropboxusercontent.com/u/80256631/8188eu-20131106.tar.gz
#585 - 8188eu-20131106.tar.gz https://dl.dropboxusercontent.com/u/80256631/8188eu-20131106.tar.gz
#585 - 8188eu-20131106.tar.gz https://dl.dropboxusercontent.com/u/80256631/8188eu-20131106.tar.gz
#587 - 8188eu-20131110.tar.gz https://dl.dropboxusercontent.com/u/80256631/8188eu-20131110.tar.gz
#590 - 8188eu-20131111.tar.gz https://dl.dropboxusercontent.com/u/80256631/8188eu-20131111.tar.gz
#592 - 8188eu-20131111.tar.gz https://dl.dropboxusercontent.com/u/80256631/8188eu-20131111.tar.gz
#594 - 8188eu-20131113.tar.gz https://dl.dropboxusercontent.com/u/80256631/8188eu-20131113.tar.gz
#596 - 8188eu-20131113.tar.gz https://dl.dropboxusercontent.com/u/80256631/8188eu-20131113.tar.gz

wget https://dl.dropboxusercontent.com/u/80256631/8188eu-201311xx.tar.gz   <-- select correct driver from list above
tar -zxvf 8188eu-201311xx.tar.gz                                           <-- select correct driver from list above
cat README                                  <-- view README file with firmware install details
cp rtl8188eufw.bin /lib/firmware/rtlwifi    <-- install firmware file if not already loaded
sudo install -p -m 644 8188eu.ko /lib/modules/3.10.18+/kernel/drivers/net/wireless
sudo insmod /lib/modules/3.10.18+/kernel/drivers/net/wireless/8188eu.ko
sudo depmod -a
wget https://dl.dropboxusercontent.com/u/80256631/8188eu-20130209.tar.gz
wget https://dl.dropboxusercontent.com/u/80256631/8188eu-20130815.tar.gz
wget https://dl.dropboxusercontent.com/u/80256631/8188eu-20130830.tar.gz
wget https://dl.dropboxusercontent.com/u/80256631/8188eu-20141107.tar.gz
cd /tmp
tar xfz -zxvf 8188eu-20130209.tar.gz
tar xfz -zxvf 8188eu-20130815.tar.gz
tar xfz -zxvf 8188eu-20130830.tar.gz

sudo install -p -m 644 8188eu.ko /lib/modules/3.11-2-amd64/kernel/drivers/net/wireless  # Linux LMDE
sudo insmod /lib/modules/3.11-2-amd64/kernel/drivers/net/wireless/8188eu.ko             # Linux LMDE
Error: could not insert module /lib/modules/3.11-2-amd64/kernel/drivers/net/wireless/8188eu.ko: Invalid module format
sudo install -p -m 644 8188eu.ko /lib/modules/3.6.11+/kernel/drivers/net/wireless       # Raspbian Wheezy
sudo insmod /lib/modules/3.6.11+/kernel/drivers/net/wireless/8188eu.ko                  # Raspbian Wheezy

sudo depmod -a
  • Close Terminal.

  • Log in as user.

  • Start Terminal.

  • Type sudo dpkg -i /media/sf_D_DRIVE/Install/MikroTik/python-httplib2_0.6.0-4_all.deb and press Enter.

  • Type sudo dpkg -i /media/sf_D_DRIVE/Install/MikroTik/python-httplib2_0.7.4-2_all.deb and press Enter.

  • Type sudo apt-get install python-httplib2 and press Enter. ???

  • Type sudo cp /media/sf_D_DRIVE/Software/MikroTik/mtlogin.py ~delta and press Enter.

  • Type sudo chown delta:delta ~delta/mtlogin.py and press Enter.

  • Type sudo chmod 755 ~delta/mtlogin.py and press Enter.

  • Close Terminal.

Usage of hotspot auto login script:

  • Log in as user.

  • Start Terminal.

  • Type python ~delta/mtlogin.py <username> <password> and press Enter.

  • Type ping www.google.com and press Enter.

  • Close Terminal.

7. Logoff of hotspot

  • Log in as user.

curl http://192.168.88.1/login | grep sendin.password | sed -e 's/^.*hexMD5(//' | sed -e 's/);$//' > /tmp/passwd
cat /tmp/passwd | sed -e "s/document.login.password.value/'PASSWORD'/" > /tmp/password

curl -d username=Staff-**** -d password=secret http://192.168.88.1/login > /tmp/login

8. Wireless Network

8.1. Configuration

USEFUL STUFF:

  • Attach the USB wifi adapter.

  • Log in as user.

  • Type su - and press Enter.

  • Type ifconfig -a and press Enter.

  • Type lsusb and press Enter.

  • Insert the debian-7.1.0-i386-CD-1.iso CD in the CDROM drive.

  • Type apt-get install wpasupplicant and press Enter.

  • Type apt-get install wireless-tools and press Enter.

  • Type eject /media/cdrom and press Enter.

  • Remove the CD from the CDROM drive.

  • Attach the USB device with wifi drivers and wifi firmware.

  • Type mount /dev/sdx# /mnt and press Enter.

  • Type dpkg -i /mnt/firmware/firmware-ralink_0.36+wheezy.1_all.deb and press Enter.

  • Type dpkg -i /mnt/firmware/firmware-realtek_0.36+wheezy.1_all.deb and press Enter.

  • Type dpkg -i /mnt/mikrotik/python-httplib2_0.7.4-2_all.deb and press Enter.

  • Type cp /mnt/mikrotik/mikrotik /usr/local/bin and press Enter.

  • Type chmod 755 /usr/local/bin/mikrotik and press Enter.

  • Type umount /mnt and press Enter.

  • Detach the external USB device with wifi drivers and wifi firmware.

  • Type cp -a /usr/share/doc/wpasupplicant/examples/wpa-roam.conf /etc/wpa_supplicant and press Enter.

  • Type cp -a /etc/wpa_supplicant/wpa-roam.conf /etc/wpa_supplicant/wpa-roam.conf.orig and press Enter.

  • Type [kbd]` wpa_passphrase smru-clinic <level l2 password> > /tmp/secret1` and press Enter.

  • Type [kbd]` wpa_passphrase SMRU-Dev <password> > /tmp/secret2` and press Enter.

  • Optional: Comment out the following lines in the /etc/wpa_supplicant/wpa-roam.conf file.

network={
    key_mgmt=NONE
}
  • Append the following lines to the /etc/wpa_supplicant/wpa-roam.conf file.

network={
    ssid="smru-clinic"
    key_mgmt=WPA-PSK
    proto=WPA RSN
    pairwise=TKIP CCMP
    group=TKIP CCMP
    psk=<passphrase>
    id_str="SMRU Clinic"
}

network={
    ssid="SMRU-Dev"
    key_mgmt=WPA-PSK
    proto=WPA RSN
    pairwise=TKIP CCMP
    group=TKIP CCMP
    psk=<passphrase>
    id_str="SMRU Development"
}
  • Type chmod 600 /etc/wpa_supplicant/wpa-roam.conf* and press Enter.

  • Append the following lines to the /etc/network/interfaces file.

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
    wpa-roam /etc/wpa_supplicant/wpa-roam.conf

iface wlan0 inet dhcp
  • Type invoke-rc.d networking restart and press Enter.

  • Type shutdown -r now and press Enter.

  • Log in as user.

  • Type su - and press Enter.

  • Type ifconfig -a and press Enter.

  • Type iwlist wlan0 scan | more and press Enter.

  • Type wpa_cli status and press Enter.

  • Optional: Type mikrotik <username> <password> to connect to the SMRU-Guest hotspot and press Enter.

  • Type ping www.google.com and press Enter.