From owner-freebsd-questions@freebsd.org Sun Aug 27 03:54:28 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B8A77DE5C70 for ; Sun, 27 Aug 2017 03:54:28 +0000 (UTC) (envelope-from FreeBSD@shaneware.biz) Received: from ipmail06.adl6.internode.on.net (ipmail06.adl6.internode.on.net [150.101.137.145]) by mx1.freebsd.org (Postfix) with ESMTP id 48F6663513 for ; Sun, 27 Aug 2017 03:54:27 +0000 (UTC) (envelope-from FreeBSD@shaneware.biz) Received: from unknown (HELO leader.local) ([118.211.113.221]) by ipmail06.adl6.internode.on.net with ESMTP; 27 Aug 2017 13:19:18 +0930 Subject: Re: Scripting wifi connections To: "C. L. Martinez" , freebsd-questions@freebsd.org References: <20170826132404.mpvknkgxl26t5c43@tesla.lab.uxdom.org> From: Shane Ambler Message-ID: <44a0b50e-3c4b-86ce-9bda-9e6fc634af35@ShaneWare.Biz> Date: Sun, 27 Aug 2017 13:19:15 +0930 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170826132404.mpvknkgxl26t5c43@tesla.lab.uxdom.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-AU Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Aug 2017 03:54:28 -0000 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