Network setup: Difference between revisions

From Rsewiki
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
Back to [[Robobot]]
Back to [[Robobot]]


=== Network setup ===
Back to [[Robobot B]]


Access using ssh and username local
ssh -X local@<IP>
ask for the password (or look on the course page)


=== NTP ===
=== NTP ===
Line 14: Line 9:
At DTU most clock sources are blocked, the clock source needs to be configured.
At DTU most clock sources are blocked, the clock source needs to be configured.


At DTU, edit /etc/ntp.conf, add ntp.ait.du.dk to server pool
At DTU, edit /etc/ntp.conf (or maybe /etc/ntpsec/ntp.conf), add ntp.ait.du.dk to server pool
 
sudo nano /etc/ntpsec/ntp.conf


  ...
  ...
Line 29: Line 26:
Should work in and around DTU - see also [[NTP howto]] for more details.
Should work in and around DTU - see also [[NTP howto]] for more details.


====WiFi network====
===WiFi network===


Now open wpa_supplicant.conf
Now open wpa_supplicant.conf
Line 48: Line 45:
         key_mgmt=WPA-PSK
         key_mgmt=WPA-PSK
         id_str=home
         id_str=home
}
}


You can add any number of the "network" groups for all the networks you get across
You can add any number of the "network" groups for all the networks you get across
Line 67: Line 64:
  }
  }


====Connecting Raspberry Pi to Eduroam====
====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
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
Line 80: Line 77:
Now open wpa_supplicant.conf
Now open wpa_supplicant.conf
  sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
  sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Comment out or replace whatever in this file so that the content corresponds to the following
Add or replace the following (You need at least one network group)
  country=DK
  country=DK
  ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
  ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
Line 87: Line 84:
  network={
  network={
         ssid="eduroam"
         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
         scan_ssid=1
         key_mgmt=WPA-EAP
         key_mgmt=WPA-EAP
Line 101: Line 107:
  sudo /etc/init.d/networking restart
  sudo /etc/init.d/networking restart


==== IP and SSID ====
=== Check IP and SSID ===


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


NB! the MAC can hold letters, they should probably be capital.
NB! the MAC can hold letters, they should probably be capital.
==== If you don't know the MAC address====


Use the first part, to get a list of active IP on the net:
Use the first part, to get a list of active IP on the net:
   nmap -sP 10.16.175.0/24
   nmap -sP 10.16.175.0/24
The name of the robot should be included in the list, but it can take a while for the network to detect the name.

Latest revision as of 18:50, 3 April 2024

Back to Robobot

Back to Robobot B


NTP

Network time protocol, to keep clocks in sync. At DTU most clock sources are blocked, the clock source needs to be configured.

At DTU, edit /etc/ntp.conf (or maybe /etc/ntpsec/ntp.conf), add ntp.ait.du.dk to server pool

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

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 md4

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

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.16.175.xxx

To see which SSID you are connected to use

iwconfig

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.16.175.0/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB:23:A0:F5/{print ip}'

where 10.16.175 is the first three sections of the IP you noted down 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 MAC address

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

 nmap -sP 10.16.175.0/24

The name of the robot should be included in the list, but it can take a while for the network to detect the name.