Read Me
Network Manager ControL (nmctl)
This python script facilitate the management of different network interfaces on OpenBSD machines.
Thank to nmctl is becomes easy to switch from one wifi, to an other one, to a cable connection with specific IP configs or to a dhcp.
Moreover, since version 0.6, the config file with all your different rules is stored in your HOMEDIR. Such feature allow you to share your machine with different users. Each user will have his own ~/.nmctl.conf file and no one will see the rules of the others.
Pre-requisites:
--------------
As from version 0.6 you need to configure /etc/doas.conf for each commands.
As from version 0.4, you need python3.6.
Before version 0.4, you need to have python2.7 installed.
You need tp type: pkg_add python and select the appropriate version. In this case, 3.6
Optionaly, if you want to use the small GUI part, you must install python-tkinter (pkg_add python-tkinter). Here too, select version 3.6
In case some nwid have accented names, I recommend to use a utf-8 settings (LC_CTYPE, ...)
Installation
------------
To install the script and the config file, just type: "make install"
You can remove them by doing: "make uninstall"
You have to create a config file in ~/nmctl.conf:
Each block must start from column 0 with interface, a column and the name of the connection.
The conneciton called "open" is mandatory and informed nmctl with interface he can use for the
open wifi connections.
The rest must start with one blank character. This part is composed on 3 componenents:
- if first character is "!", this is a call to an external command
- if the keyword "dhcp" is listed, nmctl with trigger the dhclient command
- all the rest are ifconfig commands. In fact they will be preceeded by ifconfig <interface>
For security reasons, this file must be chmod 600
Comments are permitted
check a sample in the file nmctl.conf
Configuration of /etc/doas.conf
--------------------------------
You must at least have the following entries (or equivalent) in your /etc/doas.conf file:
permit nopass keepenv <userid> as root cmd /bin/cat args /etc/nmctl.conf
permit nopass keepenv <userid> as root cmd /usr/bin/pkill args dhclient
permit nopass keepenv <userid> as root cmd /sbin/ifconfig
permit nopass keepenv <userid> as root cmd /sbin/dhclient
And the following if you use a config like mine here above
permit nopass keepenv <userid> as root cmd /usr/sbin/arp
permit nopass keepenv <userid> as root cmd /sbin/route
Rudimentary documentation
-------------------------
Here after the outcome of "nmctl --help".
PLease note that the options "--list" and "--scan" will generate an XML file
compatible with openbox menus.
usage: nmctl [-h] [--debug DEBUG] [--log LOG] [--interfaces] [--list] [--scan]
[--open OPEN] [--restart] [--retry RETRY] [--wait WAIT] [--ping]
[--gui] [--current] [--disconnect_wifi]
[name]
Simple network manager for OpenBSD
positional arguments:
name Please provide the name you want to connect to or
nothing to list the available networks
optional arguments:
-h, --help show this help message and exit
--debug DEBUG, -D DEBUG
debug messages
--log LOG, -L LOG print debug message into log file instead to std
output
--interfaces, -i display the available interfaces on this machine
--list, -l list available names
--scan, -s scan on the wifi interface the available access points
--open OPEN, -o OPEN connect to an open network
--restart, -r We restart the connection by looping all registered
connections
--retry RETRY, -R RETRY
How much retry should we perform.
--wait WAIT, -w WAIT We wait x seconds before starting the real process
--ping, -p Execute a ping test
--gui, -g launch the gui version of nmctl
--current, -c Get the current connection
--disconnect_wifi, -d
Disconnect your wifi interfaces
By default nmctl is quiet. You have to assign a value to --debug to understand what it
does. Bigger it is, more details you get. UP to now, the max value is 3.
If you put a log file, this info will be redirected so you can consult it
afterwards.
Some extrat info can be found on my website:
http://vincentdelft.be/category/nmctl
The main usages are:
--------------------
To run nmctl and let him check which network interfacce match your context,
let him do the "restart" mode.
Moreover we ask debug mode and logging in a specific file
nmctl -D -L /tmp/nmctl.log -r
To start the GUI par of nmctl, we can do.
This is the ideal command to put in some shortcuts, or window manager
buttons
nmctl -D -L /tmp/nmctl.log -g