Windows Guest with NAT

adamb

Famous Member
Mar 1, 2012
1,329
77
113
I have a windows guest setup using NAT mode for networking. Everything works really well except for one thing. When I shutdown the VM, then start it back up, windows sees it as a new network every single time. I have to select yes to set it to private and the network takes a new name. At this point I am on Network 48. Does anyone know of a work around for this issue?
 
Hi,

you can turn off the network discovery in Windows.
 
Can you post your setup? I am not quite sure what you mean by that. :D

We are using iptables to masquerade the traffic into the wireless adapter. It works fantastic other than this issue we are seeing.

auto vmbr1
#private sub network
iface vmbr1 inet static
address 192.168.1.1
netmask 255.255.255.0
bridge_ports none
bridge_stp off
bridge_fd 0

post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '192.168.1.0/24' -o wlp2s0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '192.168.1.0/24' -o wlp2s0 -j MASQUERADE

This isn't a issue during a reboot, so it makes me wonder if it has to do with the tap adapter in the host. Maybe because the taps's mac address changes during a shutdown/start but doesn't during a reboot.

8: tap100i1: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master vmbr1 state UNKNOWN group default qlen 1000
link/ether a2:bd:bc:ca:1a:ea brd ff:ff:ff:ff:ff:ff
 
Ok now I know what you mean. Can you post you VM config? If I am right you use the NAT mode in your VM nic.
 
Ok now I know what you mean. Can you post you VM config? If I am right you use the NAT mode in your VM nic.

I just hand over vmbr1 to the windows guest and set a static IP in, but I don't enable "NAT" mode for the adapter.

args: -device vfio-pci,host=00:02.0,addr=0x18,x-vga=on,x-igd-opregion=on
balloon: 0
boot: cdn
bootdisk: virtio1
cores: 4
cpu: host
hostpci0: 00:14.0
hotplug: disk,network
memory: 6000
name: Test
net1: e1000=C2:71:77:61:8F:4E,bridge=vmbr1
numa: 0
onboot: 1
ostype: win10
scsihw: virtio-scsi-pci
smbios1: uuid=BA689FEE-560F-11E7-96CA-98EECB63D6AE,manufacturer=Acer,serial=DTVQ0AA006726014693000,sku=0000000000000000
sockets: 1
vga: qxl
virtio1: local-lvm:vm-100-disk-1,size=100G
 
Does anyone know if there is a way to specify the MAC address of the tap adapter? I have tracked the issue down to this mac address and because it changes on a power down and power up, it causes windows to see it as a new network.
 
Testing this out using the ip command to define the MAC address of the tap device and can confirm that is my issue.

If I set the MAC to the same mac as soon as the VM starts but before windows has a chance to load, all is well. Here is an example.

ip link set tap100i0 address 76:9d:d3:a4:3b:a6

I am really hoping there is a way to define this in the VM config file.
 
Took this a step further, added the "ip link set tap100i0 address 76:9d:d3:a4:3b:a6" to a quick bash script, then added the following to /var/lib/qemu-server/pve-bridge

system("/bin/bash /usr/local/bin/set_tap_mac");

This works, but I don't think it will survive updates. Really hoping a dev or someone else has a better idea.