How To Connect To A Wpa/Wpa2 Wifi Network Using Linux Dominance Line

This is a step-to-step guide for connecting to a WPA/WPA2 WiFi network via the Linux ascendance describe of piece of occupation interface. The tools are:

  • wpa_supplicant
  • iw
  • ip
  • ping

iw is the basic tool for WiFi network-related tasks, such every bit finding the WiFi device name, as well as scanning access points. wpa_supplicant is the wireless tool for connecting to a WPA/WPA2 network. ip is used for enabling/disabling devices, as well as finding out full general network interface information.

The steps for connecting to a WPA/WPA2 network are:

  1. Find out the wireless device name.
     $ /sbin/iw dev phy#0 Interface wlan0 ifindex three type managed 

    The inwards a higher house output showed that the organization has 1 physical WiFi card, designated every bit phy#0. The device cite is wlan0. The type specifies the functioning manner of the wireless device. managed agency the device is a WiFi station or customer that connects to an access point.

  2. Check that the wireless device is up.
     $ ip link exhibit wlan0 3: wlan0: (BROADCAST,MULTICAST) mtu 1500 qdisc noop nation DOWN manner DEFAULT qlen K     link/ether 74:e5:43:a1:ce:65 brd ff:ff:ff:ff:ff:ff 

    Look for the discussion "UP" within the brackets inwards the outset describe of piece of occupation of the output.

    In the inwards a higher house example, wlan0 is non UP. Execute the next ascendance to convey it up:

     $ sudo ip link laid wlan0 upward   [sudo] password for peter:  

    Note: you lot demand origin privilege for the inwards a higher house operation.

    If you lot run the exhibit link ascendance again, you lot tin enjoin that wlan0 is similar a shot UP.

     $ ip link exhibit wlan0 3: wlan0: (NO-CARRIER,BROADCAST,MULTICAST,UP) mtu 1500 qdisc mq nation DOWN manner DEFAULT qlen K     link/ether 74:e5:43:a1:ce:65 brd ff:ff:ff:ff:ff:ff 
  3. Check the connector status.
     $ /sbin/iw wlan0 link Not connected. 

    The inwards a higher house output shows that you lot are non connected to whatever network.

  4. Scan to bring out out what WiFi network(s) are detected
     $ sudo /sbin/iw wlan0 scan BSS 00:14:d1:9c:1f:c8 (on wlan0)         ... sniped ... freq: 2412 SSID: gorilla RSN: * Version: 1  * Group cipher: CCMP  * Pairwise ciphers: CCMP  * Authentication suites: PSK  * Capabilities: (0x0000)         ... sniped ... 

    The 2 of import pieces of information from the inwards a higher house are the SSID as well as the safety protocol (WPA/WPA2 vs WEP). The SSID from the inwards a higher house representative is gorilla. The safety protocol is RSN, also unremarkably referred to every bit WPA2. The safety protocol is of import because it determines what tool you lot purpose to connect to the network.

  5. Connect to WPA/WPA2 WiFi network.

    This is a 2 pace process. First, you lot generate a configuration file for wpa_supplicant that contains the pre-shared substitution ("passphrase") for the WiFi network.

     $ sudo -s [sudo] password for peter:  $ wpa_passphrase gorilla >> /etc/wpa_supplicant.conf  ...type inwards the passphrase as well as hitting enter... 

    wpa_passphrase takes the SSID every bit the unmarried argument. You must type inwards the passphrase for the WiFi network gorilla afterward you lot run the command. Using that information, wpa_passphrase volition output the necessary configuration statements to the measure output. Those statements are appended to the wpa_supplicant configuration file located at /etc/wpa_supplicant.conf.

    Note: you lot demand origin privilege to write to /etc/wpa_supplicant.conf.

     $ truthful cat /etc/wpa_supplicant.conf  # reading passphrase from stdin network={ ssid="gorilla" #psk="testtest" psk=4dfe1c985520d26a13e932bf0acb1d4580461dd854ed79ad1a88ec221a802061 } 

    The instant pace is to run wpa_supplicant alongside the novel configuration file.

     $ sudo wpa_supplicant -B -D wext -i wlan0 -c /etc/wpa_supplicant.conf 

    -B agency run wpa_supplicant inwards the background.

    -D specifies the wireless driver. wext is the generic driver.

    -c specifies the path for the configuration file.

    Use the iw ascendance to verify that you lot are indeed connected to the SSID.

     $ /sbin/iw wlan0 link Connected to 00:14:d1:9c:1f:c8 (on wlan0) SSID: gorilla freq: 2412 RX: 63825 bytes (471 packets) TX: 1344 bytes (12 packets) signal: -27 dBm tx bitrate: 6.5 MBit/s MCS 0  bss flags:short-slot-time dtim period:0 beacon int:100 
  6. Obtain IP address past times DHCP
     $ sudo dhclient wlan0 

    Use the ip ascendance to verify the IP address assigned past times DHCP. The IP address is 192.168.1.113 from below.

     $ ip addr exhibit wlan0 3: wlan0:  mtu 1500 qdisc mq nation UP qlen K     link/ether 74:e5:43:a1:ce:65 brd ff:ff:ff:ff:ff:ff     inet 192.168.1.113/24 brd 192.168.1.255 reach global wlan0     inet6 fe80::76e5:43ff:fea1:ce65/64 reach link         valid_lft forever preferred_lft forever 
  7. Add default routing rule.

    The concluding configuration pace is to brand certain that you lot direct maintain the proper routing rules.

     $ ip road exhibit 192.168.1.0/24 dev wlan0  proto center  reach link  src 192.168.1.113  

    The inwards a higher house routing tabular array contains alone 1 dominion which redirects all traffic destined for the local subnet (192.168.1.x) to the wlan0 interface. You may desire to add together a default routing dominion to overstep all other traffic through wlan0 every bit well.

     $ sudo ip road add together default via 192.168.1.254 dev wlan0 $ ip road exhibit default via 192.168.1.254 dev wlan0  192.168.1.0/24 dev wlan0  proto center  reach link  src 192.168.1.113  
  8. ping external ip address to show connectivity
     $ ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_req=1 ttl=48 time=135 ms 64 bytes from 8.8.8.8: icmp_req=2 ttl=48 time=135 ms 64 bytes from 8.8.8.8: icmp_req=3 ttl=48 time=134 ms ^C --- 8.8.8.8 ping statistics --- three packets transmitted, three received, 0% bundle loss, fourth dimension 2000ms rtt min/avg/max/mdev = 134.575/134.972/135.241/0.414 ms 

The inwards a higher house serial of steps is a really verbose explanation of how to connect a WPA/WPA2 WiFi network. Some steps tin hold upward skipped every bit you lot connect to the same access betoken for a instant time. For instance, you lot already know the WiFi device name, as well as the configuration file is already develop for the network. The procedure needs to hold upward tailored according to your situation.

Berlangganan update artikel terbaru via email:

0 Response to "How To Connect To A Wpa/Wpa2 Wifi Network Using Linux Dominance Line"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel