Setup Wifi Arch Linux


Đầu tiên ta cài driver cho Arch Linux

 sudo pacman -S wpa_supplicant

Ta xem card usb wifi có được Arch Linux nhận không

[dt@dt-arco ~]$ lsusb
Bus 002 Device 004: ID 05ac:8406 Apple, Inc. Internal Memory Card Reader
Bus 002 Device 003: ID 2109:0817 VIA Labs, Inc. USB3.0 Hub             
Bus 002 Device 002: ID 0080:a001 Unknown JMS578 based SATA bridge
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 05ac:0259 Apple, Inc. Internal Keyboard/Trackpad
Bus 001 Device 006: ID 413c:301a Dell Computer Corp. Dell MS116 Optical Mouse
Bus 001 Device 008: ID 2357:010c TP-Link TL-WN722N v2/v3 [Realtek RTL8188EUS]
Bus 001 Device 005: ID 0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet
Bus 001 Device 004: ID 05ac:0250 Apple, Inc. Aluminium Keyboard (ISO)
Bus 001 Device 002: ID 2109:2817 VIA Labs, Inc. USB2.0 Hub             
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[dt@dt-arco ~]$ 

Card usb wifi của mình là TP-Link TL-WN722N v2/v3 [Realtek RTL8188EUS]

% ip address        
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
4: wlp0s20u2u2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 7c:8b:ca:19:fa:bb brd ff:ff:ff:ff:ff:ff

Ta thấy có card wifi là wlp0s20uu2. Có nhiều gói để quản lý mạng wifi, ở đây minh cài gói netctl.

sudo pacman -S netctl dhcpcd

Sau khi cài xong ta gỏ.

sudo wifi-menu

wifi

wifi

Sau đó chọn điểm truy cập (SSID) và password. Khi đó wifi-menu hỏi có tạo profile không thì đặt tên profile, ở đây mình đặt là wifi_vnpt.

Ta kiểm tra profile wifi_vnpt có chạy hay chưa.

sudo netctl status wifi_vnpt

% sudo netctl status wifi_vnpt
● netctl@wifi_vnpt.service - Networking for netctl profile wifi_vnpt
     Loaded: loaded (/usr/lib/systemd/system/netctl@.service; static)
     Active: active (exited) since Mon 2021-08-30 10:38:44 +07; 40s ago
       Docs: man:netctl.profile(5)
    Process: 3393 ExecStart=/usr/lib/netctl/network start wifi_vnpt (code=exited, status=0/SUCCESS)
   Main PID: 3393 (code=exited, status=0/SUCCESS)
     Status: "online"
      Tasks: 6 (limit: 9421)
     Memory: 2.2M
        CPU: 252ms
     CGroup: /system.slice/system-netctl.slice/netctl@wifi_vnpt.service
             ├─3403 wpa_supplicant -q -B -P /run/wpa_supplicant-wlp0s20u2u2.pid -i wlp0s20u2u2 -D nl802>
             ├─3457 "dhcpcd: wlp0s20u2u2 [ip4]" "" "" "" "" "" "" "" ""
             ├─3458 "dhcpcd: [privileged actioneer] wlp0s20u2u2 [ip4]"
             ├─3459 "dhcpcd: [control proxy] wlp0s20u2u2 [ip4]"
             ├─3467 "dhcpcd: [BPF ARP] wlp0s20u2u2 192.168.1.15"
             └─3519 "dhcpcd: [network proxy] 192.168.1.15"

Thg 8 30 10:38:44 dt-arco dhcpcd[3454]: dhcpcd-9.4.0 starting
Thg 8 30 10:38:44 dt-arco dhcpcd[3458]: DUID 00:04:f6:f0:c8:85:66:da:15:51:9d:04:d1:b1:ce:9a:93:09
Thg 8 30 10:38:44 dt-arco dhcpcd[3458]: wlp0s20u2u2: IAID ca:19:fa:bb
Thg 8 30 10:38:45 dt-arco dhcpcd[3458]: wlp0s20u2u2: soliciting a DHCP lease
Thg 8 30 10:38:45 dt-arco dhcpcd[3458]: wlp0s20u2u2: offered 192.168.1.15 from 192.168.1.1
Thg 8 30 10:38:45 dt-arco dhcpcd[3458]: wlp0s20u2u2: probing address 192.168.1.15/24
Thg 8 30 10:38:50 dt-arco dhcpcd[3458]: wlp0s20u2u2: leased 192.168.1.15 for 86400 seconds
Thg 8 30 10:38:50 dt-arco dhcpcd[3458]: wlp0s20u2u2: adding route to 192.168.1.0/24
Thg 8 30 10:38:50 dt-arco dhcpcd[3458]: wlp0s20u2u2: adding default route via 192.168.1.1
Thg 8 30 10:38:50 dt-arco network[3393]: Started network profile 'wifi_vnpt'

/etc/netctl took 2s
% 

Ta xem ip đã xin được chưa.

% ip address       
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
4: wlp0s20u2u2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 7c:8b:ca:19:fa:bb brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.15/24 brd 192.168.1.255 scope global dynamic noprefixroute wlp0s20u2u2
       valid_lft 84897sec preferred_lft 74097sec
    inet6 2001:ee0:56b4:dc70:7e8b:caff:fe19:fabb/64 scope global dynamic mngtmpaddr 
       valid_lft 866sec preferred_lft 866sec
    inet6 fe80::7e8b:caff:fe19:fabb/64 scope link 
       valid_lft forever preferred_lft forever

/etc/netctl
% 

Như vậy card wifi đã có được ip 192.168.1.15/24 Để mỗi lần khởi động profile tự chạy luôn ta dùng.

sudo netctl enable wifi_vnpt

Lưu ý là nếu các bạn có cài NetworkManager thì phải stop và disable nó đi không là sẽ bị conflict.

[dt@dt-arco netctl]$ systemctl stop NetworkManager.service
[dt@dt-arco netctl]$ systemctl disable  NetworkManager.service
Removed /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
Removed /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service.
[dt@dt-arco netctl]$ 

Vậy thì khi ta tạo profile bằng sudo wifi-menu thì profile này lưu tại /etc/netctl/

% cd /etc/netctl

/etc/netctl
% ls
ethernet  examples  hooks  interfaces  wifi_vnpt

/etc/netctl
% sudo cat wifi_vnpt          
[sudo] password for dt: 
Description='Automatically generated profile by wifi-menu'
Interface=wlp0s20u2u2
Connection=wireless
Security=wpa
ESSID=VNPT_D
IP=dhcp
Key=<your key here>

/etc/netctl
% 

TroubleShooting

Vì lý do gì đó khi ta gõ sudo netctl start wifi_vnpt mà không start được profile thì ta xóa profile wifi_vnpt.

sudo rm -rf wifi_vnpt 

Và làm lại các bước trên để tạo profile. Như vậy là ta đã biết cách setup wifi trên Arch Linux rồi nhé.