Re: networkd: Link local static IP address behind NAT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> 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: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000
     link/ether b6:c8:ab:ac:44:7f brd ff:ff:ff:ff:ff:ff
4: sit0@NONE: <NOARP> 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.



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux