Hello Pavel,
Thank you for your question and for reaching out with your question today.
You can solve this by creating two connection profiles.
A DHCP config with high priority that tries for some time and a static config with lower priority that connects if DHCP fails.
In config files (e.g. /etc/NetworkManager/system-connections/*.nmconnection) :
The DHCP profile
[connection]
id=dhcp
uuid=<an UUID>
type=ethernet
interface-name=eth0
autoconnect-priority=1
autoconnect-retries=2
[ipv4]
dns-search=
method=auto
dhcp-timeout=10
may-fail=false
The static profile
[connection]
id=static
uuid=<an UUID>
type=ethernet
interface-name=eth0
autoconnect-priority=0
autoconnect-retries=-1
[ipv4]
address1=192.168.1.10/24,192.168.1.1
dns=192.168.1.1
dns-search=
method=manual
If the reply was helpful, please don’t forget to upvote or accept as answer.
Best regards.