LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking > Linux - Wireless Networking
User Name
Password
Linux - Wireless Networking This forum is for the discussion of wireless networking in Linux.

Notices


Reply
  Search this Thread
Old 01-22-2018, 05:26 PM   #1
hrfister
LQ Newbie
 
Registered: Jan 2008
Posts: 25

Rep: Reputation: 0
Trouble with Wireless USB Adapter working on boot up.


I've gotten better at Linux and it's been a while since I have posted. But I just about gave up trying to get my Wifi USB Adapter (TP-Link Archer T1U) to connect to the WAP in the office on boot up. The online research said to use WPA supplicant and I tried to follow the instructions and modified the variable names to match what I am running. I think my issue is either a problem with it using the wrong driver when I try to start it with WPA supplicant, or a possible authentication failure. The following is the reason I type that.

After I restart the PC, or start /etc/init.d/wpa.sh manually I get the following when I check /var/log/wpa_supplicant.log

Code:
Successfully initialized wpa_supplicant
ra0: Trying to associate with e2:55:6d:5f:90:51 (SSID=<my office ssid> freq=5220 MHz)
ra0: Association request to the driver failed
ra0: Authentication with e2:55:6d:5f:90:51 timed out.
ra0: CTRL-EVENT-DISCONNECTED bssid=e2:55:6d:5f:90:51 reason=3 locally_generate
...and it just repeats itself.

Now, I have a gut feeling that the driver that is being used when I connect manually is not the same as the driver that the srcipt /etc/init.d/wpa.sh wants to use. On /etc/init.d/wpa.sh, I have:

Code:
DRIVER=wext
When I connect manually (and it works), and I use lshaw, it is using this:
Code:
#lshw -C network

  *-network
       description: Wireless interface
       physical id: 1
       logical name: ra0
       serial: d4:6e:0e:50:bd:ea
       capabilities: ethernet physical wireless
       configuration: broadcast=yes driver=RALINK WLAN ip=<my lan ip> multicast=yes wireless=Ralink STA

If I change DRIVER=wext to DRIVER="RALINK WLAN", on /etc/init.d/wpa.sh I get a different message on the log (/var/log/wpa_supplicant.log) when I start /etc/init.d/wpa.sh. Something along the lines that this driver RLINK can't be used.

The following is what I enter manually to make this work but I need it to work automatically when it boots up.

Code:
ifconfig ra0 up
iwpriv ra0 set SiteSurvey=1
iwpriv ra0 set NetworkType=Infra
iwpriv ra0 set AuthMode=WPA2PSK
iwpriv ra0 set EncrypType=AES
iwpriv ra0 set SSID="<my office ssid>"
iwpriv ra0 set WPAPSK=<my preshared key>
iwpriv ra0 set SSID="<my office ssid>"
dhclient ra0
(I got this information from driver manual from the TP-LINK website)
This works great, but again, if done manually!

And yes, I've tried this with a bash script in /etc/init.d/ to see if it connects on bootup, but it doesn't work. Not sure why.


Here is some more information that may help you help me:

The same manual to me to check that the driver was installed by doing this:
Code:
 lsmod | grep mt7650
mt7650u_sta_net        36206  1 
mt7650u_sta           842995  1 mt7650u_sta_net
mt7650u_sta_util       66642  2 mt7650u_sta_net,mt7650u_sta
...and yes, I even tried to set DRIVER=mt7650u and DRIVER=mt7650u_sta_net and DRIVER=mt7650u_sta...etc...on /etc/init.d/wpa.sh and it did not work. Got the same message as with RALINK

This is the Kernel Version and Ubuntu version I am trying to run this on:
Code:
#cat /proc/version
Linux version 3.16.0-77-generic (buildd@lcy01-24) (gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) ) #99~14.04.1-Ubuntu SMP Tue Jun 28 19:18:41 UTC 2016
(Please note that, I had to downgrade to v 14 from v 16 when I couldn't get the driver to install, per the driver specs from the TP-LINK website.)

My network configuration:
Code:
cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto ra0
iface ra0 inet dhcp
pre-up /etc/init.d/wpa.sh start
post-down /etc/init.d/wpa.sh stop
Any help is greatly appreciated!
 
Old 01-22-2018, 06:24 PM   #2
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,819

Rep: Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144
Quote:
If I change DRIVER=wext to DRIVER="RALINK WLAN", on /etc/init.d/wpa.sh I get a different message on the log (/var/log/wpa_supplicant.log) when I start /etc/init.d/wpa.sh. Something along the lines that this driver RLINK can't be used.
Don't get yourself confused here. Your wireless hardware is supported by the mt7650u_sta driver, and wpa_supplicant does not directly communicate with the wireless device driver, but instead relies on a backend to interface to the driver. The wext backend is largely now deprecated, but some older drivers such as yours still depend on it for operation. Newer wifi dirvers/hardware use the nl80211 backend and the cfg80211 kernel module to communicate with the driver.
 
Old 01-22-2018, 06:53 PM   #3
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,819

Rep: Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144
Can you point us at the guide that you've been following?

Otherwise see if this guide helps...
https://maintenancecoder.wordpress.c...ntu-14-04-lts/

It uses /etc/network/interfaces with something like the following (adapted for your ra0 network device node)...
Quote:
auto ath0
iface ra0 inet dhcp
wpa-driver wext
wpa-conf /etc/wpa_supplicant.conf
 
Old 01-23-2018, 12:33 PM   #4
hrfister
LQ Newbie
 
Registered: Jan 2008
Posts: 25

Original Poster
Rep: Reputation: 0
ferrari,

Thank you very much for your response!

The following is the link that I used as a guide:
https://help.ubuntu.com/community/Ne...Line/Automatic

Quote:
Don't get yourself confused here. Your wireless hardware is supported by the mt7650u_sta driver, and wpa_supplicant does not directly communicate with the wireless device driver, but instead relies on a backend to interface to the driver. The wext backend is largely now deprecated, but some older drivers such as yours still depend on it for operation. Newer wifi dirvers/hardware use the nl80211 backend and the cfg80211 kernel module to communicate with the driver.
This helped me read to learn further. The wpa_supplicant script creates an IPC communication process between the kernel and the userspace (backend). I also learned that nl80211 that works with cfg80211 but no longer use ioctl, but instead are used by netlink at the back end. I used to get errors on
Code:
/var/log/wpa_supplicant.log
stating that ioctl doesn't recognize ra0, when I tried to incorrectly set the driver name, instead of the back end APIs. This told me that wpa_supplicant is using ioctl and not netlink that nl80211 and cfg80211 work with. If this is the case, then I may only be able to use wext, for this older driver.

Unless you have another suggestion, I'm going to see if I can use iw or hostapd as alternative backend components that use netlink libraries to see if I get better luck communicating with this driver from the backend. Let me see how I can install one at a time and see if I can make it work.

GREAT LEARNING EXPERIENCE, I'll keep you posted on the results. Thanks again!
 
Old 01-23-2018, 02:35 PM   #5
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,819

Rep: Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144
Glad to have been of help with the learning. I had a quick look at the guide you were working from, but I think the guide I linked to uses a simpler approach for connecting with wpa_supplcant and shows how to implement the wext backend as part of the wireless configuration. It relies only on minimal /etc/wpa_supplicant.conf and /etc/network/interfaces configuration, and easy to follow.
 
Old 01-23-2018, 06:06 PM   #6
hrfister
LQ Newbie
 
Registered: Jan 2008
Posts: 25

Original Poster
Rep: Reputation: 0
ferrari,

Again, thanks for all of your help. I tried that link you sent me and turned off the wpa.sh script on boot up before I tried it.

#wpa_supplicant -h
Code:
drivers:
  nl80211 = Linux nl80211/cfg80211
  wext = Linux wireless extensions (generic)
  wired = Wired Ethernet driver
  none = no driver (RADIUS server/WPS ER)

/etc/wpa_supplicant.conf
Code:
ctrl_interface=/var/run/wpa_supplicant

network={
	ssid="my-office-ssid"
        scan_ssid=0
        proto=WPA RSN
        key_mgmt=WPA-PSK
        pairwise=CCMP TKIP
        group=CCMP TKIP
	#psk="my-preshared-key"
	psk=c78b7eeb5a8cda8ee97bff1fa75314945015132b811be0d8b471da8f5ee37fca
}
/etc/network/interfaces
Code:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto ra0
iface ra0 inet dhcp
wpa-driver wext
wpa-conf /etc/wpa_supplicant.conf
I bounced the ra0 interface:

Code:
#ifdown ra0
#ifup ra0

This is what I got on the log
tail -f /var/log/syslog
Code:
Jan 23 17:38:14 clockinout2-OptiPlex-3020 wpa_supplicant[2947]: Successfully initialized wpa_supplicant
Jan 23 17:38:14 clockinout2-OptiPlex-3020 kernel: [ 3223.657077] /home/clockinout2/Archer_T1U_V1_150909/Archer_T1U_V1_150909/MODULE/os/linux/../../common/cmm_asic.c:2225 assert KeyIdx < 4failed
Jan 23 17:38:14 clockinout2-OptiPlex-3020 kernel: [ 3223.658223] /home/clockinout2/Archer_T1U_V1_150909/Archer_T1U_V1_150909/MODULE/os/linux/../../common/cmm_asic.c:2225 assert KeyIdx < 4failed
Jan 23 17:38:14 clockinout2-OptiPlex-3020 dhclient: Internet Systems Consortium DHCP Client 4.2.4
Jan 23 17:38:14 clockinout2-OptiPlex-3020 dhclient: Copyright 2004-2012 Internet Systems Consortium.
Jan 23 17:38:14 clockinout2-OptiPlex-3020 dhclient: All rights reserved.
Jan 23 17:38:14 clockinout2-OptiPlex-3020 dhclient: For info, please visit https://www.isc.org/software/dhcp/
Jan 23 17:38:14 clockinout2-OptiPlex-3020 dhclient: 
Jan 23 17:38:14 clockinout2-OptiPlex-3020 dhclient: Listening on LPF/ra0/d4:6e:0e:05:db:ae
Jan 23 17:38:14 clockinout2-OptiPlex-3020 dhclient: Sending on   LPF/ra0/d4:6e:0e:05:db:ae
Jan 23 17:38:14 clockinout2-OptiPlex-3020 dhclient: Sending on   Socket/fallback
Jan 23 17:38:14 clockinout2-OptiPlex-3020 dhclient: DHCPDISCOVER on ra0 to 255.255.255.255 port 67 interval 3 (xid=0x7edcee74)
Jan 23 17:38:16 clockinout2-OptiPlex-3020 avahi-daemon[684]: Joining mDNS multicast group on interface ra0.IPv6 with address fe80::d66e:eff:fe05:dbae.
Jan 23 17:38:16 clockinout2-OptiPlex-3020 avahi-daemon[684]: New relevant interface ra0.IPv6 for mDNS.
Jan 23 17:38:16 clockinout2-OptiPlex-3020 avahi-daemon[684]: Registering new address record for fe80::d66e:eff:fe05:dbae on ra0.*.
Jan 23 17:38:17 clockinout2-OptiPlex-3020 dhclient: DHCPDISCOVER on ra0 to 255.255.255.255 port 67 interval 3 (xid=0x7edcee74)
Jan 23 17:38:20 clockinout2-OptiPlex-3020 dhclient: DHCPDISCOVER on ra0 to 255.255.255.255 port 67 interval 4 (xid=0x7edcee74)
Jan 23 17:38:24 clockinout2-OptiPlex-3020 dhclient: DHCPDISCOVER on ra0 to 255.255.255.255 port 67 interval 11 (xid=0x7edcee74)
Jan 23 17:38:24 clockinout2-OptiPlex-3020 kernel: [ 3233.766750] ===>rt_ioctl_giwscan. 10(10) BSS returned, data->length = 1494
Jan 23 17:38:35 clockinout2-OptiPlex-3020 dhclient: DHCPDISCOVER on ra0 to 255.255.255.255 port 67 interval 8 (xid=0x7edcee74)
Jan 23 17:38:39 clockinout2-OptiPlex-3020 wpa_supplicant[2948]: ra0: Trying to associate with e2:55:6d:5f:90:51 (SSID='<my-office-ssid>' freq=5220 MHz)
Jan 23 17:38:39 clockinout2-OptiPlex-3020 wpa_supplicant[2948]: ra0: Association request to the driver failed
Jan 23 17:38:39 clockinout2-OptiPlex-3020 kernel: [ 3248.789258] ===>rt_ioctl_giwscan. 6(6) BSS returned, data->length = 892
Jan 23 17:38:39 clockinout2-OptiPlex-3020 kernel: [ 3248.789397] ==>rt_ioctl_siwfreq::SIOCSIWFREQ(Channel=44)
Jan 23 17:38:40 clockinout2-OptiPlex-3020 kernel: [ 3249.463090] PeerBeaconAtJoinAction(): HT-CtrlChannel=44, CentralChannel=>46
Jan 23 17:38:40 clockinout2-OptiPlex-3020 kernel: [ 3249.463092] PeerBeaconAtJoinAction(): Set CentralChannel=46
Jan 23 17:38:40 clockinout2-OptiPlex-3020 kernel: [ 3249.463094] AdjustChannelRelatedValue(): Input BW=1, rf_channel=46, vht_bw=1, Channel=44, vht_cent_ch=42!
Jan 23 17:38:41 clockinout2-OptiPlex-3020 kernel: [ 3250.766178] @@@ BEFORE MT76x0_dynamic_vga_tuning(): rssi=-60, Rssi_DVGA=-59
Jan 23 17:38:41 clockinout2-OptiPlex-3020 kernel: [ 3250.766245] MT76x0_dynamic_vga_tuning(): RSSI=-60, BBP 2320=0x101014f2
Jan 23 17:38:43 clockinout2-OptiPlex-3020 kernel: [ 3251.835162] @@@ BEFORE MT76x0_dynamic_vga_tuning(): rssi=-57, Rssi_DVGA=-58
Jan 23 17:38:43 clockinout2-OptiPlex-3020 kernel: [ 3251.835228] MT76x0_dynamic_vga_tuning(): RSSI=-57, BBP 2320=0x10101eb2
Jan 23 17:38:43 clockinout2-OptiPlex-3020 dhclient: DHCPDISCOVER on ra0 to 255.255.255.255 port 67 interval 14 (xid=0x7edcee74)
Jan 23 17:38:44 clockinout2-OptiPlex-3020 kernel: [ 3252.864031] @@@ BEFORE MT76x0_dynamic_vga_tuning(): rssi=-56, Rssi_DVGA=-57
Jan 23 17:38:44 clockinout2-OptiPlex-3020 kernel: [ 3252.864099] MT76x0_dynamic_vga_tuning(): RSSI=-56, BBP 2320=0x10101eb2
Jan 23 17:38:44 clockinout2-OptiPlex-3020 wpa_supplicant[2948]: ra0: Authentication with e2:55:6d:5f:90:51 timed out.
Jan 23 17:38:44 clockinout2-OptiPlex-3020 wpa_supplicant[2948]: ra0: CTRL-EVENT-DISCONNECTED bssid=e2:55:6d:5f:90:51 reason=3 locally_generated=1
Jan 23 17:38:55 clockinout2-OptiPlex-3020 wpa_supplicant[2948]: ra0: Trying to associate with e2:55:6d:5f:90:51 (SSID='<my-office-ssid>' freq=5220 MHz)
Jan 23 17:38:55 clockinout2-OptiPlex-3020 wpa_supplicant[2948]: ra0: Association request to the driver failed
Jan 23 17:38:55 clockinout2-OptiPlex-3020 kernel: [ 3263.906263] ===>rt_ioctl_giwscan. 8(8) BSS returned, data->length = 1136
Jan 23 17:38:55 clockinout2-OptiPlex-3020 kernel: [ 3263.906409] ==>rt_ioctl_siwfreq::SIOCSIWFREQ(Channel=44)
Jan 23 17:38:55 clockinout2-OptiPlex-3020 kernel: [ 3263.920075] PeerBeaconAtJoinAction(): HT-CtrlChannel=44, CentralChannel=>46
Jan 23 17:38:55 clockinout2-OptiPlex-3020 kernel: [ 3263.920077] PeerBeaconAtJoinAction(): Set CentralChannel=46
Jan 23 17:38:55 clockinout2-OptiPlex-3020 kernel: [ 3263.920079] AdjustChannelRelatedValue(): Input BW=1, rf_channel=46, vht_bw=1, Channel=44, vht_cent_ch=42!
Jan 23 17:38:56 clockinout2-OptiPlex-3020 kernel: [ 3265.089823] @@@ BEFORE MT76x0_dynamic_vga_tuning(): rssi=-56, Rssi_DVGA=-57
Jan 23 17:38:56 clockinout2-OptiPlex-3020 kernel: [ 3265.089892] MT76x0_dynamic_vga_tuning(): RSSI=-56, BBP 2320=0x10101eb2
Jan 23 17:38:57 clockinout2-OptiPlex-3020 kernel: [ 3266.166571] @@@ BEFORE MT76x0_dynamic_vga_tuning(): rssi=-56, Rssi_DVGA=-57
Jan 23 17:38:57 clockinout2-OptiPlex-3020 kernel: [ 3266.166637] MT76x0_dynamic_vga_tuning(): RSSI=-56, BBP 2320=0x10101eb2
Jan 23 17:38:57 clockinout2-OptiPlex-3020 dhclient: DHCPDISCOVER on ra0 to 255.255.255.255 port 67 interval 20 (xid=0x7edcee74)
Jan 23 17:38:58 clockinout2-OptiPlex-3020 kernel: [ 3267.187562] @@@ BEFORE MT76x0_dynamic_vga_tuning(): rssi=-56, Rssi_DVGA=-57
Jan 23 17:38:58 clockinout2-OptiPlex-3020 kernel: [ 3267.187628] MT76x0_dynamic_vga_tuning(): RSSI=-56, BBP 2320=0x10101eb2
Jan 23 17:38:59 clockinout2-OptiPlex-3020 kernel: [ 3268.208137] @@@ BEFORE MT76x0_dynamic_vga_tuning(): rssi=-57, Rssi_DVGA=-57
Jan 23 17:38:59 clockinout2-OptiPlex-3020 kernel: [ 3268.208203] MT76x0_dynamic_vga_tuning(): RSSI=-57, BBP 2320=0x10101eb2
Jan 23 17:39:00 clockinout2-OptiPlex-3020 wpa_supplicant[2948]: ra0: Authentication with e2:55:6d:5f:90:51 timed out.
Jan 23 17:39:00 clockinout2-OptiPlex-3020 wpa_supplicant[2948]: ra0: CTRL-EVENT-DISCONNECTED bssid=e2:55:6d:5f:90:51 reason=3 locally_generated=1
Jan 23 17:39:00 clockinout2-OptiPlex-3020 wpa_supplicant[2948]: ra0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="<my-office-ssid>" auth_failures=1 duration=10
Jan 23 17:39:10 clockinout2-OptiPlex-3020 wpa_supplicant[2948]: ra0: CTRL-EVENT-SSID-REENABLED id=0 ssid="<my-office-ssid>"
Jan 23 17:39:10 clockinout2-OptiPlex-3020 kernel: [ 3279.025692] ===>rt_ioctl_giwscan. 7(7) BSS returned, data->length = 958
Next thing that I am thinking of doing is blacklisting drivers, but having trouble identifying them.
 
Old 01-24-2018, 04:00 AM   #7
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,819

Rep: Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144
No, there's no need to blacklist anything- its not the issue here.

You mentioned in your opening post that you can connect manually? Can you clarify further and explain what steps or command you do here?

I also note from googling "TP-Link Archer T1U wpa_supplicant" and similar there are a lot of people experiencing connectivity issues with this device. It doesn't help that it's not supported by a mainline kernel driver. What I read is accounts of users having better success connecting to 2.4GHz wifi frequencies rather than 5GHz, but not everyone has a choice in the matter if the AP is managed by someone else for example.
 
Old 01-24-2018, 10:07 AM   #8
hrfister
LQ Newbie
 
Registered: Jan 2008
Posts: 25

Original Poster
Rep: Reputation: 0
ferrari,

Hello again.

The the wireless USB adapter works great if I execute the following after I turn on the machine.

ifconfig ra0 up
iwpriv ra0 set SiteSurvey=1
iwpriv ra0 set NetworkType=Infra
iwpriv ra0 set AuthMode=WPA2PSK
iwpriv ra0 set EncrypType=AES
iwpriv ra0 set SSID="<my office ssid>"
iwpriv ra0 set WPAPSK=<my preshared key>
iwpriv ra0 set SSID="<my office ssid>"
dhclient ra0

I got these steps straight from the driver manual that I downloaded from the TP-Link website that came with the driver itself. The only reason I wanted to blacklist drivers was to blacklist a driver for another usb wireless of another brand I wanted to try out, but it didn't work. I was a concerned that maybe this other driver would cause some type of conflict. I would not be going through all this trouble if we had extra network ports in the office to connect a cable to the PC. We ran out and they need another station for people to clock in and clock out, and to transfer data from hand held devices on Windows Mobile 5 or 6 to a mapped shared file sever in the LAN that the office uses. (Another task after I can get this resolved.) I already mapped the shared drive with CIFS and it connects on boot up just fine only if I have a network cable connected to the PC but again but we need for the wireless solution to work too. Again, since we are out of network ports and my boss doesn't want to use cheap switches to extend ports on the wall, I need to come up with a solution.

I have these commands on an bash script that I run and have thought about putting them in /init/rc.d but, I believe in not being sloppy. I would like a clean disconnect right before shutdown. The following is something I though I could make run and hold the shutdown process until it finishes:

https://stackoverflow.com/questions/...n-access-point
I'm thinking the MAC is the MAC of the WAP. I'll play with it.

Unless you think it isn't necessary, and I should tackle this from another angle, this may be an opportunity for me to learn how to set up the system to run the bash script with the commands at boot up BEFORE the the scripts that mounts the network drive. On shutdown, make sure I disassociate or disconnect from the WAP before it shuts down.
 
Old 01-24-2018, 10:14 AM   #9
hrfister
LQ Newbie
 
Registered: Jan 2008
Posts: 25

Original Poster
Rep: Reputation: 0
I forgot to mention that we do manage the WAPs from a dashboard. Here are the relevant settings:

Network access association requirement: Pre-shared key with the key.
Encryption Mode: WPA1 & WPA2
Wireless band selection 2.4GHz and 5GHz
 
Old 01-24-2018, 07:05 PM   #10
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,819

Rep: Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144
Ok, I think I know what is needed. It's clear that 'wpa-conf' isn't working for you here. You need to have your working commands in a script that gets called once the wireless device interface (ra0) is up. This can be done in /etc/network/interfaces using the 'post-up' directive. So something like this might be sufficient perhaps...

Code:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto ra0
iface ra0 inet manual
post-up <your script>.sh
and your_scipt.sh is
Code:
#!/bin/bash

iwpriv ra0 set SiteSurvey=1
iwpriv ra0 set NetworkType=Infra
iwpriv ra0 set AuthMode=WPA2PSK
iwpriv ra0 set EncrypType=AES
iwpriv ra0 set SSID="<my office ssid>"
iwpriv ra0 set WPAPSK=<my preshared key>
iwpriv ra0 set SSID="<my office ssid>"
dhclient ra0
Reference:
https://wiki.debian.org/NetworkConfiguration
 
Old 01-25-2018, 10:17 AM   #11
hrfister
LQ Newbie
 
Registered: Jan 2008
Posts: 25

Original Poster
Rep: Reputation: 0
ferrari,

This works on restart great! Thanks! The only problem I'm having now is if I shutdown, wait a few minutes, and then start the PC again. I decided to also do a pre-down as follows:

Code:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto ra0
iface ra0 inet manual
post-up <my wifi connect script>.sh
pre-down <my wifi disassociate script>.sh
According to the documentation here:
https://wiki.debian.org/NetworkConfiguration
pre-down is used with VLAN interfaces and my office is part of a VLAN

My wifi dissassociate script is the following:
Code:
iwconfig ra0 ap 00:00:00:00:00:00
sleep 1
iwpriv ra0 deepsleep 1
I got this from here:
https://stackoverflow.com/questions/...n-access-point
...where it says that when you associate to the NULL AP, it disconnects the adapter. I'm just trying to be as clean as possible.

Thank you for the post-up tip, looks like I'm almost there. Restart is working fine, now I need to make sure this works on start up after a power failure for example.
 
Old 01-25-2018, 01:35 PM   #12
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,819

Rep: Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144
Quote:
ferrari,

This works on restart great! Thanks! The only problem I'm having now is if I shutdown, wait a few minutes, and then start the PC again. I decided to also do a pre-down as follows:
Yes, it was just a minimal config to help with progressing this. Further tweaking is always possible.

Quote:
According to the documentation here:
https://wiki.debian.org/NetworkConfiguration
pre-down is used with VLAN interfaces and my office is part of a VLAN
Actually, 'pre-down' is just run before a given network interface goes down. The Debian guide just used that as an example of its use.

More info from the man page...
Code:
man /etc/network.interfaces
Quote:
IFACE OPTIONS
The following "command" options are available for every family and method. Each of these options can be given multiple times in a single stanza, in which case the commands are executed in the order in which they appear in the stanza. (You can ensure a command never fails by suffixing them with "|| true".)

pre-up command
Run command before bringing the interface up. If this command fails then ifup aborts, refraining from marking the interface as configured, prints an error message, and exits with status 0. This behavior may change in the future.

up command

post-up command
Run command after bringing the interface up. If this command fails then ifup aborts, refraining from marking the interface as configured (even though it has really been configured), prints an error message, and exits with status 0. This behavior may change in the future.

down command

pre-down command
Run command before taking the interface down. If this command fails then ifdown aborts, marks the interface as deconfigured (even though it has not really been deconfigured), and exits with status 0. This behavior may change in the future.

post-down command
Run command after taking the interface down. If this command fails then ifdown aborts, marks the interface as deconfigured, and exits with status 0. This behavior may change in the future.

There exists for each of the above mentioned options a directory /etc/network/if- <option>.d/ the scripts in which are run (with no arguments) using run-parts(8) after the option itself has been processed. Please note that as post-up and pre-down are aliases, no files in the corresponding directories are processed. Please use if-up.d and if-down.d directories instead.
All of these commands have access to the following environment variables.

IFACE
physical name of the interface being processed

LOGICAL
logical name of the interface being processed

ADDRFAM
address family of the interface

METHOD
method of the interface (e.g., static)

MODE
start if run from ifup, stop if run from ifdown

PHASE
as per MODE, but with finer granularity, distinguishing the pre-up, post-up, pre-down and post-down phases.

VERBOSITY
indicates whether --verbose was used; set to 1 if so, 0 if not.

PATH
the command search path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Additionally, all options given in an interface definition stanza are exported to the environment in upper case with "IF_" prepended and with hyphens converted to underscores and non-alphanumeric characters discarded.
When ifupdown is being called with the --all option, before doing anything to interfaces, if calls all the hook scripts ( pre-up or down) with IFACE set to "--all", LOGICAL set to the current value of --allow parameter (or "auto" if it's not set), ADDRFAM="meta" and METHOD="none". After all the interfaces have been brought up or taken down, the appropriate scripts ( up or post-down) are executed.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Having trouble setting up Wireless USB Adapter on Xubuntu 14.0.4 ram0408 Linux - Networking 16 12-25-2015 05:31 PM
Having Trouble Connecting Wireless USB Network Adapter. merknaan SUSE / openSUSE 5 01-26-2008 12:32 PM
having trouble installing Zonet ZEW2500P wireless usb adapter with ubuntu 6.10 thetenspeed Linux - Newbie 2 06-24-2007 04:11 PM
Trouble with Linksys wireless usb adapter phirefenix Linux - Wireless Networking 4 02-17-2005 11:57 PM
having trouble with wireless USB adapter with Slackware 9.1 millerlite546 Linux - Wireless Networking 0 06-03-2004 10:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking > Linux - Wireless Networking

All times are GMT -5. The time now is 05:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration