D-Link DWA-130 rev E1 Network Connection *ALMOST* Solved

So in this Thread 56861, I said I "solved" my issue. But I was only partially correct. My question is how to get my Wifi adapter to connect upon boot or reboot automatically with working internet.

So the USB Wifi adapter DOES work 100% but only if FreeBSD correctly sets up wlan0 and connects to my router.

So far:
Added to /boot/loader.conf

Added to /etc/rc.conf
ifconfig_wlan0="WPA DHCP"

Added to /etc/wpa_supplicant.conf (with my psk and ssid information of course)

But if I leave my USB Wifi adapter in the USB port, wlan0 does get created but only with as IP address (upon boot or reboot) and status does say associated regardless.

The only known repeatable way to get my Wifi Adapter working is by issuing these commands:

ifconfig wlan0 destroy
ifconfig wlan0 create wlandev rsu0
ifconfig wlan0 up
ifconfig wlan0 up scan
ifconfig wlan0 up scan
ifconfig wlan0 up scan

Sometimes the up scan hangs so I kill it with ctrl-c in the terminal.

On rare occasion if that doesn't work, I have to do those steps with pfctl -d first then after the last command, pfctl -e. Sometimes unplugging the Wifi adapter on reboot then after FreeBSD loads, plugging it back in, and following those steps works too.

It's almost different every time but those commands seems to be what gets it working.

The problem might also be in my router itself. Since I had these problems, I tried forcing my router to assign based on the MAC address of my Wifi adapter. I changed my mind, deleted that entry in the router and applied settings. I also power cycled the router, but apparently, I broke it so my router, when FreeBSD gets it working, still issues and that's how I'm connecting to the internet lol.

All I can think of is that this is an issue with PF, my router, or my Wifi Adapter, or how FreeBSD creates and tries to associate with a network or all of the above. Any experts or network engineers want to shed some insight?

Also my /etc/rc.conf

set skip on lo0
scrub in all
block in all
pass out all keep state

As a side note, I do have a PCI DWA-552 card that BSD Installs works and sets up. Using the same firewall rules, I can reboot no problem with it and it connects automatically.
What about issuing dhclient wlan0 once the system has posted; Is the issue DHCP related or driver related?

Can you perform a packet capture between the wireless client ( tcpdump) and the router to see what data is or is not being sent?

Also are all the kernel modules being loaded in /boot/loader.conf as reported by kldstat when the USb NIC is working, as ifconfig has the ability to dynamically pull in kernel modules as needed after booting? (Some thing I have just encountered myself...)



P.S. Are you using the default MAC address (/ ether address) of the USB Wifi card or trying to change it also?