Setup Wi-Fi Ubuntu Dari Command Line

Di Linux desktop yang sudah memiliki Network Manager, mengatur koneksi wireless tidak terlalu sulit. GUI untuk wireless sudah cukup mudah untuk dipakai. Tapi bagaimana bila saya tidak punya tampilan GUI hanya console terminal saja? Saya belum pernah sebelumnya mengatur koneksi wireless tanpa bantuan Network Manager. Tadi saya belajar cara mengatur koneksi WiFi di Ubuntu 12.04 lewat command line. Tentu saja saya harus mematikan Network Manager (menu GUI) terlebih dulu.

root@x220:~# /etc/init.d/network-manager stop

Bila access point yang dipakai menggunakan autentikasi (WPA,WPA2) maka untuk mengatur koneksi wireless-nya kita perlu aplikasi wpa_supplicant. Install dulu dengan perintah berikut :

root@x220:~# apt-get install wpasupplicant
root@x220:~# dpkg -l | grep wpasupplicant
ii  wpasupplicant                             0.7.3-6ubuntu2                          client support for WPA and WPA2 (IEEE 802.11i)
root@x220:~#

Di laptop saya wireless adapter-nya dikenali sebagai wlan0, maka saya perlu mendaftarkannya dulu ke dalam file /etc/network/interfaces :

root@x220:~# cat /etc/network/interfaces 
auto lo
iface lo inet loopback

auto wlan0
	iface wlan0 inet dhcp
	wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

root@x220:~#

Untuk masalah autentikasi password, saya perlu mengatur file wpa_supplicant.conf seperti berikut ini :

root@x220:~# cat /etc/wpa_supplicant/wpa_supplicant.conf 
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=root
network={
        ssid="GBT733"
        scan_ssid=1
        proto=WPA RSN
        key_mgmt=WPA-PSK
        pairwise=CCMP TKIP
        group=CCMP TKIP
        psk=da5d79195468cf3f7cb498731beac2136e8b9fccd11d90182a8d668ddbd660bb
}
root@x220:~#

Beberapa detil yang perlu dipahami dari konfigurasi di atas adalah :

  • ssid : nama access point.
  • proto : tipe wireless security yang dipakai oleh access point. Bisa WPA (Wi-Fi Protected Access) atau RSN (Robust Security Network). RSN ini juga dikenal sebagai WPA2 (Wi-Fi Protected Access II).
  • key_mgmt : menentukan tipe enkripsi dari wireless password-nya. WPA-PSK (WPA Pre-shared Key). Kenapa WPA-PSK karena access point saya menggunakan mode sekuriti WPA2-Personal.
  • pairwise & group : mengatur tipe algoritma enkripsi dari password Wi-Fi.
  • psk : pre shared key hasil enkripsi dari ASCII password

PSK didapat dari hasil enkripsi password Wi-Fi yang berupa text (password Wi-Fi yang kita kenal sehari-hari). Misalnya access point saya menggunakan nama SSID GBT733 dan password-nya adalah ‘testingpassword‘, untuk mendapat WPA PSK saya gunakan perintah berikut ini :

root@x220:~# wpa_passphrase GBT733 testingpassword
network={
	ssid="GBT733"
	#psk="testingpassword"
	psk=da5d79195468cf3f7cb498731beac2136e8b9fccd11d90182a8d668ddbd660bb
}
root@x220:~#

Setelah semua sudah diset, tinggal restart network service-nya dengan perintah :

root@x220:~# /etc/init.d/networking restart
 * Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
 * Reconfiguring network interfaces...                                                                                                                                                           ssh stop/waiting
ssh start/running, process 13925
                                                                                                                                                                                          [ OK ]
root@x220:~# 

Di syslog saya bisa lihat DHCP client mencoba mengakses access point & meminta IP address :

root@x220:~# tail -f /var/log/messages
Feb 26 10:53:27 x220 kernel: [273753.765617] iwlwifi 0000:03:00.0: L1 Enabled; Disabling L0S
Feb 26 10:53:27 x220 kernel: [273753.765806] iwlwifi 0000:03:00.0: Radio type=0x1-0x2-0x0
Feb 26 10:53:27 x220 kernel: [273753.894034] ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb 26 10:53:27 x220 dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3
Feb 26 10:53:30 x220 dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
Feb 26 10:53:31 x220 wpa_supplicant[13818]: Trying to authenticate with 90:f6:52:43:82:44 (SSID='GBT733' freq=2437 MHz)
Feb 26 10:53:31 x220 wpa_supplicant[13818]: Trying to associate with 90:f6:52:43:82:44 (SSID='GBT733' freq=2437 MHz)
Feb 26 10:53:31 x220 kernel: [273757.284480] wlan0: authenticate with 90:f6:52:43:82:44 (try 1)
Feb 26 10:53:31 x220 kernel: [273757.287179] wlan0: authenticated
Feb 26 10:53:31 x220 kernel: [273757.287454] wlan0: associate with 90:f6:52:43:82:44 (try 1)
Feb 26 10:53:31 x220 kernel: [273757.291546] wlan0: RX AssocResp from 90:f6:52:43:82:44 (capab=0x431 status=0 aid=2)
Feb 26 10:53:31 x220 kernel: [273757.291550] wlan0: associated
Feb 26 10:53:31 x220 wpa_supplicant[13818]: Associated with 90:f6:52:43:82:44
Feb 26 10:53:31 x220 kernel: [273757.299586] ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
Feb 26 10:53:31 x220 wpa_supplicant[13818]: WPA: Key negotiation completed with 90:f6:52:43:82:44 [PTK=CCMP GTK=TKIP]
Feb 26 10:53:31 x220 wpa_supplicant[13818]: CTRL-EVENT-CONNECTED - Connection to 90:f6:52:43:82:44 completed (auth) [id=0 id_str=]
Feb 26 10:53:31 x220 kernel: [273757.358903] wlan0: Wrong control channel in association response: configured center-freq: 2437 hti-cfreq: 2417  hti->control_chan: 2 band: 0.  Disabling HT.
Feb 26 10:53:34 x220 dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 9
Feb 26 10:53:34 x220 dhclient: DHCPREQUEST of 192.168.1.112 on wlan0 to 255.255.255.255 port 67
Feb 26 10:53:34 x220 dhclient: DHCPOFFER of 192.168.1.112 from 192.168.1.1
Feb 26 10:53:34 x220 dhclient: DHCPACK of 192.168.1.112 from 192.168.1.1
Feb 26 10:53:34 x220 dhclient: bound to 192.168.1.112 -- renewal in 36185 seconds.

Terlihat proses autentikasi sukses & wireless adapter saya mendapat IP 192.168.1.112.

root@x220:~# ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr 10:0b:a9:a1:f5:b8  
          inet addr:192.168.1.112  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::120b:a9ff:fea1:f5b8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:556117 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1859518 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:96155942 (96.1 MB)  TX bytes:2764438662 (2.7 GB)

root@x220:~# 

One thought on “Setup Wi-Fi Ubuntu Dari Command Line

Leave a Reply