Как изменить общедоступную сеть на частную в windows server 2016

При подключении к новой сети Windows предлагает вам выбрать ее тип (профиль или сетевое расположение): Public network (общедоступная) или Private (частная). Сетевые профили Windows являются частью Microsoft Defender Firewall и позволяют применять различные правила брандмауэра в зависимости от типа сети, к которой подключен компьютер. В зависимости от примененного профиля для вашего сетевого подключения, другие компьютеры могут видеть или не видеть ваш компьютер в сети (настройки сетевого обнаружения), использовать общие папки и сетевые принтеры.

В этой статье мы рассмотрим, как в Windows (и Windows Server) изменить назначенный профиль сети с “общедоступной” на “частную” и наоборот.

Содержание:

  • Типы (профили) сети в Windows
  • Как изменить профиль для сетевого подключения в Windows?
  • Изменить тип сети с Public на Private с помощью PowerShell
  • Изменить тип сети в реестре Windows
  • Сменить профиль сети через политику безопасности
  • Слетает доменный профиль сети на частную в Windows Server

Типы (профили) сети в Windows

Сетевому подключению в Windows (будь то Ethernet или Wi-Fi) можно назначить один из трех сетевых профилей.

  • Частная или домашняя сеть (Private) – профиль для доверенной сети (домашняя или рабочая сеть в офисе). В такой сети компьютер будет доступен для обнаружения другими устройствами, на нем можно использовать службы общего доступа к сетевым файлам и принтерам;
  • Общедоступная (общественная) сеть (Public / Guest) – профиль для недоверенной сети (кафе, публичная Wi-Fi сеть в метро, аэропорту). Вы не доверяете другим устройствам в такой сети, ваш компьютер будет скрыт для других устройств, нельзя получить удаленный доступ к опубликованным у вас сетевым папкам и принтерам;
  • Доменная сеть (Domain) – сетевой профиль для компьютеров, которые присоединены в домен Active Directory. Применяется автоматически после добавления Windows в домен. Для этого профиля вы можете применять доменные политики брандмауэра.

В зависимости от типа сети, к сетевому интерфейсу применяются разные правила брандмауэра Windows.

В Windows 10 и 11 вы можете увидеть текущий профиль, который назначен сетевому подключению, в меню Settings -> Network and Internet (команда быстрого доступа
ms-settings:network
). Сетевому интерфейсу Ethernet0 в моем примере назначен профиль Public.

просмотр назначенного типа сети в Windows

В классической панели управления Windows тип сети для активных сетевых подключений отображается здесь: Control Panel\All Control Panel Items\Network and Sharing Center.

профиль сети public в настройках панели управления windows 10

Профиль сети в Windows 10 выбирается пользователем при первом подключении к новой сети. Появляется запрос:

Network_name
Вы хотите разрешить другим компьютерам и устройствам в этой сети обнаруживать ваш ПК.
Рекомендуется делать это в домашней или рабочей сети, а не в общедоступных.

Если выбрать “Да”, сети присваивается профиль Private (домашняя), если “Нет” – public (общедоступная). При следующем подключении к этой же самой LAN или WiFi сети автоматически назначается выбранный ранее профиль.

Вы можете скрыть мастер подключения к новым сетям (Network Location wizard) в Windows. Для этого откройте редактор реестра и создайте раздел HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Network\NewNetworkWindowOff. После этого все новые сети при подключении будут определяться как общедоступные (Public).

reg add "HKLM\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff" /f

В Windows вы можете сбросить все настройки и профили для всех сохраненных сетей, выбрав Параметры -> Сеть и Интернет -> Состояние -> Сброс сети. Перезагрузите компьютер.

сброс сети Windows 10

Теперь при подключении к сети опять появится запрос о включении сетевого обнаружения.

Как изменить профиль для сетевого подключения в Windows?

Вы можете изменить тип сети в Windows из современной панели управления Параметры: перейдите в раздел «Сеть и Интернет» -> «Состояние» -> Откройте свойства вашего сетевого подключения.

Здесь можно переключить сетевой профиль с Public на Private и наоборот.

изменить общедоступную сеть на частную в Windows 10

В Windows Server 2022/2019 опция Properties отсутствует на вкладке Status. Поэтому нужно в секции Network and Internet выбрать раздел Ethernet (или раздел Wi-Fi если в Windows Server включена поддержка беспроводных сетей). Выберите ваше подключение к сети.

сменить тип сетевого подключения в windows server

В классической панели управления Windows отсутствуют настройки для смены типа профиля сетевого подключения.

Также вы не можете сменить профиль на компьютере в домене AD. Для сетевого подключения к домену всегда будет использоваться профиль Domain.

Изменить тип сети с Public на Private с помощью PowerShell

В Windows 10/11 и Windows Server 2022/2019/2016 вы можете управлять профилями сетевых подключений из PowerShell. Запустите консоль PowerShell с правами администратора.

Выведите список сетевых интерфейсов Windows и применённые к ним сетевых профилей:

Get-NetConnectionProfile

В моем примере на компьютере имеется 4 сетевых подключения, с разными типами сетей (NetworkCategory: Public, Private и DomainAuthenticated).

Get-NetConnectionProfile

Чтобы изменить профиль сети, нужно указать номер сетевого интерфейса, назначанный сетевому адаптеру (InterfaceIndex). В этом примере InterfaceIndex = 19.

Name : Неопознанная сеть
InterfaceAlias : Ethernet 3
InterfaceIndex : 19
NetworkCategory : Public
IPv4Connectivity : NoTraffic
IPv6Connectivity : NoTraffic

Чтобы изменить тип сети для сетевого интерфейса с индексом 19 на Private, выполните команду:

Set-NetConnectionProfile -InterfaceIndex 19 -NetworkCategory Private

Проверим, что профиль сети изменился:

Get-NetConnectionProfile -InterfaceIndex 19

Set-NetConnectionProfile изменить профиль сети с public на private в powershell

Windows Defender Firewall автоматически применит к сетевому подключению правила в соответствии с назначенным профилем без перезагрузки.

По аналогии вы можете изменить местоположение сети на Public:

Set-NetConnectionProfile -InterfaceIndex 19  -NetworkCategory Public

Или доменный:

Set-NetConnectionProfile -InterfaceIndex 19 -NetworkCategory DomainAuthenticated

Также вы можете изменить профиль сети сразу для всех сетевых адаптеров компьютера:

Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private

На компьютерах в домене вы не сможете изменить профиль сетевого подключения с доменного на частный или публичный. Проверьте, что ваш компьютер добавлен в домен AD:

Get-CimInstance -ClassName Win32_ComputerSystem).PartOfDomain

Попробуйте изменить сетевой профиль:

Set-NetConnectionProfile -InterfaceIndex 19  -NetworkCategory Public –Verbose

Появится ошибка:

Set-NetConnectionProfile : Unable to set the NetworkCategory due to one of the following possible reasons: not running PowerShell elevated; the NetworkCategory cannot be changed from 'DomainAuthenticated'; user initiated changes to NetworkCategory are being prevented due to the Group Policy setting 'Network List Manager Policies'.

Set-NetConnectionProfile - нельзя сменить тип для доменной сети

Изменить тип сети в реестре Windows

Вы можете изменить тип сети через редактора реестра. Для этого нужно запустить regedit.exe и перейти в раздел HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles, в котором хранятся профили всех сетевых подключений. Для каждого сетевого подключения здесь присутствует отдельная ветка реестра с именем в формате GUID {xxxxxxxx-xxxx-……..}).

Чтобы найти нужную вам сеть, нужно просмотреть все ветки реестра и найти раздел, в котором указано имя нужной вам сети из панели управления (или значение Name из команды Get-NetConnectionProfile). В нашем случае компьютер подключен к сети Network 4.

изменить тип сети в windows с public на private через реестр

Имя сети указано в строковом параметре реестра ProfileName. Тип сети задается в параметре Category. Доступны следующие значения этого ключа:

  • 0 — Общественная сеть (Public Network)
  • 1 — Частная сеть (Private Network)
  • 2 — Доменная сеть (Domain Network)

Чтобы изменить тип сети, просто вручную изменить значение параметра Category. Перезагрузить компьютер чтобы применить изменения.

Сменить профиль сети через политику безопасности

Еще один способ смены типа сети — редактор локальной политики безопасности (Local Security Policy).

Запустите оснастку secpol.msc и перейдите в раздел Network List Manager Policies (Политики диспетчера списка сетей). В списке сетей справа найдите сеть по ее имени в Центре управления сетями. Откройте свойства сети и перейдите на вкладку Network Location, измените тип сети на Private и сохраните изменения. Чтобы пользователи не могли сменить профиль сети, выберите дополнительно опцию “User cannot change location” (Пользователь не может изменить расположение).

Network List Manager Policies задать тип сети в windows 10 через политику безопасности

Примечание. Если сервер или компьютер включены в домен, изменить тип сети на другой нельзя, при перезагрузке тип все равно сменится на Domain Network.

Слетает доменный профиль сети на частную в Windows Server

В новых версиях Windows Server 2022/2019 периодически встречается глюк, когда на доменном сервере (или даже контроллере домена) тип сети сам меняется с доменной на частную после перезагрузки.

Для решения проблемы достаточно перезапустить службу Network Location Awareness (из консоли
services.msc
) или командой:

Get-Service NlaSvc| Restart-Service -Force
(запускать от имени SYSTEM)

Чтобы служба Network Location Awareness при загрузке компьютера загружалась немного позже, можно задать для нее отложенный тип запуска. Для этого в свойствах службы нужно выбрать опцию Automatic (Delayed Start).

служба Network Location Awareness используется для определения типа сети

Проверьте, что после перезагрузки тип сети в Windows Server всегда определяется как доменный (вместо private).

Если проблема возникает на контроллере домена Active Directory, нужно изменить зависимости службу NlaSvc, чтобы она запускалась после службы DNS Server:

sc config nlasvc depend=DNS

Также в некоторых случаях вам может помочь принудительное указание DNS суффикса вашего домена в настройках сетевого адаптера (сетевой адаптера -> TCP/IPv4 -> Advanced -> DNS, укажите имя вашего домена в поле DNS suffix for this connection и проверьте, что включена опция «Use this connection’s suffix in DNS registration».

задать DNS суффикс для сетевого подключения

How to change public network to private in windows server 2016. Windows server 2016 provides robust networking capabilities for managing and configuring network connections. By default, when you connect to a new network, Windows Server categorizes it as either a public or private network based on certain criteria. While public networks are typically used in untrusted environments such as airports or coffee shops, private networks are considered trusted networks such as home or office networks. In this blog post, we’ll provide a step-by-step guide on how to change a public network to a private network in Windows Server 2016, ensuring that your server is appropriately configured for your environment.

1: Access Network Settings

  1. Log in to your Windows Server 2016 system using administrative credentials.
  2. Open the Start menu and click on “Settings” (gear icon).
  3. In the Settings window, click on “Network & Internet.”

2: View Network Connections

  1. In the Network & Internet settings, click on the “Ethernet” or “Wi-Fi” option, depending on the type of network connection you want to configure.
  2. Scroll down and click on “Change adapter options.” This will open the Network Connections window.

3: Identify the Network Connection

  1. In the Network Connections window, you will looking a list of network adapters. Identify the network connection that you want to change from public to private.
  2. Right-click on the network connection and select “Properties” from the context menu.

4: Change Network Profile

  1. In the Properties window, locate the “Networking” tab.
  2. Scroll down and select “Internet Protocol Version 4 (TCP/IPv4)” from the list.
  3. Click on the “Properties” button below the list.

Step 5: Configure IP Address Settings

  1. In the IPv4 Properties window, ensure that the “Obtain an IP address automatically” & “Obtain DNS server address automatically” options are selected.
  2. Click on the “Advanced” button.

6: Set Network Location

  1. In the Advanced TCP/IP Settings window, go to the “IP Settings” tab.
  2. Under the “IP addresses” section, you’ll see a list of IP addresses assigned to the network adapter. If there are multiple IP addresses, ensure that the correct IP address is selected.
  3. Below the IP addresses section, you’ll see a “IP address assignment” dropdown menu. Select “Automatic private IP address.”
  4. Click on the “DNS” tab.
  5. Ensure that the “Append primary and connection specific DNS suffixes” and “Append parent suffixes of the primary DNS suffix” options selected.
  6. Click “OKAY” to save your changes & close all open windows.

7: Confirm Network Profile Change

  1. After configuring the network adapter settings, close the Network Connections window.
  2. Right-click on the network icon in the system tray (bottom-right corner of the screen) & select “Open Network and Sharing Center.”
  3. You should now see the network connection labeled as “Private network.” This indicates that the network profile successfully changed from public to private.

Conclusion:
Changing a public network to a private network in Windows Server 2016 is a straightforward process that done through the Network & Internet settings. By following the step-by-step guide outlined above, you ensure that your server configured with the appropriate network profile for your trusted environment. Whether you’re setting up a server in a home or office network, it’s essential to correctly configure the network settings to maintain security and connectivity. With the right configuration, you can optimize your server for performance and reliability in your specific network environment.

In this article, we will consider the concept of a network profile in Windows, consider what types of network profiles are, what they are used for, and how to change the assigned network profile from Public to Private or vice versa in Windows 10 and Windows Server 2019/2016. This is necessary if the network location is mistakenly detected as Public Network when it should be Private.

Windows network profiles are a part of the Windows Defender Firewall with Advanced Security and allow you to apply different firewall rules depending on the type of network the computer is connected to. Depending on the profile used for your network connection, other computers may or may not see your computer on the network (network discovery settings), use shared network folders and printers. Contents:

What is a Network Location (Profile) in Windows?

Network profiles firstly appeared in Vista/Windows Server 2008. In Windows 10 (Windows Server 2016), you can assign one of the following network security profiles (locations) for your NIC (network interface card), whether Ethernet or Wi-Fi:

  • Private or Home network – a profile for a trusted network (home or office networks). In such a network, the computer will be available for discovery by other devices; you can share your files and printers.
  • Public network – a profile for an untrusted network (public Wi-Fi network in the subway, cafe, airport). You don’t trust other devices on such a network, your computer will be hidden to other network devices, no one will be able to access shared network folders and printers on your computer;
  • Domain network – a profile for computers that are members of an Active Directory domain. Applies automatically after joining Windows to the AD domain. You can apply domain firewall policies for this profile.

The Network Location Awareness (NLA) service is used by Windows to determine if a network connection is on a Public, Private, or Domain network.

As mentioned earlier, different Windows Firewall rules apply to your network connection based on the network profile of your NIC.

In Windows 10, you can check the current network profile (location) assigned to the network connection in the Settings -> Network & Internet. In my screenshot, you can see that the Open (Public) profile is assigned to the Ethernet0 NIC.

win 10 - network status open for ethernet0 NIC

In the classic Control Panel, the network type for active network connections is displayed here: Control Panel -> All Control Panel Items -> Network and Sharing Center. But you cannot change the assigned network location from the classic Control Panel. For example, in Windows Server 2012 R2 / Windows 8.1, you can only change the network profile through the PowerShell, registry, or local security policy (described below).

public network in windows 10 control panel

How to Set a Network Profile in Windows 10?

The network profile in Windows 10 is selected by the user when the device connected to the new network for the first time. A prompt appears:

Network 2
Do you want to allow your PC to be discoverable by other PCs and devices on this network?
We recommend allowing this on your home and work networks, but not public ones.
Do you want to allow your PC to be discoverable by other PCs and devices on this network? We recommend allowing this on your home and work networks, but not public ones

If you select “Yes”, the Private profile will be assigned to the network, or the Public profile if you select “No”. The next time you connect to the same LAN or WiFi network, the previously selected profile is automatically assigned.

You can hide “Network Location Wizard” when connecting to a new network through the registry. Just create an empty registry key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Network\NewNetworkWindowOff. After that, all networks are considered Public.

You can reset all settings and profiles for saved networks in Windows 10 by selecting Settings -> Network & Internet -> Status -> Network Reset and rebooting the computer.

win 10 - reset network

Now when you connected to the network, a network discovery request appears again.

You can change the network profile from the Windows 10 GUI. If you are using the new Settings panel, go to “Network & Internet” -> “Status” -> “Change connection properties”.

Here you can switch the network location profile from Public to Private and vice versa.

network profile change from public to private in windows 10 settings

You cannot change the network profile from the classic Control Panel in Windows 10.

Also, you cannot change the network profile on the domain-joined computer. The Domain profile will always be used for a domain network connection.

Change Network Types Using PowerShell in Windows 10

On Windows 10/Windows Server 2016/2019, you can manage network connection location from the PowerShell. Run the elevated PowerShell console.

Now use the Get-NetConnectionProfile cmdlet to get a list of network adapters on your computer and their associated network profiles.

In my example, there is only one physical network adapter on a computer with a Public network location type (in the NetworkCategory value, you can see the following types of network profiles: Public, Private or DomainAuthenticated).

Get-NetConnectionProfile

Let’s try to change the assigned network profile for the NIC. We need to get the index assigned to this network card. In this example, InterfaceIndex is 8.

Name : Network 2
InterfaceAlias : Ethernet0
InterfaceIndex : 8
NetworkCategory : Public
IPv4Connectivity : Internet
IPv6Connectivity : NoTraffic

After you get the network adapter index, you can change the network type to Private:

Set-NetConnectionProfile -InterfaceIndex 8 -NetworkCategory Private

Check that the network profile has changed:

Get-NetConnectionProfile -InterfaceIndex 19

Set-NetConnectionProfile NetworkCategory - powershell

The new firewall rules will be applied to the interface according to the assigned network profile without rebooting.

You can also change the network profile for all network adapters of the computer at once:

Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private

Setting Network Type Using Windows Registry

The network type can also be changed from the Registry Editor. To do this, run regedit.exe and go to the following key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles. This registry key contains profiles of all network connections.

You can find the necessary network profile by its name listed (from the Network and Sharing Center) in the ProfileName registry parameter.

The network type is specified in the Category parameter. The following values are available:

  • 0 — Public Network
  • 1 — Private Network
  • 2 — Domain Network

Change the key value to the one you need and restart your computer.

Changing Network Location Type Using Security Policy

Another way to change the network location type is to use the Local Security Policy Editor. Run secpol.msc snap-in and go to the section Network List Manager Policies. On the right, find your network by its name as it is displayed in the Network and Sharing Center. Open the network properties and go to the Network Location tab, then change the network type from Not configured to Private and save the changes. To prevent users from changing the network profile, select the option “User cannot change location”.

change network location using security policy

Note. If a server or a computer is joined to the AD domain, you cannot change the network type. After the reboot, it will automatically change back to the Domain Network.

First, to identify the network type we will use the Get-NetConnectionProfile cmdlet. As you will see in the picture below, NetworkCategory shows the network type for all network adapters.

Change network type using PowerShell in Windows Server 2016

Using the InterfaceAlias ​​or InterfaceIndex of the previous command, you can change the network type for the adapter you want by using the Set-NetConnectionProfile cmdlet.

Set-NetConnectionProfile -InterfaceAlias ​​Ethernet -NetworkCategory Private
Set-NetConnectionProfile -InterfaceIndex 2 -NetworkCategory Private

With the NetworkCategory switch, you can choose between the three: Public, Private, and Domain.

Alternatively, to change the network type for all machine adapters, use the following command.

Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private

 Windows OS Hub / Windows 10 / How to Change the Network Profile (Location) to Public or Private on Windows

When connecting to a new network, Windows prompts you to select its network profile type (network location): Public or Private. Windows network profiles are part of Windows Defender Firewall with Advanced Security and allow you to apply different firewall rules depending on the type of network your computer is connected to. Depending on the profile used for your network connection, other computers may or may not see your computer on the network, use shared network folders and printers (network discovery settings).

In this article, we will look at how to change the Network profile type from “Public” to “Private” and vice versa in Windows (and Windows Server) using Windows Settings, PowerShell, Registry, and Security Policies.

Contents:

  • What is the Network Location (Profile) in Windows?
  • How to Change the Network Profile (Location) from Public to Private on Windows?
  • Change Network Location to Public or Private with PowerShell
  • How to Set Network Location via Windows Registry?
  • Change Network Type Using Local Security Policy
  • Private Network Instead of Domain on Windows Server

What is the Network Location (Profile) in Windows?

A network connection in Windows (whether Ethernet or Wi-Fi) can be assigned one of three network profiles.

  • Private or Home network – a profile for a trusted network (home or office network). In such a network, the computer will be available for discovery by other devices and you can share your files and printers;
  • Public network (Guest/Open) – a profile for untrusted networks (public Wi-Fi network in the subway, cafe, or airport). You don’t trust other devices on such a network, your computer will be hidden from other network devices, and no one will be able to access shared folders and printers on your computer;
  • Domain network – a profile for computers joined to an Active Directory domain. Applies automatically after joining the Windows device to the AD domain. You can apply domain firewall policies for this profile.

The Network Location Awareness (NLA) service is used in Windows to determine whether a network connection is on a Public, Private, or Domain network.

Depending on the type of network, different Windows Firewall rules apply to the network interface.

On Windows 10 and 11, you can see the current profile (location) assigned to the network connection in Settings -> Network and Internet -> Status (quick access command ms-settings:network ). The Ethernet0 network interface in my example is assigned the Public (Open) profile.

win 10 - network status open for ethernet0 NIC

You can check the network type for active network connections in Windows 10 using the classic Control Panel (All Control Panel Items\Network and Sharing Center).

public network in windows 10 control panel

The network profile in Windows 10 is selected by the user when the device is connected to the new network for the first time. A prompt appears:

Network 2
Do you want to allow your PC to be discoverable by other PCs and devices on this network?
We recommend allowing this on your home and work networks, but not public ones.

Do you want to allow your PC to be discoverable by other PCs and devices on this network? We recommend allowing this on your home and work networks, but not public ones

If you select “Yes”, the Private profile will be assigned to the network, or the Public profile if you select “No”. The next time you connect to the same LAN or WiFi network, the previously selected profile is automatically assigned.

You can hide the “Network Location Wizard” in Windows. Open the Registry Editor and create an empty registry key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Network\NewNetworkWindowOff. After that, all new networks will be defined as public networks when connected.

reg add "HKLM\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff" /f

You can reset all settings and profiles for all saved network connections in Windows by selecting Settings -> Network & Internet -> Status -> Network Reset. Then reboot the computer.

win 10 - reset network

Now when you connect to the network, a network discovery request appears again.

How to Change the Network Profile (Location) from Public to Private on Windows?

You can change the network profile type on Windows 10/11 using the modern Settings app. Go to “Network & Internet” -> “Status” and open your network connection settings.

Here you can switch the network location profile from Public to Private and vice versa.

network profile change from public to private in windows 10 settings

In Windows Server 2022/2019, the Properties option is missing from the Status tab. Therefore, select the Ethernet section in the Network and Internet section (or the Wi-Fi section if wireless networking is enabled in Windows Server). Select your network connection.

You cannot change the network connection profile type through the classical Control Panel in Windows.

If a server or a computer is joined to the AD domain, you cannot change the network type for a domain network connection. After the reboot, it will automatically change back to the Domain Network profile.

Change Network Location to Public or Private with PowerShell

On Windows 10/11 and Windows Server 2022/2019/2016, you can manage network connection locations from PowerShell. Open the elevated PowerShell console. List Windows network interfaces and the network profiles applied to them:

Get-NetConnectionProfile

In my example, there is only one physical network adapter (Ethernet0) on a computer with a Public network location (in the NetworkCategory value, you can see the following types of network profiles: Public, Private or DomainAuthenticated).

Get-NetConnectionProfile

Let’s try to change the assigned network profile for the NIC. You need to get the index assigned to this network adapter. In this example, InterfaceIndex = 8.

Name : Network 2
InterfaceAlias : Ethernet0
InterfaceIndex : 8
NetworkCategory : Public
IPv4Connectivity : Internet
IPv6Connectivity : NoTraffic

To change the network for the network adapter with index 8 to Private, run the command:

Set-NetConnectionProfile -InterfaceIndex 8 -NetworkCategory Private

Check that the network profile has changed:

Get-NetConnectionProfile -InterfaceIndex 8

Set-NetConnectionProfile NetworkCategory - powershell

Windows Defender Firewall will automatically apply firewall rules to the network connection according to the assigned network profile without rebooting.

Similarly, you can change the location of the network to Public:

Set-NetConnectionProfile -InterfaceIndex 8 -NetworkCategory Public

Or domain:

Set-NetConnectionProfile -InterfaceIndex 8 -NetworkCategory DomainAuthenticated

You can also change the network profile for all network adapters of the computer at once:

Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private

You won’t be able to change the network connection profile from domain to private or public on a domain-joined computer. Make sure your computer is joined to an AD domain:

Get-CimInstance -ClassName Win32_ComputerSystem).PartOfDomain

Try changing the network location:

Set-NetConnectionProfile -InterfaceIndex 8 -NetworkCategory Public –Verbose

An error will appear:

Set-NetConnectionProfile : Unable to set the NetworkCategory due to one of the following possible reasons: not running PowerShell elevated; the NetworkCategory cannot be changed from 'DomainAuthenticated'; user initiated changes to NetworkCategory are being prevented due to the Group Policy setting 'Network List Manager Policies'.

Set-NetConnectionProfile error: NetworkCategory cannot be changed from DomainAuthenticated

How to Set Network Location via Windows Registry?

You can change the network location using the Registry Editor. Open the regedit.exe and go to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles. This registry section contains a list of all network connections on your computer. There is a separate registry key for each network connection with a name in GUID format ({xxxxxx-xxxxx-……..}).

To find the network you need, look through all the registry keys and find the key that contains the parameter ProfileName with the network you need from the Network and Sharing Center (or the Name value from the Get-NetConnectionProfile command). In our case, the computer is connected to Network 4.

change network profile on windows via registry

Check your network name in the ProfileName registry string value. The network type is specified in the Category parameter. The following values are available:

  • 0 — Public Network
  • 1 — Private Network
  • 2 — Domain Network

In order to change the network type, set the parameter value to the one you need and restart your computer.

Change Network Type Using Local Security Policy

Another way to change the network connection type is to use the Local Security Policy Editor.

Run the secpol.msc snap-in and go to the section Network List Manager Policies. On the right, find your network by its name as it is displayed in the Network and Sharing Center. Open the network properties and go to the Network Location tab, then change the network type from Not configured to Private and save the changes. To prevent users from changing the network location profile, check the option “User cannot change location”.

change network location using security policy

Private Network Instead of Domain on Windows Server

In the new versions of Windows Server 2022/2019, I have seen several times a bug where the domain server (or even a domain controller or RODC) itself changes the network type from domain to private.

To solve the problem, just restart the Network Location Awareness service (from the services.msc console) or with the PowerShell command:

Get-Service NlaSvc| Restart-Service -Force (run as SYSTEM account)

To fix this problem on Windows Server, you need to configure the delayed start type for the Network Location Awareness service. To do this, select the Automatic (Delayed Start) option in the service properties and save the changes.

set network location awareness service delayed start

Make sure that after a reboot, the network type in Windows Server is now always defined as domain (not private).

If the problem occurs on an Active Directory domain controller, you need to change the dependencies of the NlaSvc service so that it starts after the DNS Server service:

sc config nlasvc depend=DNS

Also, in some cases, it can help to force set the DNS suffix of your domain in the network adapter settings (network adapter -> TCP / IPv4 -> Advanced -> DNS, specify your domain name in the “DNS suffix for this connection”, and check the option “Use the suffix of this connection in the DNS registration”.

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Windows 10 device guard kaspersky
  • Как закрепить картинку поверх всех окон windows 10
  • Отображение номеров недель в календаре windows
  • Анализ дампа памяти windows 10
  • Как перенести oem windows 7 на другой диск