deleted>Frq08988 mNo edit summary |
Registered User mNo edit summary |
||
(14 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
<noinclude> | <noinclude>{{ApplicableFor | ||
{{ | |MPUs list=STM32MP13x,STM32MP15x | ||
|MPUs checklist=STM32MP13x, STM32MP15x | |||
}}</noinclude> | |||
</noinclude> | |||
== Purpose == | == Purpose == | ||
This article describes how to configure the Ethernet interface | This article describes how to configure the Ethernet interface. <br/> | ||
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 | |||
== Using [[Ifconfig]] tools== | |||
* <big>'''''Connect an Ethernet cable and enjoy'''''</big> | * <big>'''''Connect an Ethernet cable and enjoy'''''</big> | ||
At startup SSH daemon (sshd) and ifplugd daemon are automatically launched: | At startup SSH daemon (sshd) and ifplugd daemon are automatically launched: | ||
Line 18: | Line 18: | ||
If a DHCP server is not available, one can set the Ethernet IP adress with : | If a DHCP server is not available, one can set the Ethernet IP adress with : | ||
{{Board$}} ifconfig eth0 uuu.xxx.yyy.zzz | {{Board$}} ifconfig eth0 uuu.xxx.yyy.zzz | ||
{{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}}<br /> | |||
::To check if eth0 and the gateway are well configured, one can type: | ::To check if eth0 and the gateway are well configured, one can type: | ||
Line 37: | Line 39: | ||
default lme-gw-vl802.lm 0.0.0.0 UG 10 0 0 eth0 | default lme-gw-vl802.lm 0.0.0.0 UG 10 0 0 eth0 | ||
10.48.0.0 * 255.255.252.0 U 0 0 0 eth0 | 10.48.0.0 * 255.255.252.0 U 0 0 0 eth0 | ||
== Using systemd-networkd service == | |||
''Systemd-networkd'' is a network service provided by systemd. <br/> | |||
=== Ethernet interface === | |||
''Systemd-networkd'' provides a directory on which the Ethernet interface must be configured via configuration file: /lib/systemd/network. | |||
{{Board$}} 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 '''ethX''' ethernet interface | |||
* 50-wired.network.static: example of basic DHCP configuration on which eth0 are exclude of list | |||
* 52-static.network.static: example of static IP configuration for eth0 | |||
=== Configuration file === | |||
Example of configuration:<br> | |||
DHCP configuration; | |||
<pre> | |||
[Match] | |||
Name=eth* | |||
[Network] | |||
DHCP=ipv4 | |||
</pre> | |||
Static IP configuration: | |||
<pre> | |||
[Match] | |||
Name=eth0 | |||
[Network] | |||
DNS=192.168.72.254 | |||
Address=192.168.72.2/24 | |||
Gateway=192.168.72.254 | |||
</pre> | |||
'''[Match]''' <br/> | |||
* '''MACAddress=''' a whitespace-separated list of hardware addresses | |||
* '''Name=''' a white-space separated list of device names or expression (e.g. eth*). | |||
* '''Host=''' the machine hostname | |||
'''[NETWORK]'''<br/> | |||
[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: <ref>https://www.freedesktop.org/software/systemd/man/systemd.network.html</ref> | |||
=== DHCP configuration === | |||
DHCP configuration; | |||
<pre> | |||
[Match] | |||
Name=eth* | |||
[Network] | |||
DHCP=ipv4 | |||
</pre> | |||
All Ethernet interface are configured with DHCP client address. | |||
=== STATIC configuration === | |||
Static configuration;<br/> | |||
Add a new file 52-static.network with the following content<br/> | |||
(/lib/systemd/network/50-wired.network or /lib/systemd/network/52-static.network) | |||
<pre> | |||
[Match] | |||
Name=eth0 | |||
[Network] | |||
DNS=192.168.72.254 | |||
Address=192.168.72.2/24 | |||
Gateway=192.168.72.254 | |||
</pre> | |||
Eth0 Ethernet interface are configured with static IP address. | |||
{{Info|In case of static configuration or specific configuration, please take care to not configure two time your Ethernet interface<br/>, with the static configuration example you need to exclude eth0 interface of default configuration (here 50-wired.network) }}<br /> | |||
Exclude eth0 from default Ethernet configuration:<br/> | |||
Change the file 50-wired.network (or 80-wired.network) with the following content<br/> | |||
(/lib/systemd/network/50-wired.network or /lib/systemd/network/80-wired.network) | |||
<pre> | |||
[Match] | |||
Name=eth[1-9] | |||
[Network] | |||
DHCP=ipv4 | |||
</pre> | |||
=== DHCP Server configuration === | |||
DHCP server example: | |||
<pre> | |||
[Match] | |||
Name=eth0 | |||
[Network] | |||
Address=192.168.72.1/24 | |||
DHCPServer=yes | |||
IPForward=ipv4 | |||
IPMasquerade=yes | |||
</pre> | |||
==References== | ==References== | ||
<references /> | <references /> | ||
<noinclude> | |||
[[Category:Ethernet]] | |||
{{PublicationRequestId | 10180 | 2019-01-07 | BrunoB }} | |||
</noinclude> |
Latest revision as of 18:46, 24 January 2023
1. Purpose
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
2. Using Ifconfig tools
- 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 :
Template:Board$ ifconfig eth0 uuu.xxx.yyy.zzz
- To check if eth0 and the gateway are well configured, one can type:
Template:Board$ifconfig Template:Board$route
- In the console, a log similar to the one below should be displayed:
Template:Board$ ifconfig eth0 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 eth0 10.48.0.0 * 255.255.252.0 U 0 0 0 eth0
3. Using systemd-networkd service
Systemd-networkd is a network service provided by systemd.
3.1. Ethernet interface
Systemd-networkd provides a directory on which the Ethernet interface must be configured via configuration file: /lib/systemd/network.
Template:Board$ 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 ethX ethernet interface
- 50-wired.network.static: example of basic DHCP configuration on which eth0 are exclude of list
- 52-static.network.static: example of static IP configuration for eth0
3.2. Configuration file
Example of configuration:
DHCP configuration;
[Match]
Name=eth*
[Network]
DHCP=ipv4
Static IP configuration:
[Match]
Name=eth0
[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. eth*).
- 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
DHCP configuration;
[Match]
Name=eth*
[Network]
DHCP=ipv4
All Ethernet interface are configured with DHCP client address.
3.4. STATIC configuration
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=eth0
[Network]
DNS=192.168.72.254
Address=192.168.72.2/24
Gateway=192.168.72.254
Eth0 Ethernet interface are configured with static IP address.
Exclude eth0 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=eth[1-9]
[Network]
DHCP=ipv4
3.5. DHCP Server configuration
DHCP server example:
[Match]
Name=eth0
[Network]
Address=192.168.72.1/24
DHCPServer=yes
IPForward=ipv4
IPMasquerade=yes
4. References