Last edited 2 months ago

How to configure ethernet interface

Applicable for STM32MP13x lines, STM32MP15x lines, STM32MP25x lines

1. Purpose[edit | edit source]

This article describes how to configure the Ethernet interface.
This article provides two ways to make it:

  • via ifconfig: to put quickly and temporary the Ethernet interface with static IP address.
  • via systemd: to change durably the Ethernet configuration with static IP address
Warning white.png Warning
Since ecosystem release ≥ v5.0.0 More info.png , eth0 was renamed in end0

2. Using Ifconfig tools[edit | edit source]

  • Connect an Ethernet cable and enjoy

At startup SSH daemon (sshd) and ifplugd daemon are automatically launched:

  • sshd (useful to perform ssh, scp)
  • ifplugd detect:
    • udhcpc is launched on cable detection to retrieve an IP address,

If a DHCP server is not available, one can set the Ethernet IP adress with :

  ifconfig end0 uuu.xxx.yyy.zzz
Warning white.png Warning
If there is some service such as systemd-networkd, NetworkManager, Connman , the configuration of Ethernet interface can change when the service see the change


To check if end0 and the gateway are well configured, one can type:
 ifconfig
 route
In the console, a log similar to the one below should be displayed:
  ifconfig
 end0      Link encap:Ethernet  HWaddr 00:80:E1:01:39:61  
           inet addr:10.48.1.172  Bcast:10.48.3.255  Mask:255.255.252.0
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:18 errors:0 dropped:0 overruns:0 frame:0
           TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000 
           RX bytes:3038 (2.9 KiB)  TX bytes:684 (684.0 B)
           Interrupt:103 
 STM32MP1 # route
 Kernel IP routing table
 Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
 default         lme-gw-vl802.lm 0.0.0.0         UG    10     0        0 end0
 10.48.0.0       *               255.255.252.0   U     0      0        0 end0

3. Using systemd-networkd service[edit | edit source]

Systemd-networkd is a network service provided by systemd.

3.1. Ethernet interface[edit | edit source]

Systemd-networkd provides a directory on which the Ethernet interface must be configured via configuration file: /lib/systemd/network.

  ls /lib/systemd/network
50-wired.network            52-static.network.static    80-container-vz.network
50-wired.network.static     80-container-host0.network  99-default.link 
51-wireless.network.sample  80-container-ve.network

ST provide some configurations file:

  • 50-wired.network: basic DHCP configuration for each endX ethernet interface
  • 50-wired.network.static: example of basic DHCP configuration on which end0 are exclude of list
  • 52-static.network.static: example of static IP configuration for end0

3.2. Configuration file[edit | edit source]

Example of configuration:
DHCP configuration;

[Match]
Name=end*

[Network]
DHCP=ipv4

Static IP configuration:

[Match]
Name=end0

[Network]
DNS=192.168.72.254
Address=192.168.72.2/24
Gateway=192.168.72.254

[Match]

  • MACAddress= a whitespace-separated list of hardware addresses
  • Name= a white-space separated list of device names or expression (e.g. end*).
  • Host= the machine hostname

[NETWORK]
[Network]

  • DHCP= enables the DHCP client, value can be: yes, no, ipv4, ipv6
  • DHCPServer= enables the DHCP server for this configuration
  • DNS= list DNS addresses in case of static configuration (you may specify several addresses)
  • IPForward= configures IP packet forwarding, value can be: ipv4 or ipv6
  • IPMasquerade= configures IP masquerading for the network interface. If enabled, packets forwarded from the network interface will be appear as coming from the local host. Takes a boolean argument. Implies IPForward=ipv4. Defaults to "no". Value can be yes or no.

All parameters are described on official documentation of systemd-networkd: [1]

3.3. DHCP configuration[edit | edit source]

DHCP configuration;

[Match]
Name=end*

[Network]
DHCP=ipv4

All Ethernet interface are configured with DHCP client address.

3.4. STATIC configuration[edit | edit source]

Static configuration;
Add a new file 52-static.network with the following content
(/lib/systemd/network/50-wired.network or /lib/systemd/network/52-static.network)

[Match]
Name=end0

[Network]
DNS=192.168.72.254
Address=192.168.72.2/24
Gateway=192.168.72.254

End0 Ethernet interface are configured with static IP address.


Info white.png Information
In case of static configuration or specific configuration, please take care to not configure two time your Ethernet interface
.With the static configuration example you need to exclude end0 interface of default configuration (here 50-wired.network)


Exclude end0 from default Ethernet configuration:
Change the file 50-wired.network (or 80-wired.network) with the following content
(/lib/systemd/network/50-wired.network or /lib/systemd/network/80-wired.network)

[Match]
Name=end[1-9]

[Network]
DHCP=ipv4

3.5. DHCP Server configuration[edit | edit source]

DHCP server example:

[Match]
Name=end0

[Network]
Address=192.168.72.1/24
DHCPServer=yes
IPForward=ipv4
IPMasquerade=yes

4. References[edit | edit source]