Wi-Fi: Difference between revisions

From Leo's Notes
This page was last edited on 30 December 2021, at 02:00.
m Reverted edits by Leo (talk) to last revision by 10.1.1.3
m Added categories and navbox
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Monitoring Access Points ==
== Monitoring Access Points ==
To monitor data on the wifi network, install aircrack-ng, then run:
To monitor data on the wifi network, install aircrack-ng, then run:
airomon-ng start wlan0
{{highlight|lang=terminal|code=
airodump-ng wlan0
# airomon-ng start wlan0
# airodump-ng wlan0
}}


You may get an error like:
You may get an error like:
<syntaxhighlight lang="text">
{{highlight|lang=terminal|code=
[root@alarmpi ~]# airodump-ng wlan0
[root@alarmpi ~]# airodump-ng wlan0
ioctl(SIOCSIWMODE) failed: Device or resource busy
ioctl(SIOCSIWMODE) failed: Device or resource busy
Line 13: Line 16:
sure RFMON is enabled: run 'airmon-ng start wlan0 <#>'
sure RFMON is enabled: run 'airmon-ng start wlan0 <#>'
Sysfs injection support was not found either.
Sysfs injection support was not found either.
</syntaxhighlight>
}}


Make sure that the wireless device is in the monitor mode and then try again.
Make sure that the wireless device is in the monitor mode and then try again.


<syntaxhighlight lang="text">
{{highlight|lang=terminal|code=
[root@alarmpi ~]# iwconfig wlan0
[root@alarmpi ~]# iwconfig wlan0
wlan0    IEEE 802.11bgn  ESSID:off/any
wlan0    IEEE 802.11bgn  ESSID:off/any
Line 32: Line 35:
           Retry short limit:7  RTS thr:off  Fragment thr:off
           Retry short limit:7  RTS thr:off  Fragment thr:off
           Power Management:off
           Power Management:off
</syntaxhighlight>
}}


== Automatically Connecting ==
== Automatically Connecting ==
Install wpa_supplicant since it's required to connect to wpa networks:
Install wpa_supplicant since it's required to connect to wpa networks:
pacman -S wpa_supplicant
{{highlight|lang=terminal|code=
# pacman -S wpa_supplicant
}}


You will need to create a netctl profile in /etc/netctl. This can be done either manually or through the <code>wifi-menu</code> command. Example WPA configuration files can be viewed in <code>/etc/netctl/examples/wireless-wpa</code> and can be copied to <code>/etc/netctl</code> and used as a template configuration file.
You will need to create a netctl profile in /etc/netctl. This can be done either manually or through the {{code|wifi-menu}} command. Example WPA configuration files can be viewed in {{code|/etc/netctl/examples/wireless-wpa}} and can be copied to {{code|/etc/netctl}} and used as a template configuration file.


<syntaxhighlight lang="text">
{{highlight|lang=terminal|code=
# cat /etc/netctl/wlan0-dd-wrt
# cat /etc/netctl/wlan0-dd-wrt
Description='Automatically generated profile by wifi-menu'
Description='Automatically generated profile by wifi-menu'
Line 49: Line 54:
IP=dhcp
IP=dhcp
Key=\"f0c8a9e643*************************************************af10f
Key=\"f0c8a9e643*************************************************af10f
</syntaxhighlight>
}}


Your <code>Key</code> can be your password or the PSK key generated using <code>wpa_passphrase</code>. <code>wifi-menu</code> will automatically generate and use the PSK key instead of storing the plain text copy of the password.
Your {{code|Key}} can be your password or the PSK key generated using {{code|wpa_passphrase}}. {{code|wifi-menu}} will automatically generate and use the PSK key instead of storing the plain text copy of the password.


<syntaxhighlight lang="text">
{{highlight|lang=text|code=
#  wpa_passphrase dd-wrt ap_password
#  wpa_passphrase dd-wrt ap_password
network={
network={
Line 60: Line 65:
         psk=14c5441f17e930da158a71592c3c7914315424f08d03c225d1092076093c32ee
         psk=14c5441f17e930da158a71592c3c7914315424f08d03c225d1092076093c32ee
}
}
</syntaxhighlight>
}}


You can then connect to the access point by running:
You can then connect to the access point by running:
netctl start '''profile-name'''
{{highlight|lang=terminal|code=
# netctl start $profile-name
}}


If it errors out, check the systemd logs using <code>journalctl -xe</code>. If you're still having issues connecting, you may want to try reseating the wireless device or rebooting the machine.
If it errors out, check the systemd logs using {{code|journalctl -xe}}. If you're still having issues connecting, you may want to try reseating the wireless device or rebooting the machine.


To make the machine join a wireless access point automatically, create a startup script (see [[Systemd]] for more information) containing:
To make the machine join a wireless access point automatically, create a startup script (see [[Systemd]] for more information) containing:
<syntaxhighlight lang="bash">#!/bin/sh


{{highlight|lang=bash|code=
#!/bin/sh
sh -c 'while ! netctl start wlan0-dd-wrt ; do echo Wi-Fi failed to come up. Retrying ; sleep 1 ; done'
sh -c 'while ! netctl start wlan0-dd-wrt ; do echo Wi-Fi failed to come up. Retrying ; sleep 1 ; done'
 
}}
</syntaxhighlight>


== See Also ==
== See Also ==
* https://wiki.archlinux.org/index.php/netctl
* https://wiki.archlinux.org/index.php/netctl
{{Navbox Linux}}
[[Category:Linux]]
[[Category:Networking]]

Latest revision as of 02:00, 30 December 2021

Monitoring Access Points

To monitor data on the wifi network, install aircrack-ng, then run:

# airomon-ng start wlan0
# airodump-ng wlan0

You may get an error like:

[root@alarmpi ~]# airodump-ng wlan0
ioctl(SIOCSIWMODE) failed: Device or resource busy

ARP linktype is set to 1 (Ethernet) - expected ARPHRD_IEEE80211,
ARPHRD_IEEE80211_FULL or ARPHRD_IEEE80211_PRISM instead.  Make
sure RFMON is enabled: run 'airmon-ng start wlan0 <#>'
Sysfs injection support was not found either.

Make sure that the wireless device is in the monitor mode and then try again.

[root@alarmpi ~]# iwconfig wlan0
wlan0     IEEE 802.11bgn  ESSID:off/any
          Mode:Managed  Access Point: Not-Associated   Tx-Power=20 dBm
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off

[root@alarmpi ~]# ifconfig wlan0 down
[root@alarmpi ~]# iwconfig wlan0 mode monitor
[root@alarmpi ~]# ifconfig wlan0 up
[root@alarmpi ~]# iwconfig wlan0
wlan0     IEEE 802.11bgn  Mode:Monitor  Frequency:2.422 GHz  Tx-Power=20 dBm
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off

Automatically Connecting

Install wpa_supplicant since it's required to connect to wpa networks:

# pacman -S wpa_supplicant

You will need to create a netctl profile in /etc/netctl. This can be done either manually or through the wifi-menu command. Example WPA configuration files can be viewed in /etc/netctl/examples/wireless-wpa and can be copied to /etc/netctl and used as a template configuration file.

# cat /etc/netctl/wlan0-dd-wrt
Description='Automatically generated profile by wifi-menu'
Interface=wlan0
Connection=wireless
Security=wpa
ESSID=dd-wrt
IP=dhcp
Key=\"f0c8a9e643*************************************************af10f

Your Key can be your password or the PSK key generated using wpa_passphrase. wifi-menu will automatically generate and use the PSK key instead of storing the plain text copy of the password.

#  wpa_passphrase dd-wrt ap_password
network={
        ssid="dd-wrt"
        #psk="ap_password"
        psk=14c5441f17e930da158a71592c3c7914315424f08d03c225d1092076093c32ee
}

You can then connect to the access point by running:

# netctl start $profile-name

If it errors out, check the systemd logs using journalctl -xe. If you're still having issues connecting, you may want to try reseating the wireless device or rebooting the machine.

To make the machine join a wireless access point automatically, create a startup script (see Systemd for more information) containing:

#!/bin/sh
sh -c 'while ! netctl start wlan0-dd-wrt ; do echo Wi-Fi failed to come up. Retrying ; sleep 1 ; done'

See Also