Re: Link-local with fixed IP



On Fri, 2021-09-24 at 07:07 +0000, moonkid--- via networkmanager-list
wrote:
Hello together,

is it possible to use a fixed (static?) IP on a network interface
when 
it is configured as "Link-local"?

Currently not.


Let me explain my problem first and the background (Why I want this) 
after.

I think it makes sense to combine IPv4 link local addressing together
with manual or DHCP(v4) methods. That should be added.

We are about to rework the IP handling of NetworkManager. That should
make it simpler to implement that feature.


I am on a RaspberryOS (Pi4 with two interfaces: LAN and WLAN). 
Network-Manager is not installed by default so I did it via "apt".
Via nmtui I setup the "eth0" with Link-local as you can see on the 
screenshot [1].

I tried to setup a fixed IP on "eth0" and used the dhcpd.conf for
that.

$ cat /etc/dhcpcd.conf
interface eth0
static ip_address=169.245.228.100
noipv6

You mean, you are using "[main].dhcp=dhcpcd" in NetworkManager.conf?
Yes, I guess this would work somewhat. But it totally bypasses
NetworkManager, and hacks an IP address there. This is not how it's
supposed to work and users should not be required to edit files in /etc
as root.


When I connect another PC (a Win10 Laptop) to "eth0" I can see in the
/var/log/syslog that this fixed IP is used at the first step. But
after 
it another random IP is setup. At the end the IP is not overridden
but 
"eth0" got two IPs. I was not aware that this is possible.

I don't know. You'd have to check dhcpcd documentation what "static"
means. In geneal, if you use [main].dhcp=dhcpcd", then NetworkManager
execs dhcpcd to do DHCP. If you then configure dhcpcd directly, then
some things will happen and that would be transparant to
NetworkManager.



2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP
group default qlen 1000
     link/ether e4:5f:01:5d:1c:b8 brd ff:ff:ff:ff:ff:ff
     inet 169.254.232.113/16 brd 169.254.255.255 scope link
noprefixroute 
eth0
        valid_lft forever preferred_lft forever
     inet 169.245.228.100/16 brd 169.245.255.255 scope global 
noprefixroute eth0
        valid_lft forever preferred_lft forever
     inet6 fe80::e65f:1ff:fe5d:1cb8/64 scope link
        valid_lft forever preferred_lft forever

But from the Win10 PC the Pi is reachable (SSH) only via the second 
(random) IP. What can I do to setup a fixed IP?

That's unclear. If you use IPv4LL addresses, then they are in subnet
169.245.0.0/16. If your Windows PC has multiple interfaces, then I
would check that 169.245.0.0/16 really gets routed the right way. When
you try to reach an link local address, then you usually have to
specify the interface which should be used (both with IPv4 and IPv6).



Now let me explain some background because you will ask why I need
this. 
;)
I am not very familiar with network things and also "Link-local" is 
totaly new for me. But in my understanding it is that what I need for
my 
use case without setting up an DHCP Server on the PI.
My use-case is that I want to connect (via "eth0") the Pi headless(!)
to 
a LAN Port of Windows 10 PC. There is no device (router, switch, ...)
between the Pi and the Win - only a LAN cable. There is absolutely
now 
way to do any network configurations on the Windows machine! It is
setup 
to listen on every DHCP by default. No way to change that!

But I found out that the Windows machine takes an IP address when the
"opposite machine" (the Pi on the other end of the LAN cable) is
setup 
to Link-local. This saves me from setup an DHCP server on the Pi -
which 
I tried but did not succeeded. I think a DHCP server would be
overhead 
because the Pi only connects to this one machine.

Why a fixed IP? As told the Pi is headless. When I connect the Win 
machine I do not know the IP of the Pi. There is no usual way to find
out the Pi's IP without doing any network scans. But I also have no 
monitor on the Pi to look into its log files or network status
appletts.
Btw: I know that in most situations a Pi is reachable via 
"raspberrypi.local" by default. This works here on my case. But I do
not 
want to trust on that. I would sleep better when I would have the
real 
IP. The "raspebbrypi.local" did not help me to get the IP behind it 
because when I ping it I just get a IPv6 look-a-like address back -
no 
IPv4. Even if there is a way to get the IPv4 IP behind 
"raspberrypi.local" from the Windows machine it would be a workaround
because I would have to do it on every connection. I would prefer a 
static/fixed always known IP.

Btw: As you can see there is also a IPv6 address on "eth0" but I
tried 
to deactivate IPv6 via "noipv6" in dhcpcd.conf; but it is ignored or 
overridden.

You could also run "ipv4.method=shared". Then NetworkManager will run a
DHCP server and the Windows-PC can just connect. Also the IP address in
NetworkManager is then well known (and configurable).




best,
Thomas



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