I am working on an embedded Linux system where there is a WLAN interface can work in both STA and AP mode.
valid interface combinations:
* #{ AP } <= 2, #{ managed } <= 2, #{ P2P-client, P2P-GO } <= 2, #{ P2P-device } <= 1, #{ IBSS } <= 1,
total <= 4, #channels <= 2
Now I have configured the WLAN interface to STA and AP mode (by creating a software AP uap0) as follows,
# ifconfig
uap0 Link encap:Ethernet HWaddr D6:9C:DD:A0:13:78
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4749 errors:0 dropped:333 overruns:0 frame:0
TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:458760 (448.0 KiB) TX bytes:5526 (5.3 KiB)
wlan0 Link encap:Ethernet HWaddr D4:9C:DD:A0:13:78
inet addr:192.168.95.14 Bcast:192.168.95.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:36 errors:0 dropped:0 overruns:0 frame:0
TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5425 (5.2 KiB) TX bytes:1723 (1.6 KiB)
wlan0 is the physical interface, whose IP address is got from external AP.
uap0 is software interface used as an AP, which can be connected by my cell phone.
I enabled the sysctl -w net.ipv4.ip_forward=1, and route -n shows,
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.95.1 0.0.0.0 UG 0 0 0 wlan0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 uap0
192.168.95.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
I can ping external public internet from the target board, and my cell phone's IP (192.168.0.190).
But now my cell phone cannot access internet through the WIFI (uap0).
How to configure the Linux networking in this case to enable my cell phone to access public internet?
uap0, so the phone isn't getting any nameservers, and therefore your phone browser doesn't work. You can do that e.g. by installingdnsmasqand configuring it foruap0.