I have a Beaglebone Black device that uses Debian 9.9 Linux (without UI, I am using terminal for this). (latest image for Beaglebone Black https://beagleboard.org/latest-images)
I enabled and successfully connected to the wifi using conmannctl. (https://fis.gatech.edu/how-to-configure-bbw-wifi/)
When I got connected to the wifi, I am unable to ping externally (8.8.8.8 or www.google.com).
I need to manually add the route via: ip route add default via 192.168.1.1 dev wlan0 and it will be able to connect externally. My IP range at home is 192.168.1.x
I would like to experiment and use this on a place with different WLAN IP range for example 192.168.10.x, with that, I need to run ip route add default via 192.168.10.1 dev wlan0
I am looking for a way to be able to connect to another place with different WLAN IP range without the need of typing and adding the ip route.
I had been researching this since yesterday but it seems I cannot provide the interface only to ip route add command, and the IP always needs to be provided. (or maybe I am not hitting the right google keywords.)
Is there a way to have the route automatically configured whenever I connect to the the interface (wireless lan)? I also tried, connecting a USB to LAN, and I also need to manually issue an ip route command to be able to connect externally.
Currently, I am thinking of creating a python script to do regex parsing on the ifconfig output, and get the first three numbers of the IP on wlan0 (e.g. 192.168.10), and then add .1, then I will use this to execute an ip route add command inside python.
Although, I am thinking if there is a built-in Linux process for this, since when I connect to Wifi on my Ubuntu machine (using the UI), I can immediately browse the internet once the wifi is connected.