Open main menu

DAVE Developer's Wiki β

Changes

How to configure the network interfaces

50 bytes removed, 09:51, 15 February 2023
no edit summary
{{InfoBoxTop}}{{AppliesToAxel}}{{AppliesToAxelLite}}{{AppliesToAxelEsatta}}{{Applies To Bora}}{{Applies To BoraX}}{{Applies To BoraLite}}{{Applies To Diva}}{{InfoBoxBottom}}== How to configure the network interfaces ==
For deploying an Embedded System, one of the most important configuration is the ''Network Interface configuration''.
== Introduction == One of the most used configuration is the ''Network Interface configuration''.  Once the Embedded Device is finally configured for stand-alone bootstrap, the network interface has to should be automatically configured for reaching the device remotely via network connections like ssh, telnet, ftp, htpphttp, etc.
This Application Note briefly describes how it is possible to simply configure the network interfaces on [https://en.wikipedia.org/wiki/UNIX_System_V SystemV] (aka ''SysV'') or [https://www.freedesktop.org/wiki/Software/systemd/ systemd]
=== Resources ===
For further details on network configuration, please refer - for example - to:
* [https://www.freedesktop.org/software/systemd/man/systemd.network.html systemd network configuration]
=== Examples===
The following configuration assumptions are used in the paragraphs shown below:
* IP address range of the LAN network '''192.168.1.0 - 192.168.1.255'''
* IP address of the gateway '''192.168.1.254'''
* IP address of the PC device '''192.168.1.100'''
== SysV = systemd ===
The network configuration files for SysV can be systemd are basically found in pre-defined directorys as written [https:the <code>/etc/en.wikibooks.orgsystemd/wikinetwork/Linux_Networking</Where_should_I_put_the_configuration_commands%3F here]code> directory.
Basically, The most simply way for configuring the network configuration, it should be enough interface is to properly configure create/edit the <code>file '''/etc/systemd/network/interfaces<20-eth0.network''' as per the following paragraphs. In the event that there are another network interface, then this must be create/edit as '''/etc/code> filesystemd/network/20-eth1.network'''.For more example and usage hints on systemd, please refer to our [[XELK-AN-008:_How_to_use_systemd_on_an_Embedded_system#Configuring_the_network_interfaces | wiki]] page.
Here below an example of configuration file: ==== Static IP address ====The SBC ORCA has two network interface interfaces, below is configured with shown how to configure them both through a static IP address by creating . In the configuration entry in the '''/etc/network/interfaces''' file as the following:case of SBCX MINI there is only one ethernet interface, consequently going to configure only eth0 interface.
Example for ethernet interface 0.
<pre>
iface [Match]Name=eth0 inet static address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.254</pre>
# Prevent the interface loading if the kernel boots from nfsKernelCommandLine=== Dynamic IP addres (DHCP) ===!nfsroot
The network interface is configured - using a proper DHCP server on the network - by creating the configuration entry in the '''/etc/network/interfaces''' file as the following:[Network]Address=192.168.1.100<pre>Gateway=192.168.1.254allow-hotplug eth0iface eth0 inet dhcpDNS=192.168.1.1
</pre>
When the Linux kernel detects the physical Example for ethernet interface eth0, the iface causes ''ifup'' to use DHCP to configure the interface. === DNS === If the <code>resolvconf</code> package is not installed, the DNS configuration can be done manually by editing the '''/etc/resolv1.conf''' as the following: 
<pre>
nameserver 192.168.1.1[Match]</pre>Name=eth1
For example, it can be done on # Prevent the command line echoing interface loading if the string in this way:kernel boots from nfsKernelCommandLine=!nfsroot
root@axel-lite:~# echo "nameserver [Network]Address=192.168.1.101Gateway=192.168.1" > /etc/resolv.conf254DNS=== loopback network interface === The following configuration entry in the '''/etc/network/interfaces''' file brings up the loopback network interface lo upon booting the system192.168.1.<pre>auto loiface lo inet loopback1
</pre>
This one always exists in Once modified, the ''<code>networkd</etc/network/interfaces'' file.code> service should be resarted:
== systemctl restart systemd ==-networkd
The network configuration for systemd are basically found in the <code>/etc/systemd/network/</code> directory.==== Dynamic IP addres (DHCP) ====
The most simply way for configuring the SBC ORCA has two network interface interfaces, below is shown how to create/edit configure them both through DHCP. In the file '''/etc/systemd/network/case of SBCX MINI there is only one ethernet interface, consequently going to configure only eth0.network''' as per the following paragraphsinterface.
For more example and usage hints The network interface is configured - using a proper DHCP server on systemd, please refer to our [[XELK-ANthe network -008by using the '''DHCP''' key in the configuration file as the following:_How_to_use_systemd_on_an_Embedded_system#Configuring_the_network_interfaces | wiki]] page. === Static IP address ===
<pre>
[Network]
AddressDHCP=192.168.1.100Gateway=192.168.1.254DNS=192.168.1.1yes
</pre>
=== Dynamic IP addres (DHCP) === The In the event that there are another network interface is configured - using a proper DHCP server on the network - by using the '''DHCP''' key in , the configuration file as the following:
<pre>
[Match]
Name=eth0eth1
# Prevent the interface loading if the kernel boots from nfs
When systemd network starts, it tries to use a DHCP server present in the network to configure the interface.
==== DNS ====
The DNS key (in the configuration file) is used only if the '''ystemdsystemd-resolved service''' is enabled and the ''/etc/resolv.conf'' has a symbolic link to ''/run/systemd/resolve/stub-resolv.conf''
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
 
Once modified, the <code>resolved</code> service should be resarted:
 
systemctl restart systemd-resolved
 
==== loopback network interface ====
systemd contains native implementations of various tasks that need to be executed as part of the boot process.
 
For example, it sets the hostname or configures the loopback network device.
 
==== Apply configuration changes ====
After editing the above files, changes are applied after reboot or by restarting <code>systemd-networkd.service</code>:<syntaxhighlight lang="bash">
root@desk-mx8mp:~# systemctl restart systemd-networkd.service
</syntaxhighlight>
dave_user
404
edits