Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 3980  / 2 Years ago, tue, september 20, 2022, 3:25:27

I have Ubuntu 20.04 configured as a router with nftables and frr (ospf configured) installed.
I have configured two interfaces (ens33 and ens34) in different networks,
forwarding is configured in /etc/sysctl.conf with net.ipv4.ip_forward=1 and also in
/etc/systemd/network/ens33.network


[Match]
Name=ens33

[Network]
IPForward=1

/etc/systemd/network/ens34.network


[Match]
Name=ens34

[Network]
IPForward=1

netplan file:


# This is the network config written by 'subiquity'
network:
version: 2
renderer: networkd
ethernets:
ens33:
mtu: 1300
addresses:
- 10.10.2.1/24
gateway4: 10.10.2.254
nameservers:
addresses:
- 10.10.3.1
search:
- management.int
ens34:
mtu: 1300
addresses:
- 10.10.20.254/24
nameservers: {}
bridges:
br0:
mtu: 1300
addresses:
- 10.10.3.22/32
nameservers: {}

After command "systemctl -p" everything goes fine but after reboot ip forward is disabled (output of: sysctl net.ipv4.ip_forward is: net.ipv4.ip_forward=0)


More From » 20.04

 Answers
6

When the netplan is generating the configuration, it will write a file for each interface to /run/systemd/network/ in a format: 10-netplan-{interface}.network. After that the systemd-networkd will apply the configuration.

systemd-networkd will find configuration files in /run/... and your config files in /etc/... and it will precess them in lexical order.

From www.freedesktop.org/.../systemd.network.html:



All configuration files are collectively sorted and processed in lexical order, regardless of the directories in which they live. However, files with identical filenames replace each other.




[Match] Section Options

The network file contains a [Match] section, which determines if a given network file may be applied to a given device; and a [Network] section specifying how the device should be configured. The first (in lexical order) of the network files that matches a given device is applied, all later files are ignored**, even if they match as well.



So now you can see that the IPForward option will never be applied.


Now you need to focus your troubleshooting on sysctl.conf


From www.freedesktop.org/.../sysctl.d.html:



Configuration Directories and Precedence

Configuration files are read from directories in /etc/, /run/, /usr/local/lib/, and /usr/lib/, in order of precedence, as listed in the SYNOPSIS section above. Files must have the ".conf" extension. Files in /etc/ override files with the same name in /run/, /usr/local/lib/, and /usr/lib/. Files in /run/ override files with the same name under /usr/.


All configuration files are sorted by their filename in lexicographic order, regardless of which of the directories they reside in. If multiple files specify the same option, the entry in the file with the lexicographically latest name will take precedence. Thus, the configuration in a certain file may either be replaced completely (by placing a file with the same name in a directory with higher priority), or individual settings might be changed (by specifying additional settings in a file with a different name that is ordered later).





EDIT:

It is possible that there are application which will override the sysctl.conf

For example ufw firewall configuration in /etc/ufw/sysctl.conf might have line such as net/ipv4/ip_forward=0 which would take precedence over /etc/sysctl.conf. It is not default configuration though, and it would have to be configured manually.


[#2219] Wednesday, September 21, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rieency

Total Points: 299
Total Questions: 116
Total Answers: 111

Location: Wales
Member since Tue, Dec 14, 2021
2 Years ago
rieency questions
Wed, Aug 25, 21, 15:17, 3 Years ago
Wed, Jun 23, 21, 04:37, 3 Years ago
Fri, Sep 30, 22, 12:07, 2 Years ago
Thu, Feb 24, 22, 00:50, 2 Years ago
Mon, Mar 28, 22, 13:28, 2 Years ago
;