Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have tried using ap-hotspot from WebUpd8, and it did not work for me in 13.10 or 14.04, so I have been working on getting hostapd manually set up, using isc-dhcp-server since dnsmasq was having conflicts for me. I have been able to connect to the AP, and get an IP, but routing does not seem to want to work. Here is my build log and the guides I have been following:

Config files:

/etc/network/interfaces:

auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet static
hostapd -dd /etc/hostapd/hostapd.conf
address 10.10.0.1
netmask 255.255.255.0

/etc/default/hostapd:

RUN_DAEMON="yes"
DAEMON_CONF="/etc/hostapd/hostapd.conf"
DAEMON_OPTS="-dd"

/etc/hostapd/hostapd.conf:

# WiFi Hotspot
interface=wlan0
driver=nl80211
#Access Point
ssid=workshop
hw_mode=g
# WiFi Channel:
channel=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=mypass
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

/etc/dhcp/dhcpd.conf:

ddns-update-style none;
#default-lease-time 600;
#max-lease-time 7200;
log-facility local7;
subnet 10.10.0.0 netmask 255.255.255.0 {
    range 10.10.0.2 10.10.0.32;
    option domain-name-servers 208.67.222.222, 208.67.220.220;
    option routers 10.10.0.1;
}

/etc/rc.local:

iptables -t nat -A POSTROUTING -s 10.10.0.0/32 -o eth1 -j MASQUERADE
exit 0

The following commands were run:

sudo ifconfig wlan0 10.10.0.1
sudo sysctl net.ipv4.ip_forward=1
sudo ip link set dev wlan0 up
sudo service hostapd start

I have installed bridge-utils, but I have not added br0 yet because I am not sure how to change the other parts of my config to reflect it...

Edit: After double checking my configs through another (older) guide, tried again and decided to add what shows up in the logs when something connects. The device connecting is my android phone, which connects fine through normal routers.

(I understand most of what is going on in the logs, and startup looks fine. Then scrolling randomness...)

Add randomness: count=52 entropy=51
mgmt::auth
authentication: STA=a0:f4:50:18:a2:c3 auth_alg=0 auth_transaction=1 status_code=0 wep=0
  New STA
wlan0: STA a0:f4:50:18:a2:c3 IEEE 802.11: authentication OK (open system)
wlan0: STA a0:f4:50:18:a2:c3 MLME: MLME-AUTHENTICATE.indication(a0:f4:50:18:a2:c3, OPEN_SYSTEM)
wlan0: STA a0:f4:50:18:a2:c3 MLME: MLME-DELETEKEYS.request(a0:f4:50:18:a2:c3)
authentication reply: STA=a0:f4:50:18:a2:c3 auth_alg=0 auth_transaction=2 resp=0 (IE len=0)
Add randomness: count=53 entropy=52
mgmt::auth cb
wlan0: STA a0:f4:50:18:a2:c3 IEEE 802.11: authenticated
mgmt::assoc_req
association request: STA=a0:f4:50:18:a2:c3 capab_info=0x431 listen_interval=20
  new AID 1
wlan0: STA a0:f4:50:18:a2:c3 IEEE 802.11: association OK (aid 1)
Add randomness: count=54 entropy=53
mgmt::assoc_resp cb
wlan0: STA a0:f4:50:18:a2:c3 IEEE 802.11: associated (aid 1)
wlan0: STA a0:f4:50:18:a2:c3 MLME: MLME-ASSOCIATE.indication(a0:f4:50:18:a2:c3)
wlan0: STA a0:f4:50:18:a2:c3 MLME: MLME-DELETEKEYS.request(a0:f4:50:18:a2:c3)
wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=0x9f8ac90 key_idx=0 set_tx=1 seq_len=0 key_len=0
   addr=a0:f4:50:18:a2:c3
wlan0: STA a0:f4:50:18:a2:c3 WPA: event 1 notification
wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=0x9f8ac90 key_idx=0 set_tx=1 seq_len=0 key_len=0
   addr=a0:f4:50:18:a2:c3
IEEE 802.1X: Ignore STA - 802.1X not enabled or forced for WPS
wlan0: STA a0:f4:50:18:a2:c3 WPA: start authentication
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state INITIALIZE
wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=0x9f8ac90 key_idx=0 set_tx=1 seq_len=0 key_len=0
   addr=a0:f4:50:18:a2:c3
wlan0: STA a0:f4:50:18:a2:c3 IEEE 802.1X: unauthorizing port
WPA: a0:f4:50:18:a2:c3 WPA_PTK_GROUP entering state IDLE
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state AUTHENTICATION
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state AUTHENTICATION2
WPA: Re-initialize GMK/Counter on first station
Get randomness: len=32 entropy=54
GMK - hexdump(len=32): [REMOVED]
Get randomness: len=32 entropy=22
Key Counter - hexdump(len=32): [REMOVED]
Get randomness: len=16 entropy=0
GTK - hexdump(len=16): [REMOVED]
wpa_driver_nl80211_set_key: ifindex=3 alg=3 addr=0x80dd6be key_idx=1 set_tx=1 seq_len=0 key_len=16
   broadcast key
WPA: Assign ANonce - hexdump(len=32): 12 53 6f 26 8a a3 87 09 b4 31 e2 81 ef c3 ea 3e 6c 3d 0c a5 fb 85 07 f2 0a 2a 4a 5e a2 00 59 e9
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state INITPSK
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state PTKSTART
wlan0: STA a0:f4:50:18:a2:c3 WPA: sending 1/4 msg of 4-Way Handshake
WPA: Send EAPOL(version=2 secure=0 mic=0 ack=1 install=0 pairwise=8 kde_len=0 keyidx=0 encr=0)
WPA: Use EAPOL-Key timeout of 100 ms (retry counter 1)
nl80211: Event message available
nl80211: New station a0:f4:50:18:a2:c3
IEEE 802.1X: a0:f4:50:18:a2:c3 TX status - version=2 type=3 length=95 - ack=1
WPA: EAPOL-Key TX status for STA a0:f4:50:18:a2:c3 ack=1
WPA: Increase initial EAPOL-Key 1/4 timeout by 1000 ms because of acknowledged frame
IEEE 802.1X: 121 bytes from a0:f4:50:18:a2:c3
   IEEE 802.1X: version=1 type=3 length=117
WPA: Received EAPOL-Key from a0:f4:50:18:a2:c3 key_info=0x10a type=2 key_data_length=22
WPA: Received Key Nonce - hexdump(len=32): 7c 4d 99 9f 10 56 93 84 a9 8a f8 15 d8 8e 1e 6d 2f 39 95 8f bc 99 9a 4c 06 3d 37 65 e6 db 49 fa
WPA: Received Replay Counter - hexdump(len=8): 00 00 00 00 00 00 00 01
Add randomness: count=55 entropy=0
wlan0: STA a0:f4:50:18:a2:c3 WPA: received EAPOL-Key frame (2/4 Pairwise)
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state PTKCALCNEGOTIATING
WPA: PTK derivation - A1=90:4c:e5:55:94:4d A2=a0:f4:50:18:a2:c3
WPA: Nonce1 - hexdump(len=32): 12 53 6f 26 8a a3 87 09 b4 31 e2 81 ef c3 ea 3e 6c 3d 0c a5 fb 85 07 f2 0a 2a 4a 5e a2 00 59 e9
WPA: Nonce2 - hexdump(len=32): 7c 4d 99 9f 10 56 93 84 a9 8a f8 15 d8 8e 1e 6d 2f 39 95 8f bc 99 9a 4c 06 3d 37 65 e6 db 49 fa
WPA: PMK - hexdump(len=32): [REMOVED]
WPA: PTK - hexdump(len=48): [REMOVED]
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state PTKCALCNEGOTIATING2
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state PTKINITNEGOTIATING
wlan0: STA a0:f4:50:18:a2:c3 WPA: sending 3/4 msg of 4-Way Handshake
WPA: Send EAPOL(version=2 secure=1 mic=1 ack=1 install=1 pairwise=8 kde_len=46 keyidx=1 encr=1)
Plaintext EAPOL-Key Key Data - hexdump(len=56): [REMOVED]
WPA: Use EAPOL-Key timeout of 100 ms (retry counter 1)
IEEE 802.1X: a0:f4:50:18:a2:c3 TX status - version=2 type=3 length=151 - ack=1
WPA: EAPOL-Key TX status for STA a0:f4:50:18:a2:c3 ack=1
IEEE 802.1X: 99 bytes from a0:f4:50:18:a2:c3
   IEEE 802.1X: version=1 type=3 length=95
WPA: Received EAPOL-Key from a0:f4:50:18:a2:c3 key_info=0x30a type=2 key_data_length=0
WPA: Received Key Nonce - hexdump(len=32): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
WPA: Received Replay Counter - hexdump(len=8): 00 00 00 00 00 00 00 02
wlan0: STA a0:f4:50:18:a2:c3 WPA: received EAPOL-Key frame (4/4 Pairwise)
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state PTKINITDONE
wpa_driver_nl80211_set_key: ifindex=3 alg=3 addr=0x9f8ac90 key_idx=0 set_tx=1 seq_len=0 key_len=16
   addr=a0:f4:50:18:a2:c3
wlan0: AP-STA-CONNECTED a0:f4:50:18:a2:c3
wlan0: STA a0:f4:50:18:a2:c3 IEEE 802.1X: authorizing port
wlan0: STA a0:f4:50:18:a2:c3 RADIUS: starting accounting session 536C1843-00000000
wlan0: STA a0:f4:50:18:a2:c3 WPA: pairwise key handshake completed (RSN)
Add randomness: count=56 entropy=1

(more randomness, until I ctrl+c)

share|improve this question

Try the following

sudo apt-get install hostapd dnsmasq dhcp3-server isc-dhcp-server haveged

Setting up hostapd

hostapd is for wireless router functionality:

leafpad /etc/hostapd.conf

General Hotspot Configurations:

Define interface

interface=wlan#
bridge=br0

Select driver:

driver=nl80211

Set access point hardware mode to 802.11a/b/g/n (hw supports?):

hw_mode=g
logger_stdout=-1
logger_stdout_level=2
require_ht=0
ht_capab= [HT40+] [HT40-] [SHORT-GI-40] [RX-STBC1]
ieee80211d=1
ieee80211n=1
macaddr_acl=0
wmm_enabled=1

Configure wireless characteristics:

beacon_int=50
country_code=US
disassoc_low_ack=1

Set Wi-Fi channel:

channel=6

Set access point name:

ssid=nametobroacdcast
ignore_broadcast_ssid=0

Set encryption standard (1 for WPA, 2 for WPA2, 3 for WPA + WPA2):

auth_algs=1
wpa=3
wpa_passphrase=yourpassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP

Other options for wpa_key_mgmt=WPA-EAP WPA-PSK-SHA256 WPA-EAP-SHA256


Create & save ./######.sh script

#!/bin/bash
# Configure IP address for WLAN
sudo ifconfig wlan0 up 192.168.3.1 netmask 255.255.255.0
sleep 2

# Start DHCP/DNS server (Can replace `dnsmasq` with `dhcpd` or `isc-hdcp-server`):
sudo service dnsmasq restart

# Replace "dnsmasq restart" line above with this area between ## ## if that does not work
if [ “$(ps –e | grep dhcpd)” == “” ]; then
dhcpd $1 &
fi

# Enable routing
sudo sysctl net.ipv4.ip_forward=1

# Enable Network Address Translation (NAT)
sudo iptables --flush
sudo iptables –-table nat --flush
sudo iptables --delete-chain
sudo iptables --table nat --delete-chain
sudo iptables --table nat --flush
sudo iptables -t nat -A POSTROUTING --out –interface $1 -j MASQUERADE

# “$1” = computer acting as AP output interface (to internet)
sudo iptables –A FORWARD –in-interface $2 –j ACCEPT

# “$2” = client input interface (to client)
echo 1 > /proc/sys/net/ipv4/ipforward

# Run access point daemon
sudo hostapd /etc/hostapd.conf

# Stopping DHCP/DNS server

# Disable NAT
sudo iptables -D POSTROUTING -t nat -o ppp0 -j MASQUERADE

# Disable routing
sudo sysctl net.ipv4.ip_forward=0

# Disable DHCP/DNS server
sudo service dnsmasq stop
# Can replace with “dhcpd” or “isc-hdcp-server”

# Start HOSTAPD
sudo service hostapd start

Start setup DNS/DHCP

dnsmasq dhcp3-server isc-dhcp-server is for DNS/DHCP functionality (choose one):

Example:

leafpad /etc/dhcp/dhcpd.conf

General DHCP Configurations:

ddns-update-style none;
ignore clients-updates;
authoritative;
option local-wpad code 252 = test;
log-facility local7;
default-lease-time 3600;
max-lease-time 7200;
subnet
192.168.3.0 netmask 255.255.255.0 {
    # Broadcast address
    option broadcast-address 192.168.3.2;
    # Netmask
    option subnet-mask 255.255.255.0;
    # Default gateway
    option routers 192.168.3.1;

    # Domain Name Servers for directing client traffic 
    option domain-name-servers 8.8.8.8, 8.8.4.4;
    option time-offset 0;

    # Set IP address range available to clients
    range 192.168.3.2, 192.168.3.100;
}

Allow ./#####.sh script created to run

Make hostapdfilecreated.sh executable:

sudo chmod +x nameoffilecreated.sh

You have to be inside the directory where ######.sh file resides, cd into it then run command.

Execute script to start computer-based access point broadcasting:

sudo ./nameoffilecreated.sh
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.