OPNsense Forum

Archive => 21.1 Legacy Series => Topic started by: balders on June 19, 2021, 03:18:29 pm

Title: Wireless NIC as WAN interface - does not dhcp on boot need to run manual cmds
Post by: balders on June 19, 2021, 03:18:29 pm
Hi forum,

I am having trouble with using a wifi adapter with OpnSense. On bootup I have the nic listed fine in ifconfig and it can also scan networks just fine. However it always says "no carrier" and thus cannot initiate dhcp request to get IP's etc.

I manually run this little script and the wifi card fetchs an address and all is good with the world. How can I fix this properly and permanently though...can someone with the know-how please provide some pointers. Any help massively appreciated. For detail sake this is a RALINK adapter but all I can find about it is:
usbconfig ugen0.5 dump_all_desc
ugen0.5: <Ralink 802.11 n WLAN> at usbus0
  idVendor = 0x148f
  idProduct = 0x3572
  bcdDevice = 0x0101
  iManufacturer = 0x0001  <Ralink>

Like I say it works fine if I run the restart and dhclient below after each boot. I know I can stick this in RC or CRON but it isn't a fix. Looking for a fix.

#!/bin/sh
ping -q -c5 8.8.8.8 > /dev/null 2>&1

if [ $? -eq 0 ]
  then
     echo . >> /var/log/wan.log
     echo "========WAN CHECK INITIATED============" >> /var/log/wan.log
     echo . >> /var/log/wan.log
      echo "No restart of WAN interface required."
      echo "$(date '+%Y-%m-%d %H:%M:%S') - WAN interface did not require restarting on" $(hostname -s) >> /var/log/wan.log
  else
      # When we restart the NIC we also need to run a dhclient to get our (fixed) IP address:
     echo . >> /var/log/wan.log
     echo "========WAN CHECK INITIATED============" >> /var/log/wan.log
     echo . >> /var/log/wan.log    
      echo "$(date '+%Y-%m-%d %H:%M:%S') - WAN interface Restarting on" $(hostname -s) >> /var/log/wan.log
      /etc/rc.d/netif restart run0_wlan1 >> /var/log/wan.log
      dhclient run0_wlan1 >> /var/log/wan.log
      echo "$(date '+%Y-%m-%d %H:%M:%S') - WAN interface Restarted on" $(hostname -s) >> /var/log/wan.log
fi