Obtendo WiFi AP trabalhando com hostapd e isc-dhcp-server [Xubuntu 14.04]

5

Eu tentei usar o ap-hotspot do WebUpd8, e ele não funcionou para mim no 13.10 ou no 14.04, então tenho trabalhado para configurar manualmente o hostapd, usando isc-dhcp-server , pois o dnsmasq estava tendo conflitos para mim. Eu consegui me conectar ao AP e obter um IP , mas o roteamento não parece querer funcionar. Aqui está o meu log de criação e os guias que venho seguindo:

Arquivos de configuração:

/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

Os seguintes comandos foram executados:

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

Instalei bridge-utils , mas ainda não adicionei br0 porque não sei como alterar as outras partes da minha configuração para refletir isso ...

Editar: Depois de verificar novamente minhas configurações através de outro guia (mais antigo), tentei novamente e decidi adicionar o que aparece nos logs quando algo se conecta. O dispositivo de conexão é o meu telefone Android, que se conecta bem através de roteadores normais.

(Eu entendo a maior parte do que está acontecendo nos logs, e a inicialização parece bem. Em seguida, role a aleatoriedade ...)

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

(mais aleatoriedade, até ctrl + c)

    
por Cyndre 07.05.2014 / 22:22

1 resposta

0

Tente o seguinte

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

Configurando o hostapd

O hostapd é para a funcionalidade do roteador sem fio:

leafpad /etc/hostapd.conf

Configurações gerais de pontos de acesso:

Definir interface

interface=wlan#
bridge=br0

Selecione o driver:

driver=nl80211

Defina o modo de hardware de ponto de acesso como 802.11a / b / g / n (hw suporta?):

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 as características sem fio:

beacon_int=50
country_code=US
disassoc_low_ack=1

Definir o canal de Wi-Fi:

channel=6

Definir nome do ponto de acesso:

ssid=nametobroacdcast
ignore_broadcast_ssid=0

Defina o padrão de criptografia (1 para WPA, 2 para WPA2, 3 para WPA + WPA2):

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

Outras opções para wpa_key_mgmt = WPA-EPA WPA-PSK-SHA256 WPA-EAP-SHA256

Crie & amp; salvar ./######.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  &
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  -j MASQUERADE

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

# “” = 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

Iniciar a configuração DNS / DHCP

dnsmasq dhcp3-server O isc-dhcp-server é para funcionalidade DNS / DHCP (escolha um):

Exemplo:

leafpad /etc/dhcp/dhcpd.conf

Configurações gerais do DHCP:

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;
}

Permitir que o script ./#####.sh criado seja executado

Tornar hostapdfilecreated.sh executável:

sudo chmod +x nameoffilecreated.sh

Você tem que estar dentro do diretório em que ######.sh arquivo reside, cd nele, então execute o comando.

Execute o script para iniciar a transmissão do ponto de acesso baseado em computador:

sudo ./nameoffilecreated.sh
    
por SierraJuliet 15.06.2016 / 04:24