Changes

Jump to: navigation, search

How to configure the network interfaces

4,222 bytes added, 11:44, 6 November 2019
Created page with "{{InfoBoxTop}} {{AppliesToAxel}} {{AppliesToAxelLite}} {{AppliesToAxelEsatta}} {{InfoBoxBottom}} == Introduction == One of the most used configuration is the Network Interf..."
{{InfoBoxTop}}
{{AppliesToAxel}}
{{AppliesToAxelLite}}
{{AppliesToAxelEsatta}}
{{InfoBoxBottom}}


== 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 be automatically configured for reaching the device remotely via netowrk connections like ssh, telnet, ftp, htpp, 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.debian.org/doc/manuals/debian-reference/ch05.en.html#_the_basic_network_configuration_with_ifupdown_legacy Debian - The basic network 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 '''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]

Basically, for network configuration, it should be enough to properly configure the <code>/etc/network/interfaces</code> file.

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>
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.254
</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:

<pre>
allow-hotplug eth0
iface eth0 inet dhcp
</pre>

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:

<pre>
nameserver 192.168.1.1
</pre>

For example, it can be done on the command line echoing the string in this way:

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 (via auto stanza).
<pre>
auto lo
iface lo inet loopback
</pre>

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.

The most simply way for configuring the network interface is to create/edit the file '''/etc/systemd/network/eth0.network''' as per te following paragraphs.

=== Static IP address ===

<pre>
[Match]
Name=eth0

# Prevent the interface loading if the kernel boots from nfs
KernelCommandLine=!nfsroot

[Network]
Address=192.168.1.100
Gateway=192.168.1.254
DNS=192.168.1.1
</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:

<pre>
[Match]
Name=eth0

# Prevent the interface loading if the kernel boots from nfs
KernelCommandLine=!nfsroot

[Network]
DHCP=yes
</pre>

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 systemd-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
8,154
edits

Navigation menu