Main | Exchange 2010 Install on Hyper-V fails with "exsetupui.exe cannot start" »
Thursday
Nov142013

Windows 2012 (RTM/R2) Set Network Location

Ref: http://blogs.msdn.com/b/powershell/archive/2009/04/03/setting-network-location-to-private.aspx

Ref: http://social.technet.microsoft.com/Forums/windowsserver/en-US/18437d06-237f-4170-8e82-2a9de67b0bd3/setting-network-locations-in-server-core-2008-r2?forum=winservercore

In my hyper-v lab I use Non-Domain bound Hosts with a wired and wireless network setup - I place wired in private and wireless in public.

This attribute is not a property of the adapter or interface. Adapter or interface can be connected to different networks, this is obvious for Wi-Fi but is also true for wired Ethernet (just plug the cable to the hotel room socket to experience this).

This attribute is a property of the "network signature", which is managed by the Network Location Awareness service. It identifies networks by things like the default gateway's MAC address and the DNS suffix provided by the DHCP server, creates a unique record for each such network and allows the user to set whether it is Public or Private. Then NLA pushes this setting down to the firewall.

Now the solutions

Powershell:

# Skip network location setting for pre-Vista operating systems
 if([environment]::OSVersion.version.Major -lt 6) { return }
 
# Skip network location setting if local machine is joined to a domain.
 if(1,3,4,5 -contains (Get-WmiObject win32_computersystem).DomainRole) { return }
 
# Get network connections
 $networkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}"))
 $connections = $networkListManager.GetNetworkConnections()
 
# Set network location to Private for all networks
 $connections | % {$_.GetNetwork().SetCategory(1)}

Using NetSH

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\Unmanaged

scan all subkeys here, and look at DefaultGatewayMac to find the proper one (Wi-Fi networks can have some other fields there, but I have some doubts in Wi-Fi on Server Core).

In the proper subkey, find ProfileGuid.

Then:

net stop nlasvc

(this also stops netprofm)

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles\{profile guid}

Category REG_DWORD 0 - public, 1 - private, edit this dword

net start netprofm

(this also starts nlasvc)

To check the tweak was actually applied:

netsh adv sh cur

(should be Public before, Private after)

 

PrintView Printer Friendly Version

EmailEmail Article to Friend

References (8)

References allow you to track sources for this article, as well as articles that were written in response to this article.
  • Response
    click here for the top copo camaro available
  • Response
    (Still) Heavy on the Technical - Journal - Windows 2012 (RTM/R2) Set Network Location
  • Response
    (Still) Heavy on the Technical - Journal - Windows 2012 (RTM/R2) Set Network Location
  • Response
    Response: xe oto audi
    (Still) Heavy on the Technical - Journal - Windows 2012 (RTM/R2) Set Network Location
  • Response
    (Still) Heavy on the Technical - Journal - Windows 2012 (RTM/R2) Set Network Location
  • Response
    (Still) Heavy on the Technical - Journal - Windows 2012 (RTM/R2) Set Network Location
  • Response
    (Still) Heavy on the Technical - Journal - Windows 2012 (RTM/R2) Set Network Location
  • Response
    Response: browse this site
    (Still) Heavy on the Technical - Journal - Windows 2012 (RTM/R2) Set Network Location

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>