Scripting wifi connections
Shane Ambler
FreeBSD at ShaneWare.Biz
Sun Aug 27 03:54:28 UTC 2017
On 26/08/2017 22:54, C. L. Martinez wrote:
> Hi all,
>
> Sometimes I need to use two wifi connections at the same time.
> Actually, my FreeBSD laptop is configured to use source routing (via
> setfib+pf rules) to accomplish this. But I need more flexibility: choose
> how many connections to use, setup a wpa_spplicant.conf's file "on the
> fly", etc.
>
> My current config in rc.conf is:
>
> dhclient_fib="1"
> wlans_ath0="wlan0"
> wlans_urtwn0="wlan1"
> ifconfig_wlan0="country ES WPA SYNCDHCP fib 1 group egress"
>
> As you can see, I can only have one wlan interface properly
> configured. And my idea is to build a script to setup configurations "on
> the fly".
>
> Any tip or idea?
I only have one wlan so haven't tested this -
For two wlans you should be able to add
ifconfig_wlan0="country ES WPA SYNCDHCP fib 1 group egress ssid home"
ifconfig_wlan1="country ES WPA SYNCDHCP fib 1 group egress ssid work"
If needed you can adjust wpa_supplicant flags in rc.conf
wpa_supplicant_flags="-s"
wpa_supplicant_conf_file="/etc/wpa_supplicant.conf"
While wpa_supplicant has the -i ifname and -c config_file options
allowing you to restart it with different configs if you wanted, you
should be able to configure multiple wlans in the one config_file, you
could adjust the one config and SIGHUP wpa_supplicant to re-read it or
have multiple configs setup and tell it to use a different one to suit.
network={
ssid="home"
scan_ssid=1
key_mgmt=WPA-PSK
...
}
network={
ssid="work"
scan_ssid=1
key_mgmt=WPA-EAP
...
}
If using ifconfig wlan1 down to turn off one wlan doesn't work have a
look at wpa_cli to interact with the running wpa_supplicant, it can take
commands so should work from a script. Be sure to set ctrl_interface and
ctrl_interface_group in your wpa_supplicant.conf to use wpa_cli.
--
FreeBSD - the place to B...Software Developing
Shane Ambler
More information about the freebsd-questions
mailing list