LinkedIn Sourceforge Twitter

Vincent's Blog

Pleasure in the job puts perfection in the work (Aristote)

Network Manager ControL for OpenBSD

Posted on 2018-04-11 15:11:00 from Vincent in Open Bsd nmctl

In this blog I've shared with you my small script allowing a easier Network management tool for OpenBSD. This blog will present some enhancements on this tool


Generalities

I just remind the scope of this small tool:

  • allow you to pre-define several cable or wifi connections
  • let nmctl to connect automatically to the first available one
  • allow you to easily switch from one network connection to an other one
  • create openbox dynamic menus

Enhancements in this version

This is my second development version: 0.2.

I've added performed several changes int he code:

  • code style cleanup, to better match the python recommendations
  • adapt the tool to allow to connect to an Open-wifi having blancs in the name. This happens in some hotels
  • implement a loop as work-around concerning the arp table issue.

The source code is still on the git of Sourceforge.net.
You can see the files here

And you can download the last version here

Feedbacks after few months

I'm using this script on my OpenBSD laptop since about 5 months. In my case, I'm mainly using the openbox menus and the --restart option.

The Openbox menus

The openbox menus are working fine. As explain in my previous blog, I just have to create 2 entries in my openbox's menu.xml file, and all the rest comes automatically from nmctl itself thanks to the --list and --scan options.

I've not changed this part of nmctl since it works as expected (for me :-) ).

The --restart option

Because I'm very lazy, and because OpenBSD is very simple to use, I've added the command "nmctl --restart" in the /etc/apm/resume script. Thanks to apmd, this script will be used each time I'm opening the lid of my laptop.
In other words, each time I'll opening my laptop, nmctl will search the optimum network connection for me.

#!/bin/sh

date >  /tmp/resume
/usr/local/bin/nmctl -r -w 15 >> /tmp/resume

But I had several issues in this scenario.

Most of the problems were linked to the arp table issues. Indeed, in some circumstances, my proxy IP address was associated to the cable interface instead of the wifi interface or vice-versa. As consequence I'm not able to connect to the proxy, thus not able to connect to internet. So the ping to google (final test nmctl perform) is failing.

Knowing that anyhow, I'm doing a full arp cleanup, it's not clear for me from where this problem come from. To solve this situation I've implemented a "retry" concept. In other words, before testing an another possible network connection (as listed in my /etc/nmctl.conf file), the script try 3x the current connection's parameters.

If you want to reduce or increase this figures, you can do it via the --retry parameter.

Results of my expertise with this small tool

Where ever I'm located, my laptop is now connecting automatically to the wifi / cable connection previously identified for this location.

Currently I have 3 places where I have Wifi credentials and 2 offices places where I just have to plug the network cable.

Since the /etc/apm/resume scripts is triggered when I open the lid of the laptop, I just have to make sure that I plug the RJ45 before opening the laptop. For the rest, I do not have to type any commands, OpenBSD do all what is needed ;-).

I hotels or restaurants, I can just connect to the Open Wifi thanks to the openbox menu created by "nmctl --scan".

Next steps

Documentation

The tool is missing lot of documentation. I appreciate OpenBSD for his great documentation, so I have to do the same.

I plan to write a README and a man page at first instances.

But since my laziness, I will do it as soon as I see some interest for this tool from other persons.

Tests

I now have to travel and see how to see the script react on the different situations.

Interested persons are welcome to share with me the outcome of their tests.

I'm curious how it work.



0, 0
displayed: 1082



What is the first letter of the word Python?