Eu configurei com sucesso um USB wlan1
como AP via hostapd
, e isc-dhcpd
(ele escuta apenas wlan1
-interface) em um Raspberry 4 (usando Raspbian). Independentemente de wlan0
(o WIFI integrado) estar conectado a um ponto de acesso WAN, wlan1
os clientes podem fazer ping nessa wlan1
interface. IP Forwarding/masquerade funciona, e se wlan0
estiver conectado a WAN AP, wlan1
os clientes também têm acesso à internet. Perfeito!
Mas no momento em que eu plugo eth0
, wlan1
os clientes ainda podem se conectar a esse AP (Status connected
), mas NÃO podem wlan1
mais PING nessa interface (e nenhum acesso WAN mais). Isso é estranho! O servidor DHCP enviou os mesmos IPs válidos para o cliente como antes, e o IP estático wlan1
também permanece o mesmo ( eth0
e wlan1
tem IP estático). wlan1
pode ser pingado localmente do rapsberry (mas não de um cliente externo).
Quando eu desligo eth0
, ele funciona novamente.
O que está acontecendo de errado e por que não consigo mais fazer ping nessa interface?
O encaminhamento de IPv4 do sysctl está ativado.
...
$ ip link
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
4: wlan1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
...
$ ip addr
...
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether e4:5f:01:84:db:34 brd ff:ff:ff:ff:ff:ff
inet 10.8.0.2/8 brd 10.255.255.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
...
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether e4:5f:01:84:db:37 brd ff:ff:ff:ff:ff:ff
4: wlan1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether a0:f3:c1:23:2d:62 brd ff:ff:ff:ff:ff:ff
inet 10.8.5.1/8 brd 10.255.255.255 scope global noprefixroute wlan1
valid_lft forever preferred_lft forever
...
$nft list ruleset
...
table ip nat {
chain postrouting {
type nat hook postrouting priority srcnat; policy accept;
masquerade
}
}
...
$ cat /etc/hostapd/hostapd.conf
interface=wlan1
#If this fails, try rt1871xdrv a
#driver=nl80211
# Name of the new network: best use the hostname
ssid=xxx
# Pick a channel not already in use
channel=1
# Change to b for older devices?
hw_mode=g
macaddr_acl=0
auth_algs=3
# Disable this to insure the AP is visible:
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=xxx
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
#bridge=br0 # no bridge! We're using routing
country_code=JP
cat /etc/dhcpcd.conf
...
interface eth0
static ip_address=10.8.0.2/8
static routers=10.8.0.1
static domain_name_servers=127.0.0.1
interface wlan1
static ip_address=10.8.5.1/8
nohook wpa_supplicant
static domain_name_servers=127.0.0.1
interface wlan0
static domain_name_servers=127.0.0.1
cat /etc/dhcp/dhcpd.conf
...
authoritative;
subnet 10.8.5.0 netmask 255.255.255.0 {
range 10.8.5.201 10.8.5.250;
option broadcast-address 10.8.5.255;
option routers 10.8.5.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local";
option domain-name-servers 10.8.5.1;
}
host ares {
hardware ethernet 04:ea:56:ae:58:03;
fixed-address 10.8.5.20;
}
$ ipconfig # on Windows 11 Client
...
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . : local
Description . . . . . . . . . . . : Intel(R) Dual Band Wireless-AC 8265
Physical Address. . . . . . . . . : 04-EA-56-AE-58-03
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::9300:7ccf:3e03:eaf9%17(Preferred)
IPv4 Address. . . . . . . . . . . : 10.8.5.20(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Friday, 16 December 2022 22:56:38
Lease Expires . . . . . . . . . . : Friday, 16 December 2022 23:06:37
Default Gateway . . . . . . . . . : 10.8.5.1
DHCP Server . . . . . . . . . . . : 10.8.5.1
DHCPv6 IAID . . . . . . . . . . . : 168094294
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-26-1E-05-25-48-2A-E3-3A-C9-F0
DNS Servers . . . . . . . . . . . : 10.8.5.1
NetBIOS over Tcpip. . . . . . . . : Enabled
...