• Armbian hostname and WiFi configuration


    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

    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-loopback
      fe00::0     ip6-localnet
      ff00::0     ip6-mcastprefix
      ff02::1     ip6-allnodes
      ff02::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_supplicant
      network={
              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 bash
      DEV=$(iw dev | awk '/Interface/ {interf=$2} END {print interf}')
      DHCL_PIDFILE=/var/run/dhclient-$DEV.pid
      WPA_PIDFILE=/var/run/wpa_supplicant-$DEV.pid
      if [[ -f $DHCL_PIDFILE ]] && kill -9 $(cat $DHCL_PIDFILE)
      then
          dhclient -v -r $DEV
          echo "IP address released"
      fi
      if [[ -f $WPA_PIDFILE ]] && kill -9 $(cat $WPA_PIDFILE)
          then
          echo "WPA supplicant killed"
      fi
      killall wpa_supplicant
      echo "wpa_supplicant killed :)"
      ifconfig -v $DEV down
      sleep 1
      ifconfig -v $DEV up
      echo "$DEV interface is up again"
      iwconfig $DEV essid 'my-wifi' channel 8
      echo "starting wpa_supplicant.."
      sleep 2
      wpa_supplicant -B -dd -i$DEV -P$WPA_PIDFILE -c/etc/wpa_supplicant/wifi.conf
      sleep 2
      echo "getting IP address.."
      dhclient -v -pf $DHCL_PIDFILE $DEV
      

    6. Run the script as root

  • 相关阅读:
    CommonJS和AMD/CMD
    map 有{}的时候需要有return 没有{}的时候不需要有return
    sublime3添加插件
    C++—模板(1)模板与函数模板
    函数的调用过程(栈帧)
    Linux-进程描述(5)之进程环境
    Linux-进程描述(4)之进程优先级与进程创建执行
    多态(2)纯虚函数与重载、重写(覆盖)、重定义(隐藏)
    多态(1)静态多态与动态多态以及虚函数相关
    Linux-进程描述(3)之进程状态僵尸进程与孤儿进程
  • 原文地址:https://www.cnblogs.com/mtcnn/p/9410033.html
Copyright © 2020-2023  润新知