Thursday, June 1, 2023

Connect to Wifi internet linux

echo 127.0.0.1    laptop > /etc/hosts
echo pcname > /etc/hostname


Connect to WIFI
sudo systemctl enable iwd

Enable dhcp client
/etc/iwd/main.conf
[General]
EnableNetworkConfiguration=true
[Rank]
BandModifier5Ghz=100.0

DNS
Either use resolv.conf for a static dns or enable systemd-resolved
/etc/resolv.conf
nameserver 4.4.4.4
nameserver 8.8.8.8
# google public dns

/etc/runit/sv/iwd/run
#!/bin/sh
exec /lib/iwd/iwd 2>/dev/null
ln -s /etc/runit/sv/iwd /run/runit/iwd


Connect to AP
rfkill 
rfkill unblock all
* if it is powered off - press FN+Wifi or Fn+Airplane Mode twice

iwctl device list
iwctl station wlan0 scan
iwctl station wlan0 get-networks
iwctl station wlan0 connect NETWORK_NAME
iwctl station wlan0 disconnect
iwctl station wlan0 show
iwctl known-networks list
iwctl known-networks NETWORK_NAME forget


ifconfig - temporary settings in kernel, not persistent at reboot
ifup/down - config /etc/network/interfaces

Don't install networkmanager 
If you do, sudo systemctl disable NetworkManager-wait-online
Systemd - waits for - multi-user environments - for the network to connect and then continues to load services and you get a long wait at boot.

===========================

ip a
dhclient -v eth0
route
ping
netstat -tapn
namp
iptables -L (INPUT - FORWARD - OUTPUT)

wpa_supplicant
wpa_password wifi_network password > wifi
ip a
rfkill -- check it is enabled
wpa_supplicant -B -i wlan0 -c ./wifi
sudo dhclient wlan0

wpa_supplicant -B -i wlan0 -c <(wpa_passphrase "Your_SSID" Your_passphrase) && dhclient wlan0

Link service to runit by 
# ln -s /etc/sv/wpa_supplicant /var/service
or systemctl enable wap_supplicant

No comments:

Post a Comment