Windows 8.1 VM keeps changing my network to public.


Recommended Posts

I have a windows 8.1 VM installed and I have already manually changed my network from public to private in the past using the registry editor and it worked for a while.  Today my MySQL stopped working and I started to investigate and I found that my network has changed back to and unidentified public network.  How do I keep this from happening?

Link to comment

I have a windows 8.1 VM installed and I have already manually changed my network from public to private in the past using the registry editor and it worked for a while.  Today my MySQL stopped working and I started to investigate and I found that my network has changed back to and unidentified public network.  How do I keep this from happening?

 

How is the "network bridge" configured for your VM ?

Link to comment
  • 1 year later...

I know this is an old thread, but a Google search doesn't turn up any successful fixes for this issue and I figured others will come looking for a solution in the future. The problem is that Public/Private isn't really a setting on Windows 8.x and 10, its a condition. At startup Windows looks at all the networks visible to the system and uses an algorithm to decide if the network should be public or private. This means that even if you previously set the network to Private, Windows might decide it should be Public at the next boot. Reinstalling the NIC drivers will cause Windows to reassess the network type, and sometimes this or other changes or special configurations can fool Windows into constantly changing the network to Public every time it boots.

 

I have an especially unusual configuration on my main PC where I run a pfSense instance in a VM as my main LAN firewall. To implement this I have two gigabit NICs installed. One ONLY has VMware Bridge Protocol enabled and connects to the cable modem, making the  NIC visible to the VM (and pfSense) but not to the host. The other has all the usual protocols enabled, plus the VMware Bridge Protocol, making it visible to both the host and the VM. This second NIC has an IP of 192.168.1.1 from the VM and 192.1681.6 from the host and is connected to the LAN and WiFi AP. This configuration means that when the PC is booted, the network connection icon on the task bar doesn't show "Internet access" until the pfSense VM has fully started. This means that Windows can't decide whether the network should be Public or Private when it first starts so it defaults to Public, and doesn't always change back to Private when the firewall finishes starting up. It used to work fine for me but I changed my configuration a couple of weeks ago and ever since it fails every time to make my network connection Private when rebooted.

 

The good news is that there is a way on Windows 8.x and 10 to override Windows Public/Private algorithm and force the network to Private (or Public) after every reboot. The trick is to use Task Scheduler to execute a PowerShell command after system startup. First you need to find out the ID number of the network connection you want to control. To do this...

  1. Run "Windows PowerShell" from the start menu, search, or Cortana.
  2. In the PowerShell command window type "Get-NetConnectionProfile" and hit <Enter>.
  3. Make a note of the value for "InterfaceIndex" in the text returned by step 2.

Now that you have the interface index you can tell Task Scheduler to run a PowerShell command after every boot which will set that interface to Private...

  1. Run "Task Scheduler" from the start menu, search, or Cortana.
  2. If you don't already have one you want to use, right-click on "Task Scheduler Library" at the top-left and create a new folder, something like "Admin Tasks" for tasks requiring Admin rights to execute.
  3. In that new (or existing) folder, do a "Create Task..." (not a "Create Basic Task...")
  4. On the "General" tab, give the new task a name, something like "Set Network to Private".
  5. On the "General" tab, in the "Security options" box choose "Run whether user is logged on or not" and check "Run with the highest privileges". Leave "Do not store password" unchecked.
  6. If you would rather run this task as someone other than yourself set this with the "Change User or Group..." button. The user chosen should have Administrator privileges.
  7. Move to the "Triggers" tab and choose "New...".
  8. Set "Begin the task:" to "At startup" and leave everything else on that tab at the defaults. Click "Ok".
  9. Move to the "Actions" tab and choose "New...".
  10. Leave "Action:" set to "Start a program" and enter "PowerShell.exe" in the "Program/script:" field.
  11. In "Add arguments (optional): " enter "Set-NetConnectionProfile -InterfaceIndex <index> -NetworkCategory Private", replacing <index> with the interface index you made note of earlier.
  12. Hit "Ok" twice. After the second "Ok" you will be asked to enter the password of the user this new task will run as. Once you have entered it hit "Ok".
  13. The task properties editor will close and you should see your new task in the desired task folder.
  14. Reboot.

After logging in again you should see that the network connection is Private. Depending on the reason Windows keeps trying to set it to Public it may take up to a minute before the connection shows as Private so don't panic if it shows as Public at first.

 

Hope this is helpful, especially since this issue seems to be even more prevalent on Windows 10.

Link to comment
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.