Windows VMs with SNAT and DHCP recognizing new networks on each reboot

Urxus

New Member
Feb 29, 2024
2
2
3
I'm encountering an issue with my Windows guests. After every reboot, they report connecting to a new network. I suspect this happens because the MAC address of the gateway changes with each restart.

I followed the guide on the Proxmox wiki for creating a simple zone with SNAT and DHCP https://pve.proxmox.com/wiki/Setup_Simple_Zone_With_SNAT_and_DHCP:
  • I've set up a simple zone under SDN, with IPAM set to pve
  • I've created a vnet and a subnet
  • I'm unable to find a way to set a static MAC address for the gateway, either through the GUI or CLI
  • I've tried adding the line hwaddress ether 00:11:22:33:44:55 to /etc/network/interfaces.d/sdn but to no avail
Is there a way to solve this issue within a simple zone, or should I consider different types of zones?
Thanks in advance for your help.
 
  • Like
Reactions: _gabriel
Thank you,
I tried again adding hwaddress ether 00:11:22:33:44:55 to /etc/network/interfaces.d/sdn. This time it worked as expected.
I may have overlooked something in my first attempt.
 
  • Like
Reactions: _gabriel
i added some MAC to /etc/network/interfaces.d/sdn
iface vnetXX
...
hwaddress ether 00:11:22:33:44:55

it works good even after ProxMox reboot.
But after pressing button Datacenter-SDN-APLAY or executing "pvesh set /cluster/sdn" the file /etc/network/interfaces.d/sdn is overided.
So, still looking for stable solution...
 
Add it to /etc/network/interfaces instead, ifupdown2 will automatically merge it.
 
i placed following strings into /etc/network/interfaces

auto vnet01
c
address 10.20.1.1/24
post-up iptables -t nat -A POSTROUTING -s '10.20.1.1/24' -o vmbr0 -j SNAT --to-source 192.168.11.71
post-down iptables -t nat -D POSTROUTING -s '10.20.1.1/24' -o vmbr0 -j SNAT --to-source 192.168.11.71
post-up iptables -t raw -I PREROUTING -i fwbr+ -j CT --zone 1
post-down iptables -t raw -D PREROUTING -i fwbr+ -j CT --zone 1
bridge_ports none
bridge_stp off
bridge_fd 0
ip-forward on
hwaddress 02:11:22:33:44:01

after pressing button Datacenter->SDN->APLAY ProxMox creates /etc/network/interfaces.d/sdn and duplicates iface vnet01 settings without hwaddress 02:11:22:33:44:01
 
I pinned MAC with own small service.
Now MAC fixes value even after reboot.
P.S. The best way to have MAC field in Datacenter-SDN-VNets-VNet from next ProxMpx versions.

/etc/systemd/system/fix-vnet01-mac.service
[Unit]
Description=Fix MAC address for vnet01
After=network-online.target pvedaemon.service

[Service]
Type=oneshot
ExecStart=/sbin/ip link set dev vnet01 address 02:01:02:03:04:00
ExecStart=/sbin/ip link set dev vnet01 up

[Install]
WantedBy=multi-user.target


than start service on boot.
systemctl daemon-reload
systemctl enable fix-vnet01-mac.service
 
Last edited:
other way to pin vlan interface for Windows VMs .

/etc/network/if-up.d/my_sdn
#! /bin/sh

if [ "$IFACE" = "vnet01" ]; then
ip link set dev "$IFACE" address 02:01:02:03:04:00
fi
chmod +x /etc/network/if-up.d/my_sdn
 
Last edited: