mcx-rtos v.2022.03 Network Configuration
4 minute read
Network Configuration
This section describes how to configure your wifi
, wired
or etherCAT
network.
Network Directory
Default network files are stored in the following directory:
/etc/systemd/network
├── 10-igb-quirks.link
├── 25-wifi.network
├── 50-wired.network
└── 51-ethercat.network
The network
directory displays the default network configuration for WiFi
, Wired
and EtherCAT
based on Systemd.network.
Note
When changing the network configuration, it is recommended to use the default files as a template. Note that the network directory should only contain one set of 25-.. 50-.. and 51-..
files.
Wired Network Configuration
How to change the wired network settings:
-
Navigate to the network directory:
cd /etc/systemd/network
-
Edit
50-wired.network
:sudo nano 50-wired.network
Displays the default configuration:
# Wired network settings [Match] Name=eth0 [Network] DHCP=yes IPForward=yes [Address] Label=eth0:0 Address=192.168.2.100/24
This configuration tries to configure a connection with DHCP and in case there is no DHCP server on your network it configures a static IP.
You can change the static IP address to what you prefer.
Note
When changing the network device (something other than eth0
), make sure you check the configuration of the etherCAT network device such that there are no conflicting settings.
-
Save the file and reboot your controller:
sudo reboot
Now your wired network settings are changed!
Note
After changing the controller IP address, you need to configure your network again.
EtherCAT Network Configuration
How to change the etherCAT network configuration:
The network device that is used for etherCAT must be configured as unmanaged
such that the regular network driver do not claim the device.
-
Navigate to the network directory:
cd /etc/systemd/network
-
Edit
51-ethercat.network
:sudo nano 51-ethercat.network
Displays the default configuration:
# EtherCat network settings [Match] Name=eth1 [Link] Unmanaged=yes
Here we reserve device
eth1
for etherCAT and make sure it does not get attached to a regular network driver. -
Save the file and reboot your controller:
sudo reboot
Note
The assigned etherCAT network device, must match the assigned network device in the EtherCAT Device Configuration.
WiFi Configuration
How to change the wifi configuration:
-
Navigate to the network directory:
cd /etc/systemd/network
-
Edit the file
25-wifi.network
:sudo nano 25-wifi.network
Displays the default configuration:
# Wifi network settings [Match] Name=wlan0 [Network] Address=192.168.0.1/24 DHCPServer=yes PoolOffset = 10 PoolSize = 40 EmitDNS = yes DNS = 8.8.8.8 8.8.4.4 DefaultLeaseTimeSec = 600 MaxLeaseTimeSec = 7200
-
Change the security setting of your WiFi:
sudo nano /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
By default the WiFi connection is configured as an Access Point to which an external system can connect using the default passphrase “vectioneer”. The default configuration is shown below.
network={ ssid="mcx-428c36" #psk="vectioneer" psk=373b4c981c2b7c30be346d560b6a7f04c313e7c66e841915db053d9d61a21bd7 mode=2 proto=RSN key_mgmt=WPA-PSK pairwise=CCMP group=CCMP frequency=2437 }
You can change the SSID by modifying the ssid field. You can enter a new passphrase by either putting the literal passphrase (readable) in quotes:
psk="mynewpassword"
Or you can generate a password hash by using the
wpa_passphrase
tool:wpa_passphrase {SSID} {NEWPASSPHRASE}
This outputs a new hashed passphrase section that you can transfer into your configuration file.
-
Save the file and reboot your controller:
sudo reboot
EtherCAT Device Configuration
The EtherCAT master needs to know which network device it will use for EtherCAT. The EtherCAT network device should not be configured for normal networking.
-
Change the EtherCAT network settings:
sudo nano /etc/ethercat.conf
The important settings in this file are which network adapter to use and which driver to use.
Note
Make sure that the network device that you wish to assign to the EtherCAT driver is not already taken by the normal network configuration see wired network configuration.
-
You can select your network adapter by modifying the following line:
MASTER0_DEVICE="eth1"
-
To select the driver type, change the line:
DEVICE_MODULES="generic"
Refer to the EtherLAB documentation for a description of all available configuration options.
-
Save the file and reboot your controller:
sudo reboot
cert-gen Configuration
It is possible that due to the network change the communication certificate has become invalid. For security reasons, the certificate is only valid for the ip address and hostname of the controller. MCX-Linux OS provides a certificate renewal service that checks the certificate and renews it if either it has expired or if the host name or ip address has changed.
-
Stop motorcortex:
sudo motorcortex stop
-
Edit cert-gen settings:
sudo nano /usr/share/cert-gen/config.json
Displays the default configuration:
{ "days": 365, "commonName": "Motorcortex", "organizationalUnit": "Development", "organization": "", "country": "", "locality": "", "province": "", "ip": ["192.168.2.100"], "hostname": ["motorcortex"] }
-
Change
"ip"
and"hostname"
to the current network settings and save file. -
Restart the service to generate the new certificate:
sudo /etc/init.d/cert-gen restart
-
Start motorcortex:
sudo motorcortex start