Hi,
As some of You know there is net-mgmt/networkmgr which allows convenient/graphical Wireless and LAN connections switch.
What I miss in it is the WWAN connection management, DNS management, optional MAC generation and network shares unmount at disconnect. With my solution you still need to edit /etc/wpa_supplicant.conf or /etc/ppp/ppp.conf by hand so it's also not a perfect solution, it's just different.
As I use WWAN, WLAN and LAN connections on my laptop depends on the location I wrote a script to automate this connection management.
It can also set DNS to some safe/nologging providers or even a random safe DNS and generate legitimate MAC address for both LAN and WLAN if needed, even with real OUI first three octets if You provide additional network.sh.oui.txt file with them inside.
It display on the screen what command it would run and it makes use of sudo(8) or doas(1) assuming that You are in the network group.
The command
The script would upon disconnect would also unmount all network shares.
You will have to change the name from network.sh.txt to network.sh as forums engine does not allow me to upload .sh file directly.
If you intend to use network.sh.oui.txt file, to not rename it![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
The settings are on the begin of the file, as follows:
Comments welcome.
Regards,
vermaden
As some of You know there is net-mgmt/networkmgr which allows convenient/graphical Wireless and LAN connections switch.
What I miss in it is the WWAN connection management, DNS management, optional MAC generation and network shares unmount at disconnect. With my solution you still need to edit /etc/wpa_supplicant.conf or /etc/ppp/ppp.conf by hand so it's also not a perfect solution, it's just different.
As I use WWAN, WLAN and LAN connections on my laptop depends on the location I wrote a script to automate this connection management.
It can also set DNS to some safe/nologging providers or even a random safe DNS and generate legitimate MAC address for both LAN and WLAN if needed, even with real OUI first three octets if You provide additional network.sh.oui.txt file with them inside.
Code:
% network.sh help
USAGE:
network.sh TYPE [OPTIONS]
TYPES:
lan
wlan
wwan
dns
OPTIONS:
start
start SSID|PROFILE
stop
example
EXAMPLES:
network.sh lan start
network.sh lan restart
network.sh wlan start
network.sh wlan start HOME-NETWORK-SSID
network.sh wwan example
network.sh dns onic
network.sh dns udns
network.sh dns random
network.sh doas
network.sh sudo
It display on the screen what command it would run and it makes use of sudo(8) or doas(1) assuming that You are in the network group.
The command
network.sh doas
prints what rights it needs to work without root, same for network.sh sudo
command, like that:
Code:
% network.sh doas
# pw groupmod network -m YOURUSERNAME
# cat /usr/local/etc/doas.conf
permit nopass :network as root cmd /bin/cat args /etc/ppp/ppp.conf
permit nopass :network as root cmd /etc/rc.d/netif args onerestart
permit nopass :network as root cmd dhclient
permit nopass :network as root cmd ifconfig
permit nopass :network as root cmd killall args -9 dhclient
permit nopass :network as root cmd killall args -9 ppp
permit nopass :network as root cmd killall args -9 wpa_supplicant
permit nopass :network as root cmd ppp
permit nopass :network as root cmd tee args -a /etc/resolv.conf
permit nopass :network as root cmd tee args /etc/resolv.conf
permit nopass :network as root cmd umount
permit nopass :network as root cmd wpa_supplicant
The script would upon disconnect would also unmount all network shares.
You will have to change the name from network.sh.txt to network.sh as forums engine does not allow me to upload .sh file directly.
If you intend to use network.sh.oui.txt file, to not rename it
The settings are on the begin of the file, as follows:
Code:
# SETTINGS
LAN_IF=em0
LAN_RANDOM_MAC=0
WLAN_IF=wlan0
WLAN_PH=iwn0
WLAN_RANDOM_MAC=1
WWAN_IF=tun0
WWAN_PROFILE=WWAN
NAME=$( basename ${0} )
NETFS="nfs,smbfs,fusefs.sshfs"
TIMEOUT=16
DELAY=0.5
SUDO=0
DOAS=1
Comments welcome.
Regards,
vermaden