TS-4900 Network configuration example: Difference between revisions

From embeddedTS Manuals
No edit summary
(Update for Zeus networking)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
Our default yocto image uses systemd which stores its network files in "/etc/systemd/network/". The simplest network config for a DHCP configuration would look like this:
Our Yocto image uses systemd which stores its network files in <source lang=bash inline>/etc/systemd/network/</source>. Yocto will automatically enable DHCP on its wired interfaces. This can be overridden to set a static IP or enable other options for DHCP. The only requirement is that this file is named <source lang=bash inline>/etc/systemd/network/XX-wired.network</source> Where "XX" is a number smaller than 80, e.g. <source lang=bash inline>/etc/systemd/network/79-wired.network</source> This format must be used for all <source lang=bash inline>eth*</source> and <source lang=bash inline>en*</source> named network interfaces. The lower file names will take priority.


In /etc/systemd/network/eth.network
An example of a static configuration would be:
<source lang=ini>
[Match]
Name=eth*


[Network]
/etc/systemd/network/42-wired.network
DHCP=yes
</source>
 
For a static configuration you would instead create a config file for that specific interface.
/etc/systemd/network/eth0.network
<source lang=ini>
<source lang=ini>
[Match]
[Match]
Line 20: Line 12:
Gateway=192.168.0.1
Gateway=192.168.0.1
DNS=192.168.0.1
DNS=192.168.0.1
</source>
DNS will be loaded from /etc/resolv.conf.  To make this use a static DNS:
<source lang=bash>
rm /etc/resolv.conf
echo "nameserver 8.8.8.8" > /etc/resolv.conf
echo "nameserver 8.8.4.4" >> /etc/resolv.conf
</source>
To use the DNS assigned by DHCP, run:
<source lang=bash>
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
</source>
</source>


For more information on what options are available to configure the network, see the [http://www.freedesktop.org/software/systemd/man/systemd.network.html systemd network documentation].
For more information on what options are available to configure the network, see the [http://www.freedesktop.org/software/systemd/man/systemd.network.html systemd network documentation].

Latest revision as of 17:55, 20 March 2020

Our Yocto image uses systemd which stores its network files in /etc/systemd/network/. Yocto will automatically enable DHCP on its wired interfaces. This can be overridden to set a static IP or enable other options for DHCP. The only requirement is that this file is named /etc/systemd/network/XX-wired.network Where "XX" is a number smaller than 80, e.g. /etc/systemd/network/79-wired.network This format must be used for all eth* and en* named network interfaces. The lower file names will take priority.

An example of a static configuration would be:

/etc/systemd/network/42-wired.network

[Match]
Name=eth0

[Network]
Address=192.168.0.50/24
Gateway=192.168.0.1
DNS=192.168.0.1

DNS will be loaded from /etc/resolv.conf. To make this use a static DNS:

rm /etc/resolv.conf
echo "nameserver 8.8.8.8" > /etc/resolv.conf
echo "nameserver 8.8.4.4" >> /etc/resolv.conf

To use the DNS assigned by DHCP, run:

ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

For more information on what options are available to configure the network, see the systemd network documentation.