Difference between pages "SocialEntity:7817" and "How to configure ethernet interface"

 
 

{

   "wikipageid": 1226,
   "revisionid": 69922,
   "namespace": 0,
   "titletext": "Dmesg and Linux kernel log",
   "action": "edit",
   "summary": "\u29fcbs-socialactionsmw-autoeditsummaray\u29fd",
   "parentid": 0,
   "id": 7817,
   "ownerid": 95,
   "type": "articlesave",
   "archived": false,
   "tags": [],
   "resolved": false

}


1 Purpose[edit]

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[edit]

  • 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 :

 Board $> ifconfig eth0 uuu.xxx.yyy.zzz

Warning.png 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 eth0 and the gateway are well configured, one can type:
 Board $>ifconfig
 Board $>route

In the console, a log similar to the one below should be displayed:
 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[edit]

Systemd-networkd is a network service provided by systemd.

3.1 Ethernet interface[edit]

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

3.2 Configuration file[edit]

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[edit]

DHCP configuration;


[Match]
Name=eth*

[Network]
DHCP=ipv4

All Ethernet interface are configured with DHCP client address.

3.4 STATIC configuration[edit]


Static configuration;


[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.

Info.png 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 eth0 interface of default configuration (here 50-wired.network)

Exclude eth0 from default Ethernet configuration:


[Match]
Name=eth[1-9]

[Network]
DHCP=ipv4

{{ReviewsComments|ECO:Show here the way to change the default config to static that is insided 52-static.network there is the command to update the config}

3.5 DHCP Server configuration[edit]

DHCP server example:


[Match]
Name=eth0

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



4 References[edit]


{
    "wikipageid": 1226,
    "revisionid": 69922,
    "namespace": 0,
    "titletext": "Dmesg and Linux kernel log",
    "action": "edit",
    "summary": "\u29fcbs-socialactionsmw-autoeditsummaray\u29fd",
    "parentid": 0,
    "id": 7817,
    "ownerid": 95,
    "type": "articlesave",
    "archived": false,
    "tags": [],
    "resolved": false
}<noinclude>

{{ClonedFrom | stm32mpu}}</noinclude>

== Purpose ==
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>

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 :
  {{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:
  {{Board$}}ifconfig
  {{Board$}}route
::In the console, a log similar to the one below should be displayed:
  {{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

== 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 ===
{{ReviewsComments|ECO:
Please give pratical  guideline to recconfigure default config. Indeed the content of 52-static.network .
# to enable static IP on eth0:                                                  
# $> cp 50-wired.network 50-wired.network.notused                               
# $> cp 50-wired.network.static 50-wired.network                                
# $> cp 52-static.network.static 52-static.network                              
# $> systemctl restart systemd-networkd.service       }} 

Static configuration;<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:<pre>

[Match]
Name=eth[1-9]

[Network]
DHCP=ipv4</pre>

{{ReviewsComments|ECO:Show here the way to change the default config to static that is insided 52-static.network there is the command to update the config}

=== 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 />

<noinclude>

[[Category:Ethernet]]
{{PublicationRequestId | 10180 | 2019-01-07 | BrunoB }}</noinclude>
Line 1: Line 1:
{
+
<noinclude>
    "wikipageid": 1226,
+
{{ClonedFrom | stm32mpu}}
    "revisionid": 69922,
+
</noinclude>
    "namespace": 0,
+
== Purpose ==
    "titletext": "Dmesg and Linux kernel log",
+
This article describes how to configure the Ethernet interface. <br/>
    "action": "edit",
+
This article provides two ways to make it:
     "summary": "\u29fcbs-socialactionsmw-autoeditsummaray\u29fd",
+
* via ifconfig: to put quickly and temporary the Ethernet interface with static IP address.
     "parentid": 0,
+
* via systemd: to change durably the Ethernet configuration with static IP address
    "id": 7817,
+
 
    "ownerid": 95,
+
== Using [[Ifconfig]] tools==
    "type": "articlesave",
+
 
    "archived": false,
+
* <big>'''''Connect an Ethernet cable and enjoy'''''</big>
    "tags": [],
+
At startup SSH daemon (sshd) and ifplugd daemon are automatically launched:
    "resolved": false
+
* 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 :
  +
  {{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:
  +
  {{Board$}}ifconfig
  +
  {{Board$}}route
  +
::In the console, a log similar to the one below should be displayed:
  +
  {{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
  +
 
  +
== 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 ===
  +
{{ReviewsComments|ECO:
  +
Please give pratical  guideline to recconfigure default config. Indeed the content of 52-static.network .
  +
# to enable static IP on eth0:                                                
  +
# $> cp 50-wired.network 50-wired.network.notused                             
  +
# $> cp 50-wired.network.static 50-wired.network                               
  +
# $> cp 52-static.network.static 52-static.network                             
  +
# $> systemctl restart systemd-networkd.service      }}
  +
 
  +
Static configuration;
  +
<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:
  +
<pre>
  +
[Match]
  +
Name=eth[1-9]
  +
 
  +
[Network]
  +
DHCP=ipv4
  +
</pre>
  +
{{ReviewsComments|ECO:Show here the way to change the default config to static that is insided 52-static.network there is the command to update the config}
  +
 
  +
=== 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 />
  +
 
  +
 
  +
<noinclude>
  +
[[Category:Ethernet]]
  +
{{PublicationRequestId | 10180 | 2019-01-07 | BrunoB }}
  +
</noinclude>