Armbian hostname and WiFi configuration

来源:互联网 发布:叶子流量卡淘宝店地址 编辑:程序博客网 时间:2024/05/22 09:12

In previous post i have described installation of Armbian on Orange Pi PC Plus. Now is the time for some initial configuration (hostname and WIFI setup).

Table of Contents

  • Changing hostname
  • Configuring WIFI to work with WPA2

Changing hostname

  1. Check current hostname with hostname
  2. Check current fully qualified domain name (or FQDN) with hostname --fqd
  3. Set new hostname: sudo hostname pi
  4. Update /etc/hostname for Debian to get new hostname after reboot
  5. Update /etc/hosts so that FQDN is before short localhost next to IP:

    127.0.0.1   pi.example.com pi localhost::1         pi.example.com pi localhost ip6-localhost ip6-loopbackfe00::0     ip6-localnetff00::0     ip6-mcastprefixff02::1     ip6-allnodesff02::2     ip6-allrouters

  6. Reboot with sudo reboot

Configuring WIFI to work with WPA2

There are various ways for configuring WIFI with wpa_suplicant. You may consider settings things up in /etc/network/interfaces if you want WIFI to be started automatically upon system startup. I have decided on another approach: using script for starting all manually.

  1. wpa_supplicant should be installed but needs to be run as root: sudo wpa_supplicant -v.`
  2. In the next steps you will need BSSID (access point MAC address) and channel. Turn on your WIFI card with sudo ifconfig wlan0 upand scan for your network with sudo iwlist wlan0 scan | egrep 'Address|ESSID|Channel'.
  3. Prepare configuration file for wpa_supplicant in /etc/wpa_supplicant folder. You could have more files there with different names. Our file will be named wifi.conf.
  4. Adjust the content of the file: replace 00:14:6C:AE:EA:AEmy-wifi and P@ssw0rd with your access point MAC address, your WIFI network name and your WIFI password respectively:

    ctrl_interface=DIR=/var/run/wpa_supplicantnetwork={        bssid=00:14:6C:AE:EA:AE        ssid="my-wifi"        scan_ssid=1        key_mgmt=WPA-PSK        psk="P@ssw0rd"}

  5. Create a script and add execute permissions. Replace my-wifi8 and wifi.conf with your WIFI name, channel and WPA supplicant configuration file name:

    #!/usr/bin/env bashDEV=$(iw dev | awk '/Interface/ {interf=$2} END {print interf}')DHCL_PIDFILE=/var/run/dhclient-$DEV.pidWPA_PIDFILE=/var/run/wpa_supplicant-$DEV.pidif [[ -f $DHCL_PIDFILE ]] && kill -9 $(cat $DHCL_PIDFILE)then    dhclient -v -r $DEV    echo "IP address released"fiif [[ -f $WPA_PIDFILE ]] && kill -9 $(cat $WPA_PIDFILE)    then    echo "WPA supplicant killed"fikillall wpa_supplicantecho "wpa_supplicant killed :)"ifconfig -v $DEV downsleep 1ifconfig -v $DEV upecho "$DEV interface is up again"iwconfig $DEV essid 'my-wifi' channel 8echo "starting wpa_supplicant.."sleep 2wpa_supplicant -B -dd -i$DEV -P$WPA_PIDFILE -c/etc/wpa_supplicant/wifi.confsleep 2echo "getting IP address.."dhclient -v -pf $DHCL_PIDFILE $DEV

  6. Run the script as root