Solved Wifi mess

Thank you but I will not remove that line as I want wifi network at system boot and not by manual selection at every session.
Then you will have to find a way for your 3rd party networkmgr tool to do it at startup and not rely on the FreeBSD network wifi startup script.

Otherwise you can clearly see that the two different approaches are conflicting with each other. Its like trying to run systemd-networkd *and* NetworkManager on Linux at the same time. It won't work. So much so that Red Hat stripped out systemd-networkd.

I would have thought the tool you are using has an ability to automatically connect at launch. Perhaps a tick box?
 
Then you will have to find a way for your 3rd party networkmgr tool to do it at startup and not rely on the FreeBSD network wifi startup script.

Otherwise you can clearly see that the two different approaches are conflicting with each other. Its like trying to run systemd-networkd *and* NetworkManager on Linux at the same time. It won't work. So much so that Red Hat stripped out systemd-networkd.

I would have thought the tool you are using has an ability to automatically connect at launch. Perhaps a tick box?
I need the ability to have network at boot with no need to login so I can just turn on the system and remotely access it by SSH.
I also have the ntp sync at boot so it needs network.
 
I'm using networkmgr integrated with a very handsome xfce desktop to manage wireless networks and
It sounds like networkmgr may be set up as an autostart for xfce. One should be able disable that.
I would also check if there is a service calling it, maybe from a login session manager.
 
It's pending to check that the two IPs is a networkmgr issue. Try working with the base FreeBSD config (wpa_supplicant) and switch networks with wifimgr.
If you want to use networkmgr exclusively, review how you can connect to a network at system boot. You must first configure it correctly. pkg-info -Dd networkmgr

Based on the above, should it work with wpa_supplicant?

 
It's pending to check that the two IPs is a networkmgr issue. Try working with the base FreeBSD config (wpa_supplicant) and switch networks with wifimgr.
If you want to use networkmgr exclusively, review how you can connect to a network at system boot. You must first configure it correctly. pkg-info -Dd networkmgr

Based on the above, should it work with wpa_supplicant?


I would say yes. Here is a code snippet of net-mgmt/networkmgr:

Python:
def connectToSsid(name, wificard):
    os.system('killall wpa_supplicant')
    # service
    sleep(0.5)
    os.system(f"ifconfig {wificard} ssid '{name}'")
    sleep(0.5)
    wpa_supplicant = run(
        f'wpa_supplicant -B -i {wificard} -c /etc/wpa_supplicant.conf',
        shell=True
    )
    if wpa_supplicant.returncode != 0:
        return False
    return True

So wpa_supplicant is killed an restarted by networkmgr when a connection to a new ssid/wlan is chosen.
 
So wpa_supplicant is killed an restarted by networkmgr when a connection to a new ssid/wlan is chosen.

That code seems fairly naive. What if the init script has a watcher on wpa_supplicant and will restart it if uncleanly terminated like that?

That random sleep of 0.5 too. Could they not at least keep spinning on ps -aux until the daemon has vanished?

Oh well. If it works...
 
I actually have the same issue... so I'm glad to see it being pursued by someone like OP.

One workaround that I have is to use this: (yes, you have to be root, and yes, this is command-line)
# bsdconfig wireless

The networks that I have successfully connected to ( the 'guest' hotspot at work and my own 192.168.1.1 wifi router at home) got remembered after some messing in the config files. I suspect that this will work if I take my laptop to other places.

Unfortunately, I haven't been able to figure out how to make my laptop automatically connect to the known network if it's in range. I can set it up to connect to ONE specific network by entering the details in rc.conf or wpa_supplicant.conf or whatever, but I haven't been able to line up the details for reliable automatic connection.

At this point, I have to remember to su root and run bsdconfig wireless every time I turn my laptop on or reboot it. Kinda frustrating, but yeah, wifi is a mess, and it does take an engineering degree plus some tolerance for lengthy troubleshooting, digging around, and trial/error if I am to have an actual connection via wifi. And I do have an engineering degree, and way more tolerance for troubleshooting and problem solving than most ppl irl around me.
 
I would say wpa gets killed when connectToSsid is called.
So when is connectToSsid called? Maybe when the lost signal or when I select another ssid, right?
None of those seems to happen.
 
That code seems fairly naive. What if the init script has a watcher on wpa_supplicant and will restart it if uncleanly terminated like that?

That random sleep of 0.5 too. Could they not at least keep spinning on ps -aux until the daemon has vanished?

Oh well. If it works...
yeah right, totally agree.
I would never use sleep just like that. Maybe in a loop that itself will not wait forever with an additional check if the process got killed.
It's hard coding there.
 
I actually have the same issue... so I'm glad to see it being pursued by someone like OP.

One workaround that I have is to use this: (yes, you have to be root, and yes, this is command-line)
# bsdconfig wireless

The networks that I have successfully connected to ( the 'guest' hotspot at work and my own 192.168.1.1 wifi router at home) got remembered after some messing in the config files. I suspect that this will work if I take my laptop to other places.

Unfortunately, I haven't been able to figure out how to make my laptop automatically connect to the known network if it's in range. I can set it up to connect to ONE specific network by entering the details in rc.conf or wpa_supplicant.conf or whatever, but I haven't been able to line up the details for reliable automatic connection.

At this point, I have to remember to su root and run bsdconfig wireless every time I turn my laptop on or reboot it. Kinda frustrating, but yeah, wifi is a mess, and it does take an engineering degree plus some tolerance for lengthy troubleshooting, digging around, and trial/error if I am to have an actual connection via wifi. And I do have an engineering degree, and way more tolerance for troubleshooting and problem solving than most ppl irl around me.
That tool just doesn't work.
It lists all SSID but it's impossible to select one.
 
That tool just doesn't work.
It lists all SSID but it's impossible to select one.
Ah, in my case, I have to first 'select' the SSID, but afterwards, select the 'Cancel' option. Then I run # ifconfig wlan0, and sure enough, I get the association, and can ping google, espn, you name it.

Yeah, the tool's visual feedback is not what I expect, and it did leave me confused. I think it would be nice if that were cleaned up.
 
The wifimgr looks at the lines in the /etc/wpa_supplicant.conf file specifically for text string "WPA" to differentiate between "wired" and "wireless" network connections. So on a non-encrypted open network, The "WPA" option keyword has to be deleted and you are left with ifconfig_wlan0="DHCP" or "SYNCDHCP". In this open network case, Wifimgr gui app does not work, because it is looking for "WPA" option keyword to be present on that line.
I did not know what lines need to be in the /etc/sysctl.conf file, yet I suggest manually editing 3 files /boot/loader.conf /etc/rc.conf and /etc/wpa_supplicant.conf. FreeBSD or GhostBSD app Networkmgr edits these 3 files automatically. For FreeBSD or GhostBSD, You can install Networkmgr package using command, pkg install networkmgr .

Here is my write up of setting up a wifi connection manually, by editing 3 files and using 3 commands ifconfig wlan0, wpa_supplicant and dhclient (or dhcpd) to make the network connection. Use commands netstat -rn and sockstat -4 to test the configuration
https://forums.ghostbsd.org/viewtopic.php?f=64&t=526 RTWN USB Dongle Edimax EW-7811un version 1 and maybe version 2
https://forums.ghostbsd.org/viewtopic.php?f=64&t=570 RTL8188CE PCI Realtek device slightly different manual network command examples
I welcome comments and corrections to these 2 forum posts. I put these together for a person to start from no knowledge to then be able to edit 3 files and issue a set of commands to enable the wifi connection. Use these and prove that they work in your situation case. The debug option of WPA_SUPPLICANT is quite helpful and diagnosing why a wifi connection is not made. After proving the manual wifi connection, then move on to NetworkMgr.

I , too, have been BIT by the manual edit to change file /etc/rc.conf from "WPA DHCP" to just "DHCP" for an OPEN non-encrypted wifi connection. Your eye and mind just don't see the difference ifconfig_wlan0="WPA DHCP" versus "DHCP". I just wish the WPA_SUPPLICANT could see that you are connecting to an "OPEN" network and silently remove the "WPA" and make the connection work. This is a BIG PAIN in the AXX when moving your laptop from one network to another network. Now that most routers use encrypted WPA-PSK, Open Network connection is used less frequently, so makes this condition harder to diagnose when a wifi connection does not work for you on occasions.

My favorite ping command is ping -c 3 he.net Hurricane Electric ISP that is connected directly to a internet backbone and supports IPv6 tunneling.
or ping your local router ping -c 3 192.168.1.1
or ping the internet google DNS ip number with ping -c 3 8.8.4.4
or ping using a DNS name like FreeBSD.org ping -c 3 freebsd.org

https://github.com/ghostbsd/networkmgr Github source code for NetworkMgr, includes reference to FreeBSD ports.
https://forums.freebsd.org/tags/networkmgr/ forum posts related to NetworkMgr
https://forums.freebsd.org/threads/finally-a-network-manager-for-freebsd.50638/ Explaining use of NetworkMgr with some pictures
https://www.serverlab.ca/tutorials/unix/how-to-set-static-ip-and-dhcp-in-freebsd/ A short tutorial of setting a Static IP and DHCP in FreeBSD for wired network connection

I welcome changes, modifications, suggestions and critique to the above statements. Please do read through the comprehensive 2 forum posts referenced above on forums.ghostbsd.org subforum Networking in the 2nd page. Thank you. I hope this helps you get wifi networking connections ,working better on your PC hardware' Also thanks to ericbsd at t.me/ghostbsd Telegram Group for creating and maintaining NetworkMgr python application for automatic connection to wifi networks.
 
Last edited:
I don't really know what really fix it but since I never used the xfce plugin to select the wireless but still use it to show the network icon, moved some settings to wlan args in rc.conf, installed wifimgr tool and setup the connection from there the double IP address issue never happened again.
Thank you!
 
By the way, just to inform that this problem happens only when using WiFi Extender with same SSID.
I've purchased a WiFi Mesh to replace the Extender and I got better speed and stability.
Disabled the main router WiFi and let the Mesh do the home network.
This double IP address issue never happened with this setup.
 
Back
Top