Changes

Jump to: navigation, search

How to configure the network interfaces

346 bytes added, 16:09, 14 July 2021
no edit summary
{{InfoBoxBottom}}
<section begin=Body/>
== Introduction How to configure the network interfaces ==
For deploying an Embedded System, one of the most important configuration is the ''Network Interface configuration''.
* [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 ===
The configuration files for SysV can be found in pre-defined directorys as written [https://en.wikibooks.org/wiki/Linux_Networking/Where_should_I_put_the_configuration_commands%3F here]
Here below an example of configuration file:
==== Static IP address ====
The network interface is configured with a static IP address by creating the configuration entry in the '''/etc/network/interfaces''' file as the following:
</pre>
==== Dynamic IP addres (DHCP) ====
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:
When the Linux kernel detects the physical 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/resolv.conf''' as the following:
root@axel-lite:~# echo "nameserver 192.168.1.1" > /etc/resolv.conf
==== loopback network interface ====
The following configuration entry in the '''/etc/network/interfaces''' file brings up the loopback network interface lo upon booting the system.
This one always exists in the ''/etc/network/interfaces'' file.
=== systemd ===
The network configuration for systemd are basically found in the <code>/etc/systemd/network/</code> directory.
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.
==== Static IP address ====
<pre>
</pre>
==== Dynamic IP addres (DHCP) ====
The network interface is configured - using a proper DHCP server on the network - by using the '''DHCP''' key in the configuration file as the following:
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
==== 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@imx6qdlxelk:~# systemctl restart systemd-networkd.service
</syntaxhighlight>
8,154
edits

Navigation menu