I have a server that will either connect to one of two wireless SSIDs. On the first, I need a static IP and on the second, I need a DHCP IP. I know that I can set both a static IP and DHCP to true on the same interface and it works, but the default route always ends up being for the static IP so outbound connections always fail when connected to the DHCP network.
Is there something I am missing here? Is there a way to configure at the access point level whether to have a static IP or a DHCP IP so that the default route gets set correctly?
Below is my current Netplan wifis config:
wifis:
wlan0:
optional: true
dhcp-identifier: mac
dhcp4: yes
addresses: [10.86.180.86/23]
gateway4: 10.86.180.1
access-points:
DHCPNet:
password: "YYYYYYYYYYY"
StaticNet:
password: "XXXXXXXXXXX"
And the output from ip:
user@testsystem:~$ ip address show wlan0
2: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 8c:c6:81:31:74:64 brd ff:ff:ff:ff:ff:ff
altname wlo1
altname wlp0s20f3
inet 10.86.180.86/23 brd 10.86.181.255 scope global wlan0
valid_lft forever preferred_lft forever
inet 10.1.1.106/24 brd 10.1.1.255 scope global dynamic wlan0
valid_lft 7195sec preferred_lft 7195sec
also lshw -C network:
user@testsystem:~$ sudo lshw -C network
*-network
description: Wireless interface
product: Cannon Point-LP CNVi [Wireless-AC]
vendor: Intel Corporation
physical id: 14.3
bus info: pci@0000:00:14.3
logical name: wlan0
version: 30
serial: 8c:c6:81:31:74:64
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress msix bus_master cap_list ethernet physical wireless
configuration: broadcast=yes driver=iwlwifi driverversion=5.11.0-38-generic firmware=46.4d093a30.0 9000-pu-b0-jf-b0- ip=10.1.1.106 latency=0 link=yes multicast=yes wireless=IEEE 802.11
resources: irq:16 memory:dc31c000-dc31ffff
*-network:0 DISABLED
description: Ethernet interface
physical id: 2
bus info: usb@2:4
logical name: wwan0
serial: 0e:fc:a6:f7:e9:32
capabilities: ethernet physical
configuration: broadcast=yes driver=cdc_mbim driverversion=5.11.0-38-generic firmware=CDC MBIM link=no multicast=yes
*-network:1
description: Ethernet interface
physical id: 3
bus info: usb@4:1
logical name: eth0
serial: 8c:ae:4c:e9:61:13
size: 1Gbit/s
capacity: 1Gbit/s
capabilities: ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=ax88179_178a driverversion=5.11.0-38-generic duplex=full ip=10.1.1.107 link=yes multicast=yes port=MII speed=1Gbit/s