Re: [systemd-devel] networkd: Link local static IP address behind NAT

2023-01-24 Thread Thomas Burghout
Thank you Mike and Andrei.
Having the dedicated address section with Scope=global solved our issue. We 
did investigate the Scope option, but did not realize it was both available in 
the Route and Address section.

Thanks again.

Re: [systemd-devel] networkd: Link local static IP address behind NAT

2023-01-19 Thread Andrei Borzenkov

On 18.01.2023 17:12, Thomas Burghout wrote:

On 18.01.20233 04:06, Andrei Borzenkov wrote:

On 17.01.2023 18:28, Thomas Burghout wrote:

  inet 169.254.146.171/16 brd 169.254.255.255 scope link eth0


Is it output from the correct system? Because address is different. I do
not see how "ping -I 169.254.1.2" can work with this.


That is unfortunate, I copied the wrong notes indeed. Apologies. The
following output should completely describe the configuration of the
system:


$ cat /usr/lib/systemd/network/10-lan.network
[Match]
Name=eth0

[Network]
Address=169.254.1.2/16
DNS=169.254.1.1
Gateway=169.254.1.1
$ ip route
default via 169.254.1.1 dev eth0
169.254.0.0/16 dev eth0 scope link  src 169.254.1.2
$ ip address
1: lo:  mtu 65536 qdisc noqueue qlen 1000
 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
 inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
 inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc mq qlen 1000
 link/ether e2:26:9e:11:ae:da brd ff:ff:ff:ff:ff:ff
 inet 169.254.1.2/16 brd 169.254.255.255 scope link eth0
valid_lft forever preferred_lft forever
 inet6 fe80::e026:9eff:fe11:aeda/64 scope link
valid_lft forever preferred_lft forever
3: usb0:  mtu 1500 qdisc noop qlen 1000
 link/ether b6:c8:ab:ac:44:7f brd ff:ff:ff:ff:ff:ff
4: sit0@NONE:  mtu 1480 qdisc noop qlen 1000
 link/sit 0.0.0.0 brd 0.0.0.0
$ ip route get 8.8.8.8
8.8.8.8 via 169.254.1.1 dev eth0
$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
^C
--- 8.8.8.8 ping statistics ---
9 packets transmitted, 0 packets received, 100% packet loss
$ ping -I 169.254.1.2 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 169.254.1.2: 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=116 time=12.576 ms
64 bytes from 8.8.8.8: seq=1 ttl=116 time=8.341 ms
64 bytes from 8.8.8.8: seq=2 ttl=116 time=9.124 ms
^C
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 8.341/10.013/12.576 ms


The commands I included for "interactive" were also wrong. The
following commands produce a working configuration:


ip address flush dev eth0
ip route flush dev eth0
ip address add 169.254.1.2/16 brd + dev eth0


This adds address with global scope.


ip route add 169.254.1.1 dev eth0
ip route add default via 169.254.1.1 dev eth0


Most notably, ip route now includes the following line as well:
169.254.1.1 dev eth0 scope link



This is red herring. What happens - kernel needs to set source address 
when you did not specify any. Because route to 8.8.8.8 has global scope 
and the only available address has link scope, this address is ignored 
and so no packet can be sent.


When you explicitly set source address with -I option kernel simply is 
using it.


If you do

ip address add 169.254.1.2/16 brd + dev eth0 scope link

you will observe exactly the same behavior.


Adding an extra [Route] section with this address does not fix the
networkd configuration file.


Of course not. But using

[Address]
Address=169.254.1.2/16
Scope=global

does, although I am not sure about possible implications.


Re: [systemd-devel] networkd: Link local static IP address behind NAT

2023-01-19 Thread Mike Gilbert
On Wed, Jan 18, 2023 at 9:12 AM Thomas Burghout
 wrote:
>
> On 18.01.20233 04:06, Andrei Borzenkov wrote:
> > On 17.01.2023 18:28, Thomas Burghout wrote:
> > >  inet 169.254.146.171/16 brd 169.254.255.255 scope link eth0
> >
> > Is it output from the correct system? Because address is different. I do
> > not see how "ping -I 169.254.1.2" can work with this.
>
> That is unfortunate, I copied the wrong notes indeed. Apologies. The
> following output should completely describe the configuration of the
> system:
>
>
> $ cat /usr/lib/systemd/network/10-lan.network
> [Match]
> Name=eth0
>
> [Network]
> Address=169.254.1.2/16
> DNS=169.254.1.1
> Gateway=169.254.1.1

Maybe move Address=169.254.1.2/16 to an Address section with
Scope=global. For example:

[Address]
Address=169.254.1.2/16
Scope=global


[systemd-devel] networkd: Link local static IP address behind NAT

2023-01-18 Thread Thomas Burghout
On 18.01.20233 04:06, Andrei Borzenkov wrote:
> On 17.01.2023 18:28, Thomas Burghout wrote:
> >  inet 169.254.146.171/16 brd 169.254.255.255 scope link eth0
>
> Is it output from the correct system? Because address is different. I do
> not see how "ping -I 169.254.1.2" can work with this.

That is unfortunate, I copied the wrong notes indeed. Apologies. The 
following output should completely describe the configuration of the 
system:


$ cat /usr/lib/systemd/network/10-lan.network 
[Match]
Name=eth0

[Network]
Address=169.254.1.2/16
DNS=169.254.1.1
Gateway=169.254.1.1
$ ip route
default via 169.254.1.1 dev eth0 
169.254.0.0/16 dev eth0 scope link  src 169.254.1.2 
$ ip address 
1: lo:  mtu 65536 qdisc noqueue qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host 
   valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc mq qlen 1000
link/ether e2:26:9e:11:ae:da brd ff:ff:ff:ff:ff:ff
inet 169.254.1.2/16 brd 169.254.255.255 scope link eth0
   valid_lft forever preferred_lft forever
inet6 fe80::e026:9eff:fe11:aeda/64 scope link 
   valid_lft forever preferred_lft forever
3: usb0:  mtu 1500 qdisc noop qlen 1000
link/ether b6:c8:ab:ac:44:7f brd ff:ff:ff:ff:ff:ff
4: sit0@NONE:  mtu 1480 qdisc noop qlen 1000
link/sit 0.0.0.0 brd 0.0.0.0
$ ip route get 8.8.8.8
8.8.8.8 via 169.254.1.1 dev eth0 
$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
^C
--- 8.8.8.8 ping statistics ---
9 packets transmitted, 0 packets received, 100% packet loss
$ ping -I 169.254.1.2 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 169.254.1.2: 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=116 time=12.576 ms
64 bytes from 8.8.8.8: seq=1 ttl=116 time=8.341 ms
64 bytes from 8.8.8.8: seq=2 ttl=116 time=9.124 ms
^C
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 8.341/10.013/12.576 ms


The commands I included for "interactive" were also wrong. The 
following commands produce a working configuration:


ip address flush dev eth0
ip route flush dev eth0
ip address add 169.254.1.2/16 brd + dev eth0
ip route add 169.254.1.1 dev eth0
ip route add default via 169.254.1.1 dev eth0


Most notably, ip route now includes the following line as well:
169.254.1.1 dev eth0 scope link

Adding an extra [Route] section with this address does not fix the 
networkd configuration file.


Re: [systemd-devel] networkd: Link local static IP address behind NAT

2023-01-17 Thread Andrei Borzenkov

On 17.01.2023 18:28, Thomas Burghout wrote:

Hello,

We are trying to configure a device to use a gateway and a static IP address
(in the link-local address range). However, the default gateway does not appear
to be used. As such, there is no traffic possible to the internet.

The device runs systemd 251.4 on a custom Yocto distribution with
Linux 5.4.124-altera.

The following network is used:

[Match]
Name=eth0

[Network]
Address=169.254.1.2/16
DNS=169.254.1.1
Gateway=169.254.1.1

With this configuration ping 8.8.8.8 does not work. However, if we specify the
interface like so:

ping -I 169.254.1.2 8.8.8.8

We are able to reach it successfully. We verified that the gateway is indeed
reachable.

See also the following relevant output:

$ ip route
default via 169.254.1.1 dev eth0
169.254.0.0/16 dev eth0 scope link  src 169.254.146.171  metric 2048
$ ip address
1: lo:  mtu 65536 qdisc noqueue qlen 1000
 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
 inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
 inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc mq qlen 1000
 link/ether e2:26:9e:11:ae:da brd ff:ff:ff:ff:ff:ff
 inet 169.254.146.171/16 brd 169.254.255.255 scope link eth0


Is it output from the correct system? Because address is different. I do 
not see how "ping -I 169.254.1.2" can work with this.



valid_lft forever preferred_lft forever
3: usb0:  mtu 1500 qdisc noop qlen 1000
 link/ether b6:c8:ab:ac:44:7f brd ff:ff:ff:ff:ff:ff
4: sit0@NONE:  mtu 1480 qdisc noop qlen 1000
 link/sit 0.0.0.0 brd 0.0.0.0
$ ip route get 8.8.8.8
8.8.8.8 via 169.254.1.1 dev eth0

The route seems to be configured correctly. The scope appears to be link,
we would expect global as this is consistent with other configurations. The
output of ip route get shows no src address.

If the interface is configured in an interactive manner we get the expected
behavior. The device is able to use the gateway by default.

$ ip address flush dev eth0
$ ip route flush dev eth0
$ ip address add 169.254.1.2/16 brd + dev eth0
$ ip route add 169.254.1.1 dev eth0
$ ip route add default via 169.168.1.1 dev eth0

Which produces a route which includes a src address and produces the address
with scope global.

networkd does not show any warnings or errors in the log. Is there a
configuration option we are missing?


With kind regards,
Thomas Burghout




[systemd-devel] networkd: Link local static IP address behind NAT

2023-01-17 Thread Thomas Burghout
Hello,

We are trying to configure a device to use a gateway and a static IP address 
(in the link-local address range). However, the default gateway does not appear
to be used. As such, there is no traffic possible to the internet.

The device runs systemd 251.4 on a custom Yocto distribution with 
Linux 5.4.124-altera.

The following network is used:

[Match]
Name=eth0

[Network]
Address=169.254.1.2/16
DNS=169.254.1.1
Gateway=169.254.1.1

With this configuration ping 8.8.8.8 does not work. However, if we specify the 
interface like so:

ping -I 169.254.1.2 8.8.8.8

We are able to reach it successfully. We verified that the gateway is indeed 
reachable. 

See also the following relevant output:

$ ip route
default via 169.254.1.1 dev eth0 
169.254.0.0/16 dev eth0 scope link  src 169.254.146.171  metric 2048 
$ ip address
1: lo:  mtu 65536 qdisc noqueue qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host 
   valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc mq qlen 1000
link/ether e2:26:9e:11:ae:da brd ff:ff:ff:ff:ff:ff
inet 169.254.146.171/16 brd 169.254.255.255 scope link eth0
   valid_lft forever preferred_lft forever
3: usb0:  mtu 1500 qdisc noop qlen 1000
link/ether b6:c8:ab:ac:44:7f brd ff:ff:ff:ff:ff:ff
4: sit0@NONE:  mtu 1480 qdisc noop qlen 1000
link/sit 0.0.0.0 brd 0.0.0.0
$ ip route get 8.8.8.8
8.8.8.8 via 169.254.1.1 dev eth0

The route seems to be configured correctly. The scope appears to be link,
we would expect global as this is consistent with other configurations. The 
output of ip route get shows no src address.

If the interface is configured in an interactive manner we get the expected 
behavior. The device is able to use the gateway by default.

$ ip address flush dev eth0
$ ip route flush dev eth0
$ ip address add 169.254.1.2/16 brd + dev eth0
$ ip route add 169.254.1.1 dev eth0
$ ip route add default via 169.168.1.1 dev eth0

Which produces a route which includes a src address and produces the address
with scope global.

networkd does not show any warnings or errors in the log. Is there a 
configuration option we are missing?


With kind regards,
Thomas Burghout