zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Zookeeper实战
    Zookeeper的结构和命令
    Zookeeper中的选举机制
    du 命令,对文件和目录磁盘使用的空间的查看
    rm命令
    linux之cp/scp命令+scp命令详解
    android 为应用程序创建桌面快捷方式技巧分享
    对自己的文件使用keystore签名
    Android 打包签名 从生成keystore到完成签名 -- 转
    Android App启动错误的问题(connection to the server was unsuccessful)
  • 原文地址:https://www.cnblogs.com/mtcnn/p/9410033.html
Copyright © 2011-2022 走看看