Score:0

USB wlan1 Hotspot stops working when eth0 cable is plugged in

br flag

I setup successfully an USB wlan1 as AP via hostapd, and isc-dhcpd (it listens only to wlan1-interface) on a Raspberry 4 (using Raspbian). Regardless if wlan0 (the onboard WIFI) is connected to a WAN hotspot, wlan1 Clients can ping that wlan1 interface. IP Forwarding/masquerade works, and if wlan0 is connected to WAN AP, wlan1 clients also have internet access. Perfect!

But in the moment i plug-in eth0, wlan1 clients can still connect to that AP (Status connected), but can NOT PING that wlan1 interface anymore (and no WAN access anymore). That's weird! The DHCP Server pushed the same valid IP's to the client as before, and static IP of wlan1 also stays the same (eth0 and wlan1 have static IP). wlan1 can be pinged locally from the rapsberry (but not from an external client).

When i un-plug eth0, it work's again.

What's going wrong and why i canot even ping that interface anymore?

sysctl IPv4 forwarding is enabled.

...
$ 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
...
Score:1
ar flag

Your IP addresses are:

  • 10.8.0.2/8 for wlan1
  • 10.8.5.1/8 for eth0

Those are in the same subnet. 10.0.0.0/8 covers everything from 10.0.0.0 to 10.255.255.255.

Yet, on your DHCP scope, the netmask is suddenly /24.

The general rule is that if you want to send traffic within a subnet, you need a switch (bridge), while you need a router to send traffic between subnets. When your machine gets a packet from one of your connected clients - which believe 10.8.5.0/24 is a subnet, it doesn't understand what to do with it, as it's addressed to a host in the same subnet as the originator.

You probably want /24 defined everywhere, so replace the netmask for eth0 and wlan1 with /24, not /8.

As to observed behavior: routes carry a weight. Faster interfaces float to the top. Your machine believes wlan1 and eth0 both point to the same destination. Thus, it sends the packet over the best interface (lowest weight in the routing table), which is the wired Ethernet interface. If it was properly configured with separate subnets, it'll work just fine.

br flag
That's it! Yea, i accidentally mixed-up `/8` with `/24`. After changing to `/24`, the AP is pingable. But now I have another problem: The Clients do not have WAN access anymore (but the server has)
vidarlo avatar
ar flag
Your wan router doesn't have a valid route to your clients behind the pi. And you should probably accept the answer so we avoid having the question popping up every few months...
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.