-- Leo's gemini proxy

-- Connecting to bbs.geminispace.org:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; charset=utf-8

Help: How to switch between wifi and wired networks.


My laptop is currently configured for a wired network (em0) and WIFI(wlan0). Relevant /etc/rc.conf:


ifconfig_em0="DHCP"
wlans_iwm0="wlan0"
ifconfig_wlan0="WPA DHCP"

When the system comes up, networking seems to work. However, bringing wlan0 down makes the system stop working. I just spent a few hours trying to figure out what's going on, and I managed to get it working but it seems too convoluted. What's a good way to do this?


The Problem


When I bring down wlan0, netstat -r still shows (now stale) wlan0's default gateway, and needless to say, routing fails. /etc/resolv.conf likewise shows old name servers. To get the system to work from ethernet, I have to do the following manually:


sudo route delete default
sudo service dhclient restart em0

similarly, when I unplug the ethernet and bring up wlan0, I have to reset the gateway, to match WIFI's expectations.


While this works, it is very cumbersome to say the least.


How do you deal with this?


Posted in: s/FreeBSD

๐Ÿš€ stack

2023-10-13 ยท 7 months ago


4 Comments โ†“


๐Ÿš€ stack [OP] ยท 2023-10-13 at 05:31:

To answer my own question: yet again, vermaden has a solution, a shell script that solves all problems.


โ€” https://forums.freebsd.org/threads/scripted-network-management-with-network-sh.62013/


At least I wasn't crazy, it is an issue.


๐Ÿฆ€ jeang3nie ยท 2023-10-13 at 15:02:

This one is just a bit esoteric, but there is a solution. It's called link aggregation, or a lagg interface. What this means is that you combine two interfaces into one virtual interface, either for load balancing or failover if your primary interface becomes unavailable. You'd want the latter. It's covered in section 34.9 of the FreeBSD handbook under advanced networking. If you scroll down they give an example of setting this up for using a wired connection as your primary and wireless as the failover.


๐Ÿš€ stack [OP] ยท 2023-10-13 at 17:10:

@jeang3nie, I will have a look, although my primary goal is to be able to easily switch between wired, several in-home wifis, and coffeehouse wifis, on my thinkpad.


๐Ÿฆ€ jeang3nie ยท 2023-10-13 at 19:29:

You should be able to move between different wireless networks using wpa_supplicant. Not sure how that would fit into the scheme I mentioned earlier, because the docs don't mention it specifically.

-- Response ended

-- Page fetched on Sun May 19 13:53:28 2024