Network setup: Difference between revisions

From Rsewiki
No edit summary
No edit summary
Line 1: Line 1:
Back to [[Robobot B]]
Back to [[Robobot B]]
=== NTP ===
Network Time Protocol is used to keep clocks in sync.
Raspberry Pi will start with the date and time of the last proper shutdown, and some seconds after the internet is up, it will sync the clock using NTP.
At DTU most clock sources are blocked, the clock source needs to be configured.
At DTU, edit /etc/NTP.conf or /etc/ntpsec/ntp.conf and add ntp.ait.du.dk to the top of the server pool list.
sudo nano /etc/ntpsec/ntp.conf
...
# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
pool ntp.ait.dtu.dk
...
Sync time (if on DTU net)
sudo ntpdate -u ntp.ait.dtu.dk
Should work in and around DTU - see also [[NTP howto]] for more details.


===WiFi network===
===WiFi network===
Line 73: Line 49:
The robot's name should be included in the list, but the network may take a while to detect it.
The robot's name should be included in the list, but the network may take a while to detect it.


== Depricated ==
=== NTP ===


*Old - all Raspberries now use NetworkManager, so the WPA_supplicant stuff is no longer valid.
Network Time Protocol is used to keep clocks in sync.
Raspberry Pi will start with the date and time of the last proper shutdown, and some seconds after the internet is up, it will sync the clock using NTP.


==== WPA ====
At DTU most clock sources are blocked, the clock source needs to be configured.


Replace password/passphrase with an encrypted version.
At DTU, edit /etc/NTP.conf or /etc/ntpsec/ntp.conf and add ntp.ait.du.dk to the top of the server pool list.


The '''wpa_passphrase''' generated function works to generate an encrypted passphrase:
sudo nano /etc/ntpsec/ntp.conf
(copied from Raspberry Pi forum, (thanks to 'rpdom')).


  rpdom@raspberrypi:~ $ wpa_passphrase MYSSID MYPASSPHRASE
  ...
  network={
  # Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
ssid="MYSSID"
  # on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
#psk="MYPASSPHRASE"
# more information.
psk=ENCRYPTED_PSK_IS_HERE
  pool ntp.ait.dtu.dk
  }
  ...
rpdom@raspberrypi:~ $ sudo nmcli con add con-name MYSSID \
                            type wifi ssid MYSSID \
                            wifi-sec.key-mgmt wpa-psk \
                            wifi-sec.psk ENCRYPTED_PSK_IS_HERE
  Connection 'MYSSID' (ed602d46-0a2b-4094-a2c3-79652a47d612) successfully added.
  sudo nmcli con up MYSSID


Or, if the connection is already established, then edit the relevant file and copy in the ENCRYPTED_PSK_IS_HERE to replace the clear text passphrase.
Sync time (if on DTU net)


  cd /etc/NetworkManager/system-connections
  sudo ntpdate -u ntp.ait.dtu.dk
ls
sudo nano MYSSID.nmconnection


===== 802 secure wifi =====
Should work in and around DTU - see also [[NTP howto]] for more details.
 
When connecting to Eduroam (or other with 802 security) you will eventually have to type in your username and password in the wpa_supplicant.conf-file. For your password not to be visible, generate a hash code for it
 
echo -n YOUR_COOPERATE_MAIL_PASSWORD | iconv -t utf16le | openssl md5
 
Copy the generated hash code (YOUR_COOPERATE_MAIL_PASSWORD_HASH) and clear the terminal window and the command history.
 
clear
history -c
 
A connection using 802 security could be generated with
 
nmcli connection add \
  type wifi \
  connection.id NICKNAME \
  wifi.ssid SSID \
  wifi.mode infrastructure \
  wifi-sec.key-mgmt wpa-eap \
  802-1x.eap peap \
  802-1x.identity YOUR_COOPERATE_MAIL \
  802-1x.phase2-auth mschapv2 \
  802-1x.password hash:YOUR_COOPERATE_MAIL_PASSWORD_HASH
sudo nmcli con up NICKNAME
 
Replace the UPPER case words as appropriate.
 
Or, if the connection is already established, replace the password as above (in /etc/NetworkManager/system-connections).
 
I don't know if the '''YOUR_COOPERATE_MAIL_PASSWORD_HASH''' encryption works this way.
 
==== WPA ====
 
''''No longer active''''
 
Now open wpa_supplicant.conf
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
 
If you added an wifi access point, it probably looks something like this
 
network={
        ssid="device"
        key_mgmt=NONE
}
 
or using typical security with a password
 
network={
        ssid="tdc432"
        psk="secret_password"
        key_mgmt=WPA-PSK
        id_str=home
}
 
You can add any number of the "network" groups for all the networks you get across
If you don't like the network password to be visible, see guide below.
 
====Private network====
 
Generate encrypted key with
 
wpa_passphrase mySSID secret776
 
if the desired SSID is "mySSID" and the password is "secret776", then copy the result into /etc/wpa_supplicant/wpa_supplicant.conf (except the line with the password in clear text).
 
network={
        ssid="mySSID"
        #psk="secret776"
        psk=812439e952156aea9983f3df5a389cf3f9c2e9f30ae2624eaad1551612a6ef71
}
 
====Eduroam or DTU secure====
 
When connecting to Eduroam you will eventually have to type in your username and password in the wpa_supplicant.conf-file. In order for your password not to be visible, generate a hash-code for it
 
echo -n password_here | iconv -t utf16le | openssl md5
 
Copy the hash-code and then clear the terminal window and the command history
 
clear
history -c
 
Now open wpa_supplicant.conf
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Add or replace the following (You need at least one network group)
country=DK
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
ctrl_interface_group=0
update_config=1
network={
        ssid="eduroam"
        scan_ssid=1
        key_mgmt=WPA-EAP
        eap=PEAP
        phase2="auth=MSCHAPV2"
        identity="username"
        password=hash:your_hash_code
}
network={
        ssid="DTUsecure"
        scan_ssid=1
        key_mgmt=WPA-EAP
        eap=PEAP
        phase2="auth=MSCHAPV2"
        identity="username"
        password=hash:your_hash_code
}
Replace '''username''' with your username on Eduroam, i.e. your student number and replace '''your_hash_code''' with the hash-code you generated in the previous step.
 
Reboot the Raspberry Pi
sudo reboot
or
sudo /etc/init.d/networking restart

Revision as of 15:27, 15 January 2025

Back to Robobot B

WiFi network

Network Manager

The NetworkManager uses device UUID as part of the Wi-Fi network setup. This means that (sometimes) an SD card can not be moved from one robot to another with a functional Wi-Fi connection.

After 20 seconds, an attempt to solve this is activated using the commands below (the code is found in svn/robobot/setup/rename_host.bash - last half).

Use the last line to setup manually - or the GUI, if available.

Network manager connection with UUID

nmcli connection

List available wifi access points

nmcli dev wifi

Connect to DTUdevice net

sudo nmcli device wifi connect DTUdevice password <password> ifname wlan0

This should create a new system-connection file with a usable UUID

Check IP and SSID

When the Pi has rebooted, connect to it using SSH once again. Check that the Pi is connected to WiFi

ifconfig

Under wlan0 confirm that the Pi has received an IP (inet addr) and note down the first three sections of the IP - they are most likely 10.197.21x.xxx

To see which SSID you are connected to, use

iwconfig

or

nmcli -o

The MAC address ('HWaddr' or 'ether') of the Pi should also be noted down - this probably starts with B8:27:EB:xx:xx:xx make sure to get all of it.

Find IP of robot (Linux)

In case the Pi gets a new IP address after reboot, you can search for it using the MAC address and nmap. If nmap is not installed, start by installing it

sudo apt-get install nmap

To search for the Pi using the MAC address in terminal type

nmap -sP 10.197.218.0/20 | awk '/^Nmap/{ip=$NF}/B8:27:EB:23:A0:F5/{print ip}'

where 10.197.218 is the first three sections of the IP you noted down, 20 is the number of fixed bits (out of 32), and B8:27:EB:23:A0:F5 is the MAC address of the Pi. This should return the IP of the Pi.

NB! the MAC can hold letters, they should probably be capital.

If you don't know the IP address

Use the first part to get a list of active IPs on the net:

 nmap -sP 10.197.218.0/24

The robot's name should be included in the list, but the network may take a while to detect it.

NTP

Network Time Protocol is used to keep clocks in sync. Raspberry Pi will start with the date and time of the last proper shutdown, and some seconds after the internet is up, it will sync the clock using NTP.

At DTU most clock sources are blocked, the clock source needs to be configured.

At DTU, edit /etc/NTP.conf or /etc/ntpsec/ntp.conf and add ntp.ait.du.dk to the top of the server pool list.

sudo nano /etc/ntpsec/ntp.conf

...
# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
pool ntp.ait.dtu.dk
...

Sync time (if on DTU net)

sudo ntpdate -u ntp.ait.dtu.dk

Should work in and around DTU - see also NTP howto for more details.