Hi,
i'm trying to achieve something with my Raspberry Pi 3B and an Android phone. Unfortunately I'm stuck. I think the real problem is the Android 10's routing, because the AP that I create on my Raspberry works with a laptop. Anyway I try to summarize what I've learned about the problem, and maybe you might come up with a solution/workaround.
First, I have a WiFi OBD (on board diagnostic) that creates a network.
gateway: 192.168.0.10, subnet 255.255.255.0
dns: 192.168.0.10
ip route show (on my phone)
192.168.0.0/24 dev wlan0 proto kernel scope link src 192.168.0.19
If I connect to this network with my phone, I must turn off the mobil data first, then I can ping 192.168.0.10 and I also able to communicate with the obd interface. Unfortunately If I connect more devices, the devices can't ping each other just the gateway. So my idea: raspberry connects to the Wifi_OBDII network and simultaneously creates an AP. My service on pi can communicate with the obd interface, and my phone can communicate with the pi. The phone doesn't need to access the obd interface.
More info on WiFi_OBDII (from my laptop)
Nmap scan report for 192.168.0.10
Host is up (0.018s latency).
Not shown: 999 filtered ports
PORT STATE SERVICE
30000/tcp open ndmps
$ip a
3: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 34:f3:9a:a3:ee:36 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.20/24 brd 192.168.0.255 scope global dynamic noprefixroute wlp1s0
valid_lft 86343sec preferred_lft 75543sec
inet6 fe80::36f3:9aff:fea3:ee36/64 scope link
valid_lft forever preferred_lft forever
$ip route show
default via 192.168.0.10 dev wlp1s0 proto dhcp src 192.168.0.20 metric 303
192.168.0.0/24 dev wlp1s0 proto dhcp scope link src 192.168.0.20 metric 303
Details about how I tried to use linux-router.
./lnxrouter -n --ap wlan0_ap TomiMetria --hostname tomimetria -g 192.168.27.10
WARN: brmfmac driver doesn't work properly with virtual interfaces and
it can cause kernel panic. For this reason we disallow virtual
interfaces for your adapter.
For more info: https://github.com/oblique/create_ap/issues/203
WARN: Your adapter does not fully support AP virtual interface, enabling --no-virt
PID: 2858
Target interface is wlan0_ap
WARN: Wifi is not protected by password
haveged_watchdog PID: 2895
Starting hostapd
hostapd PID: 2898
Configuration file: /dev/shm/lnxrouter_tmp/lnxrouter.wlan0_ap.conf.Ecl/hostapd.conf
wlan0_ap: Could not connect to kernel driver
Using interface wlan0_ap with hwaddr b8:27:eb:fb:8e:2c and ssid "TomiMetria"
wlan0_ap: interface state UNINITIALIZED->ENABLED
wlan0_ap: AP-ENABLED
No Internet sharing
iptables: allow DNS port access
ACCEPT tcp opt -- in wlan0_ap out * 192.168.27.0/24 -> 192.168.27.10 tcp dpt:53 /* lnxrouter-2858-wlan0_ap */
ACCEPT udp opt -- in wlan0_ap out * 192.168.27.0/24 -> 192.168.27.10 udp dpt:53 /* lnxrouter-2858-wlan0_ap */
iptables: allow DHCP port access
ACCEPT udp opt -- in wlan0_ap out * 0.0.0.0/0 -> 0.0.0.0/0 udp dpt:67 /* lnxrouter-2858-wlan0_ap */
Starting dnsmasq
Mar 29 16:05:24 dnsmasq[2936]: started, version 2.80 cachesize 150
Mar 29 16:05:24 dnsmasq[2936]: compile time options: IPv6 GNU-getopt DBus i18n IDN2 DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify dumpfile
Mar 29 16:05:24 dnsmasq[2936]: warning: no upstream servers configured
Mar 29 16:05:24 dnsmasq-dhcp[2936]: DHCP, IP range 192.168.27.10 -- 192.168.27.250, lease time 1h
Mar 29 16:05:24 dnsmasq-dhcp[2936]: DHCP, sockets bound exclusively to interface wlan0_ap
Mar 29 16:05:24 dnsmasq[2936]: cleared cache
dnsmasq PID: 2936
== Setting up completed, now linux-router is working ==
wlan0_ap: STA a0:28:ed:85:00:33 IEEE 802.11: associated
wlan0_ap: AP-STA-CONNECTED a0:28:ed:85:00:33
wlan0_ap: STA a0:28:ed:85:00:33 RADIUS: starting accounting session 2FD2F153B87501C5
Mar 29 16:06:14 dnsmasq-dhcp[2936]: DHCPDISCOVER(wlan0_ap) a0:28:ed:85:00:33
Mar 29 16:06:14 dnsmasq-dhcp[2936]: DHCPOFFER(wlan0_ap) 192.168.27.204 a0:28:ed:85:00:33
Mar 29 16:06:14 dnsmasq-dhcp[2936]: DHCPREQUEST(wlan0_ap) 192.168.27.204 a0:28:ed:85:00:33
Mar 29 16:06:14 dnsmasq-dhcp[2936]: DHCPACK(wlan0_ap) 192.168.27.204 a0:28:ed:85:00:33
wlan0_ap: STA 00:28:f8:4b:af:dc IEEE 802.11: associated
wlan0_ap: AP-STA-CONNECTED 00:28:f8:4b:af:dc
wlan0_ap: STA 00:28:f8:4b:af:dc RADIUS: starting accounting session 41CE24EFC36B8576
Mar 29 16:18:37 dnsmasq-dhcp[2936]: DHCPDISCOVER(wlan0_ap) 00:28:f8:4b:af:dc
Mar 29 16:18:37 dnsmasq-dhcp[2936]: DHCPOFFER(wlan0_ap) 192.168.27.181 00:28:f8:4b:af:dc
Mar 29 16:18:37 dnsmasq-dhcp[2936]: DHCPREQUEST(wlan0_ap) 192.168.27.181 00:28:f8:4b:af:dc
Mar 29 16:18:37 dnsmasq-dhcp[2936]: DHCPACK(wlan0_ap) 192.168.27.181 00:28:f8:4b:af:dc tomi-pc
[root@alarmpi linux-router]# ./lnxrouter --list-clients wlan0_ap
MAC IP Hostname
00:28:f8:4b:af:dc 192.168.27.181 tomi-pc
a0:28:ed:85:00:33 192.168.27.204 LICENSE
192.168.27.204 is my phone. 192.168.27.181 is a laptop. The laptop works, I mean from the laptop I can ping 192.168.27.10 the gateway.
[root@alarmpi linux-router]# arp -a
? (192.168.27.204) at a0:28:ed:85:00:33 [ether] on wlan0_ap
_gateway (192.168.1.1) at 48:f8:b3:14:89:e6 [ether] on wlan0
? (192.168.27.181) at 00:28:f8:4b:af:dc [ether] on wlan0_ap
? (192.168.1.102) at 34:f3:9a:a3:ee:36 [ether] on wlan0
I can ping the phone from the pi
[root@alarmpi linux-router]# ping 192.168.27.204
PING 192.168.27.204 (192.168.27.204) 56(84) bytes of data.
64 bytes from 192.168.27.204: icmp_seq=6 ttl=64 time=50.6 ms
I can ping the phone from the connected laptop as well.
But I can't ping the gateway from the phone.
phone details
$ ip route show
192.168.27.0/24 dev wlan0 proto kernel scope link src 192.168.27.204
I can ping the connected laptop from the phone, but I can't ping that damned gateway.
This is how I created the wlan0_ap on the pi.
$ iw dev wlan0 interface add wlan0_ap type __ap
$ macchanger -e wlan0_ap
[root@alarmpi linux-router]# iw wlan0_ap info
Interface wlan0_ap
ifindex 4
wdev 0x2
addr b8:27:eb:fb:8e:2c
ssid TomiMetria
type AP
wiphy 0
channel 1 (2412 MHz), width: 20 MHz, center1: 2412 MHz
txpower 31.00 dBm
[root@alarmpi linux-router]# iw wlan0 info
Interface wlan0
ifindex 3
wdev 0x1
addr b8:27:eb:16:1b:4c
ssid LinkSYS
type managed
wiphy 0
channel 1 (2412 MHz), width: 20 MHz, center1: 2412 MHz
txpower 31.00 dBm
Anyway, since the WiFi_OBDII creates a network where the gateway is accessible from my android phone, there must be a way to achieve this, isn't it?
I use archlinux on the raspberry.
Update: pinging the gateway from the laptop is working sometimes, but sometimes is not. Pinging the phone from the laptop works, but the time varies 20-400 ms.
Idea 2: hotspot on my phone. And connect the pi to two network simultaneously, but can't do that either.
[root@alarmpi alarm]# iw dev wlan0 interface add wlan2 type managed
command failed: Device or resource busy (-16)
Maybe I should get an usb wifi adapter for the pi to have 2 separate interface.