=====Wireless Access Point====== ** This application note is applicable to the C1/XU4/C2 Ubuntu/Linux Platforms. ** One user (tam1111574) reported there was an issue with USB 3.0 port on the XU4.\\ [[http://forum.odroid.com/viewtopic.php?f=97&t=19285]] **Hostapd** hostapd is a user space daemon for access point and authentication servers. It implements IEEE 802.11 access point management, IEEE 802.1X/WPA/WPA2/EAP Authenticators, RADIUS client, EAP server, and RADIUS authentication server. **Odroid Wireless Cards** All most all the wireless card have capability of configuration as Access Point. # iwlist If there is 'AP' in the list of "Supported interface modes" your device will support the Access Point mode with hostapd. ... Supported interface modes: * IBSS * managed * AP * AP/VLAN * WDS * monitor * mesh point **Wifi Module 3** Manufacturer: Realtek Part name: RTL8188CUS Type: chip Number of busses: 1 Bus(es): USB 2.0 Number of bands: 1 Band(s): 2.4GHz Data rate: 150Mbps MIMO configuration: 1x1:1 (1T1R) IEEE 802.11 PHY Modes: b,g,n Bus 001 Device 003: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter Please find more information on [[https://wireless.wiki.kernel.org/en/users/documentation/hostapd]] **Wifi Module 4** Manufacturer: Ralink Part name: RT5572 Type: chip Number of busses: 1 Bus(es): USB 2.0 Number of bands: 2 Band(s): 2.4GHz, 5GHz Data rate: 300Mbps MIMO configuration: 2x2:2 (2T2R) IEEE 802.11 PHY Modes: a,b,g,n Bus 001 Device 006: ID 148f:5572 Ralink Technology, Corp. RT5572 Wireless Adapter =======Configure Access Point===== **Configure Wireless network interface and Dnsmasq demon.** In order to configure Wireless Access Point you need to provide static IPaddress to Wireless network card. # cat /etc/network/interfaces # interfaces(5) file used by ifup(8) and ifdown(8) # Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp auto wlan0 iface wlan0 inet static address 192.168.1.1 netmask 255.255.255.0 **Note:** wlan0 ipaddress should be different from your router. **Note:** wireless interface name can change depend on wireless cards. **Configure DHCP server required for Access Point.** We configure dnsmasq light weight dhcp and dns server. sudo apt-get install --reinstall dnsmasq $ sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig $ sudo nano /etc/dnsmasq.conf domain-needed bogus-priv no-resolv no-poll server=/example.com/192.168.1.5 server=8.8.8.8 server=4.4.4.4 local=/example.com/ address=/doubleclick.net/127.0.0.1 no-hosts #addn-hosts=/etc/dnsmasq.d/hosts.conf expand-hosts domain=example.com dhcp-range=192.168.1.20,192.168.1.50,72h dhcp-range=tftp,192.168.1.250,192.168.1.254 dhcp-option=option:router,192.168.1.1 dhcp-option=option:ntp-server,192.168.1.5 dhcp-option=19,0 # ip-forwarding off dhcp-option=44,192.168.1.5 # set netbios-over-TCP/IP aka WINS dhcp-option=45,192.168.1.5 # netbios datagram distribution server dhcp-option=46,8 # netbios node type **Note:** Reconfigure dnsmasq: You can extend the dhcp-range or change the ipaddress in the configuration. ======Configuration for Wifi Module 0====== HostAP demon configration for Ralink RT5370 module only. **Pre software requirement for building hostapd.** sudo apt-get install libnl-3-dev libnl-genl-3-dev libssl-dev hostapd iptables =====Hostapd Configuration file for Access Point===== sudo nano /etc/default/hostapd DAEMON_CONF="/etc/hostapd/hostapd.conf" DAEMON_OPTS="-B" **Note:** You can update this DAEMON_OPTS to get the logs from Hostapd demon. cat /etc/hostapd/hostapd.conf interface=wlan0 driver=nl80211 ssid=ODROID_AP hw_mode=g channel=6 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_passphrase=hardkernel wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP ======Configuration for Wifi Module 3====== HostAP demon configration for Realtek RTL8192CU module only. **Pre software requirement for building hostapd.** sudo apt-get install libnl-3-dev libnl-genl-3-dev libssl-dev hostapd iptables git-core pkg-config **Download the latest hostapd source code and patch for RTL8192CU.** Steps to get the hostapd compilation. **Note:** Realtek RTL8192CU do not support the standard nl80211 driver of hostapd. $ git clone https://github.com/pritambaral/hostapd-rtl871xdrv.git $ $ wget https://w1.fi/releases/hostapd-2.6.tar.gz $ tar xvfz hostapd-2.6.tar.gz $ cd hostapd-2.6 $ patch -p1 < ../hostapd-rtl871xdrv/rtlxdrv.patch $ cd hostapd $ cp defconfig .config $ echo CONFIG_LIBNL32=y >> .config $ echo CONFIG_DRIVER_RTW=y >> .config $ $ make Backup the hostapd demon. Replace the demon with configured one. $ sudo cp /usr/sbin/hostapd /usr/sbin/hostapd.back $ sudo cp hostapd /usr/sbin/hostapd Verify that you have installed the latest version $ /usr/sbin/hostapd -v hostapd v2.6 for Realtek rtl871xdrv User space daemon for IEEE 802.11 AP management, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator Copyright (c) 2002-2016, Jouni Malinen and contributors =====Hostapd Configuration file for Access Point===== sudo nano /etc/default/hostapd DAEMON_CONF="/etc/hostapd/hostapd.conf" DAEMON_OPTS="-B" **Note:** You can update this DAEMON_OPTS to get the logs from Hostapd demon. sudo nano /etc/hostapd/hostapd.conf # interface interface=wlan0 # driver driver=rtl871xdrv # CTRL-Interface ctrl_interface=/var/run/hostapd ctrl_interface_group=0 # SSID ssid=OdroidAP # WLAN country_code=KR hw_mode=g channel=1 beacon_int=100 dtim_period=2 max_num_sta=255 rts_threshold=2347 fragm_threshold=2346 preamble=1 # Logging logger_syslog=-1 logger_syslog_level=3 logger_stdout=-1 logger_stdout_level=2 # passphrase wpa_passphrase=hardkernel # WPA2 wpa=3 wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP beacon_int=100 auth_algs=3 # 1=wpa, 2=wep, 3=both macaddr_acl=0 wmm_enabled=1 eap_reauth_period=360000000 rsn_preauth=1 rsn_preauth_interfaces=wlan0 wpa_group_rekey=600 wpa_ptk_rekey=600 wpa_gmk_rekey=86400 **Note:** Replace the country_code, ssid, and wpa_passphrase as per your requirement. **Note:** Latest kernel 4.9.x have 8192cu module driver which do not support Access point, so we need to rebuild Realtek driver to support Access Point. Please use the following link to build and install the kernel module https://forum.odroid.com/viewtopic.php?f=146&t=27287#p192844 ======Configuration for Wifi Module 4 and Wifi Module 5====== Wifi Module 4: HostAP demon configuration for Ralink Technology, Corp. RT5572 Wireless Adapter. Wifi Module 5: HostAP demon configuration for Realtek RTL8812AU chipset. **Pre software requirement for building hostapd.** sudo apt-get install libnl-3-dev libnl-genl-3-dev libssl-dev hostapd iptables pkg-config **Download the latest hostapd source code** Steps to get the hostapd compilation. **Note:** Ralink Technology, Corp. RT5572 Wireless Adapter do not support the standard nl80211 driver of hostapd. $ wget https://w1.fi/releases/hostapd-2.6.tar.gz $ tar xvfz hostapd-2.6.tar.gz $ cd hostapd-2.6 $ cd hostapd $ cp defconfig .config $ echo CONFIG_LIBNL32=y >> .config $ echo CONFIG_IEEE80211N=y >> .config $ make Backup the hostapd demon. Replace the demon with configured one. $ cp /usr/sbin/hostapd /usr/sbin/hostapd.back $ cp hostapd /usr/sbin/hostapd Verify that you have installed the latest version hostapd v2.6 User space daemon for IEEE 802.11 AP management, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator Copyright (c) 2002-2016, Jouni Malinen and contributors =====Hostapd Configuration file for Access Point===== sudo nano /etc/default/hostapd DAEMON_CONF="/etc/hostapd/hostapd.conf" DAEMON_OPTS="-B" **Note:** You can update this DAEMON_OPTS to get the logs from Hostapd demon. cat /etc/hostapd/hostapd.conf ** Hostapd configuration for 2.4Ghz configuration ** # HostAPD # Interface interface=wlan0 # driver driver=nl80211 # Logging logger_syslog=-1 logger_syslog_level=3 logger_stdout=-1 logger_stdout_level=2 # CTRL-Interface ctrl_interface=/var/run/hostapd ctrl_interface_group=0 # WLAN country_code=KR ssid=OdroidAPn hw_mode=g channel=6 beacon_int=100 dtim_period=2 max_num_sta=255 rts_threshold=2347 fragm_threshold=2346 preamble=1 # WPA2 wpa=2 # WPA2 only wpa_passphrase=hardkernel wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP auth_algs=3 # 1=wpa, 2=wep, 3=both macaddr_acl=0 wmm_enabled=1 eap_reauth_period=360000 fragm_threshold=2346 rsn_preauth=1 rsn_preauth_interfaces=wlan0 wpa_group_rekey=600 wpa_ptk_rekey=600 wpa_gmk_rekey=86400 # N-WLAN ieee80211n=1 ht_capab=[HT20+][SHORT-GI-20][DSSS_CCK-20] require_ht=0 obss_interval=0 ** Hostapd configuration for 5Ghz configuration ** ### hostapd configuration file ctrl_interface=/var/run/hostapd ctrl_interface_group=0 interface=wlan0 driver=nl80211 ### IEEE 802.11 ssid=Odroid5Ghz hw_mode=a channel=36 max_num_sta=128 auth_algs=1 ### DFS country_code=KR ieee80211d=1 ieee80211h=1 #ieee80211ac=1 ### IEEE 802.11n ieee80211n=1 ht_capab=[HT40+][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-20] ### IEEE 802.11ac #ieee80211ac=1 #vht_oper_chwidth=1 #vht_capab=[SHORT-GI-40][RXLDPC][TX-STBC-2BY1] #vht_oper_centr_freq_seg0_idx=0 ### IEEE 802.11i wpa=2 wpa_key_mgmt=WPA-PSK wpa_passphrase=hardkernel rsn_pairwise=CCMP ### hostapd event logger logger_syslog=-1 logger_syslog_level=2 logger_stdout=-1 logger_stdout_level=2 ### WMM wmm_enabled=1 uapsd_advertisement_enabled=1 wmm_ac_bk_cwmin=4 wmm_ac_bk_cwmax=10 wmm_ac_bk_aifs=7 wmm_ac_bk_txop_limit=0 wmm_ac_bk_acm=0 wmm_ac_be_aifs=3 wmm_ac_be_cwmin=4 wmm_ac_be_cwmax=10 wmm_ac_be_txop_limit=0 wmm_ac_be_acm=0 wmm_ac_vi_aifs=2 wmm_ac_vi_cwmin=3 wmm_ac_vi_cwmax=4 wmm_ac_vi_txop_limit=94 wmm_ac_vi_acm=0 wmm_ac_vo_aifs=2 wmm_ac_vo_cwmin=2 wmm_ac_vo_cwmax=3 wmm_ac_vo_txop_limit=47 wmm_ac_vo_acm=0 ### TX queue parameters tx_queue_data3_aifs=7 tx_queue_data3_cwmin=15 tx_queue_data3_cwmax=1023 tx_queue_data3_burst=0 tx_queue_data2_aifs=3 tx_queue_data2_cwmin=15 tx_queue_data2_cwmax=63 tx_queue_data2_burst=0 tx_queue_data1_aifs=1 tx_queue_data1_cwmin=7 tx_queue_data1_cwmax=15 tx_queue_data1_burst=3.0 tx_queue_data0_aifs=1 tx_queue_data0_cwmin=3 tx_queue_data0_cwmax=7 tx_queue_data0_burst=1.5 **Note:** Depending on the ht_capab with the Wifi module4 and Wifi moudule5 we need to tune these setting. **Note:** Replace the country_code, ssid, and wpa_passphrase as per your requirement. **Note:** Depend on the wireless interface you need to update the configuration file. **Note:** N-WLAN is optional can be dropped out. ====== Setting for forwarding Internet over WIFI from eth0====== Next, have port forwarding enabled automatically on boot up. sudo nano /etc/sysctl.conf net.ipv4.ip_forward = 1 net.ipv6.conf.all.forwarding = 1 **Access Internet over WIFI.** sudo nano /etc/rc.local sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT **Note:** Depend on the wireless network interface name update the iptables rules. **Enable hostapd service on every boot.** sudo update-rc.d hostapd enable **Confirmatioon of Hostapd service is running** **On ubuntu 14.04.x check the service status as follows** $ service hostapd restart * Stopping advanced IEEE 802.11 management hostapd [ OK ] * Starting advanced IEEE 802.11 management hostapd [ OK ] $ service hostapd status * hostapd is running **on Ubuntu 16.04.x check the service status as follows** $ sudo systemctl status hostapd.service ● hostapd.service - LSB: Advanced IEEE 802.11 management daemon Loaded: loaded (/etc/init.d/hostapd; bad; vendor preset: enabled) Active: active (running) since Sun 2017-07-09 19:48:41 UTC; 31s ago Docs: man:systemd-sysv-generator(8) Process: 789 ExecStart=/etc/init.d/hostapd start (code=exited, status=0/SUCCESS) CGroup: /system.slice/hostapd.service └─798 /usr/sbin/hostapd -B -P /run/hostapd.pid -B /etc/hostapd/hostapd-2.6.conf Jul 09 19:48:41 odroid systemd[1]: Starting LSB: Advanced IEEE 802.11 management daemon... Jul 09 19:48:41 odroid hostapd[789]: * Starting advanced IEEE 802.11 management hostapd Jul 09 19:48:41 odroid hostapd[789]: ...done. Jul 09 19:48:41 odroid systemd[1]: Started LSB: Advanced IEEE 802.11 management daemon. $ $ $ sudo systemctl status dnsmasq.service ● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled) Drop-In: /run/systemd/generator/dnsmasq.service.d └─50-dnsmasq-$named.conf, 50-insserv.conf-$named.conf Active: active (running) since Sun 2017-07-09 19:48:31 UTC; 4min 36s ago Process: 592 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=exited, status=0/SUCCESS) Process: 575 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0/SUCCESS) Process: 554 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS) Main PID: 591 (dnsmasq) CGroup: /system.slice/dnsmasq.service └─591 /usr/sbin/dnsmasq -x /var/run/dnsmasq/dnsmasq.pid -u dnsmasq -r /var/run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old, Jul 09 19:48:30 odroid dnsmasq[591]: DNS service limited to local subnets Jul 09 19:48:30 odroid dnsmasq[591]: warning: ignoring resolv-file flag because no-resolv is set Jul 09 19:48:30 odroid dnsmasq-dhcp[591]: DHCP, IP range 192.168.1.250 -- 192.168.1.254, lease time 1h Jul 09 19:48:30 odroid dnsmasq-dhcp[591]: DHCP, IP range 192.168.1.20 -- 192.168.1.50, lease time 3d Jul 09 19:48:30 odroid dnsmasq[591]: using local addresses only for domain example.com Jul 09 19:48:30 odroid dnsmasq[591]: using nameserver 4.4.4.4#53 Jul 09 19:48:30 odroid dnsmasq[591]: using nameserver 8.8.8.8#53 Jul 09 19:48:30 odroid dnsmasq[591]: using nameserver 192.168.1.5#53 for domain example.com Jul 09 19:48:30 odroid dnsmasq[591]: cleared cache Jul 09 19:48:31 odroid systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server. lines 1-22/22 (END)