0

I am currently trying to simulate a network using network namespaces under Linux. I have already set up the nodes and connected them, and they can ping each other, one hop at a time. But I am really struggling trying to enable IP forwarding.

I am using Ubuntu Server 21.04 and networking on my system is controlled by systemd-networkd. systemd's version is 247.3-3ubuntu3.4. net.ipv6.conf.all.forwarding and net.ipv4.ip_forward are already enabled. Because networkd is used, forwarding has to be enabled in configuration files additionally. For one of my namespaces, this looks as follows:

/etc/systemd/network/router1i.network:

[Match]
Name=router1i

[Network]
IPForward=yes

and /etc/systemd/network/router1i2.network:

[Match]
Name=router1i2

[Network]
IPForward=yes

Those (router1i and router1i2) are both veth interfaces and the only 2 interfaces in the namespace.

If I use the command ip -6 route get to fe80::1:0:200 iif router1i2 in the namespace, I get the correct answer fe80::1:0:200 from :: dev router1i2 proto kernel metric 256 iif router1i2 pref medium, because the route doesn't involve forwarding. If I use the similar command ip -6 route get to fe80::1:0:200 iif router1i that starts from the other interface, the answer suddenly is RNETLINK answers: Network is unreachable. So apparently, forwarding isn't enabled.

I already tried to get networkd to update by using networkctl reconfigure router1i from within the namespace, but it says Failed to reconfigure network interface router1i: No such device or address. This is strange, because when I use networkctl status router1i, it lists all the information correctly. A full reload using networkctl reload was also already tried and doesn't change anything.

I'm out of ideas. I don't even necessarily need to get it to work with networkd. What can I try next?

halfer
  • 19,824
  • 17
  • 99
  • 186
ObiBabobi
  • 63
  • 4
  • I think you just have a route conflict. Do `ip -6 route show` and `ip -6 addr show`. Also where are the other side of the `veth` pairs for each? if `router1i2` is paired with `router1i1` then your traffic is looping back to the same namespace. – Liam Kelly Aug 02 '21 at 15:51
  • This question is already resolved. I also asked it on [unix.stackexchange.com](https://unix.stackexchange.com/questions/662859/ip-forwarding-in-linux-namespaces) – ObiBabobi Aug 03 '21 at 05:02

0 Answers0