Today I set up my Raspberry Pi with dnsmasq and hostapd so it's built-in wireless interface would always be used as an access point (AP), so I could connect to it with my phone and SSH/VNC into it whenever, without worrying about having WiFi or a mobile hotspot available.
This uses the built-in WiFi interface.
I can connect to the AP with my phone, and SSH/VNC into the Pi just fine, however if I connect a USB WiFi adapter to the Pi, to allow it to connect to an existing WiFi network, I can't SSH/VNC into the Pi using a device on THAT network.
SSH'ing into the Pi via it's own AP still works fine, but I'd like to be able to get both working, so I can use my home WiFi network (with internet access) to connect to the Pi when I'm home, and use it's own hosted Access Point to connect to the Pi when I'm out and about.
I noticed that if I remove the line that I have marked below (in my /etc/dhcpcd.conf
file) and run sudo systemctl restart dnsmasq hostapd dhcpcd
, I can access the Pi as a client on my home network, but this disallows any device to connect to the Pi's AP. (I'm guessing it's because the Pi's AP no longer has a Gateway, since that static IP is what happens to be the Pi AP's Gateway? I'm not too sure).
I've been at this for hours and still can't seem to make any progress.
/etc/dhcpcd.conf:
interface wlan0
static ip_address=192.168.4.1/24 # <========= This is that line
nohook wpa_supplicant
/etc/dnsmasq.conf
interface=wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
server=8.8.8.8
/etc/hostapd/hostapd.conf:
interface=wlan0
ssid=MyAwesomeNetwork
hw_mode=g
channel=7
wpa=2
wpa_passphrase=SecurityIsMyPassion
wpa_key_mgmt=WPA-PSK
country_code=US
Thank you for reading this and I hope I've provided sufficient information, as well as a somewhat-informative explanation on what I'm aiming to accomplish. :)