How to set a fallback static address with DHCP in Win10 Pro?

Pavel A 431 Reputation points
2023-05-31T08:20:02.7866667+00:00

Dear experts,

I've been away from Windows for some time and likely forgetting things...

I want to add a static IPv4 address to a network interface so that it will be a fallback address when DHCP is not available. It should work this way:

  • When plugged to a network with DHCP ("internet") it should get the address from dhcp as usual.
  • When plugged to another network without DHCP (private network) it should use the set static address.

So I've added the User configured IP in the "alternate configuration" tab of IPv4 protocol AND "obtain IP address automatically" on the General tab.

But when plugged to the network without DHCP, it sets an APIPA address, no matter what.

Of course, when I set the static address on the General tab or via nets, it works.

The Bing AI uttered that Win10 assigns only APIPA address in this scenario, is this right?

Is there a way to achieve what I need, either via netsh or powershell or GUI?

Cannot add a second netcard for the private net, even an USB one (don't ask why...)

Windows 10 Network
Windows 10 Network
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Network: A group of devices that communicate either wirelessly or via a physical connection.
2,309 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,096 Reputation points
    2023-06-02T11:55:08.59+00:00

    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.