> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Set a Static IP and DNS on Windows Server (PowerShell)

> Set a static IP on Windows Server with PowerShell: New-NetIPAddress for the address and gateway, Set-DnsClientServerAddress for DNS, or SConfig and netsh.

To set a static IP on Windows Server with PowerShell, run `New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 203.0.113.10 -PrefixLength 24 -DefaultGateway 203.0.113.1`, then set DNS with `Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses ("198.51.100.53","198.51.100.54")`. Use the address, prefix and gateway your provider gives you. Do it from the VNC console, because a mistake drops your Remote Desktop session.

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Intermediate | 10 minutes | Windows Server 2019 / 2022 / 2025 | Administrator access, console access, your IP details |

## Before you start

* Get your network details. On a FREAKHOSTING VPS they are on the **Network** tab of the VPS Panel: address, **Gateway**, **Netmask** and **Resolvers** ([view network settings](https://help.freakhosting.com/portals/vps-panel/how-to-view-and-manage-network-settings.md)). On a dedicated server, if you don't have them, [open a ticket](https://freakhosting.com/clientarea/submitticket.php).
* Convert the netmask to a prefix length: `255.255.255.0` is `/24`, `255.255.255.128` is `/25`, `255.255.254.0` is `/23`.
* Open the [VNC console](https://help.freakhosting.com/portals/vps-panel/how-to-enable-and-use-vnc-console-access.md) and run the commands there, as Administrator.

> [!WARNING]
>
> Changing the IP, prefix or gateway of the interface you are connected through disconnects Remote Desktop if anything is wrong. Work in the VNC console (or KVM/IPMI on a dedicated server) and write down the current settings first.

## How to see the current IP settings

```powershell theme={null}
Get-NetIPConfiguration
```

```text theme={null}
InterfaceAlias       : Ethernet
InterfaceIndex       : 4
IPv4Address          : 203.0.113.10
IPv4DefaultGateway   : 203.0.113.1
DNSServer            : 198.51.100.53
```

Note the **InterfaceAlias** (often `Ethernet` or `Ethernet 2`) and **InterfaceIndex**. Use either one in the commands below. `ipconfig /all` shows the same information and whether **DHCP Enabled** is `Yes`.

## How to set a static IP with PowerShell

**1. Remove the old default gateway (if one exists)**

If the interface already has a default gateway (for example from DHCP), remove it so you don't end up with two default routes:

```powershell theme={null}
Remove-NetRoute -InterfaceAlias "Ethernet" -DestinationPrefix "0.0.0.0/0" -Confirm:$false
```

**2. Add the static address and gateway**

```powershell theme={null}
New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 203.0.113.10 -PrefixLength 24 -DefaultGateway 203.0.113.1
```

If DHCP was on, Windows turns it off for this interface automatically. The gateway must be in the same subnet as the address.

**3. Set the DNS servers**

```powershell theme={null}
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses ("198.51.100.53","198.51.100.54")
```

**4. Remove an old address (only if you changed IP)**

If the interface still has a previous address you no longer want:

```powershell theme={null}
Remove-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 203.0.113.99 -Confirm:$false
```

## How to set a static IP with netsh

`netsh` replaces the address, mask and gateway in one command, which is handy in Command Prompt:

```powershell theme={null}
netsh interface ipv4 set address name="Ethernet" source=static address=203.0.113.10 mask=255.255.255.0 gateway=203.0.113.1
netsh interface ipv4 set dnsservers name="Ethernet" source=static address=198.51.100.53 register=primary validate=no
netsh interface ipv4 add dnsservers name="Ethernet" address=198.51.100.54 index=2 validate=no
```

## How to set a static IP with SConfig

SConfig is Windows Server's built-in text menu and works well in the VNC console.

**1. Open Network settings**

Type `SConfig` in an admin PowerShell window, then **8** (**Network settings**) and the number of your network adapter.

**2. Set the address**

Choose **1** (set network adapter address), then **S** for static. Enter the IP address, the subnet mask (for example `255.255.255.0`) and the default gateway.

**3. Set DNS**

Choose **2** (set DNS servers) and enter the preferred and alternate DNS server.

## How to change only the DNS servers

DNS (Domain Name System) turns names like `example.com` into IP addresses. To change only the resolvers:

```powershell theme={null}
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses ("198.51.100.53","198.51.100.54")
Get-DnsClientServerAddress -InterfaceAlias "Ethernet" -AddressFamily IPv4
```

To go back to the DNS servers handed out by DHCP: `Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ResetServerAddresses`. On a VPS you can also pick resolvers in the panel; see [change DNS resolvers](https://help.freakhosting.com/portals/vps-panel/how-to-change-ipv4-public-dns-resolvers.md).

## How to check it worked

```powershell theme={null}
Get-NetIPConfiguration -InterfaceAlias "Ethernet"
Test-NetConnection 198.51.100.53
Resolve-DnsName example.com
```

`IPv4Address`, `IPv4DefaultGateway` and `DNSServer` should show your new values, the ping should succeed (if the target answers ping), and `Resolve-DnsName` should return an address. Then connect with Remote Desktop again from your own computer.

## How to switch back to DHCP

```powershell theme={null}
netsh interface ipv4 set address name="Ethernet" source=dhcp
netsh interface ipv4 set dnsservers name="Ethernet" source=dhcp
```

Only do this if your network actually provides DHCP; otherwise the server loses its address.

## Frequently asked questions

### What is the difference between PrefixLength and subnet mask?

They describe the same thing. A prefix length of `24` equals the mask `255.255.255.0`. PowerShell uses the prefix length; netsh and SConfig use the mask.

### New-NetIPAddress gives an error about the gateway. What now?

The interface probably already has a default route. Remove it with `Remove-NetRoute -InterfaceAlias "Ethernet" -DestinationPrefix "0.0.0.0/0"` and run `New-NetIPAddress` again, or use the single `netsh interface ipv4 set address` command, which replaces the address and gateway together.

### Can I add more IP addresses the same way?

Yes, but add extra addresses without a gateway. See [add additional IP addresses on Windows Server](https://help.freakhosting.com/portals/other/how-to-add-additional-ip-addresses-on-windows-server.md).

### I lost Remote Desktop after changing the IP. How do I fix it?

Sign in through the [VNC console](https://help.freakhosting.com/portals/vps-panel/how-to-enable-and-use-vnc-console-access.md), run `Get-NetIPConfiguration` and correct the address, prefix or gateway. If the network is badly broken, see [flush DNS and reset the network stack](https://help.freakhosting.com/portals/other/how-to-flush-dns-and-reset-the-network-stack-on-windows.md).

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every guide in this section.

> [card] [Add additional IP addresses](https://help.freakhosting.com/portals/other/how-to-add-additional-ip-addresses-on-windows-server.md)
>
> Secondary IPs on one adapter.

> [card] [Enable IPv6 on Windows Server](https://help.freakhosting.com/portals/other/how-to-enable-ipv6-on-windows-server.md)
>
> Add a static IPv6 address.

> [card] [Find your server IP](https://help.freakhosting.com/portals/other/how-to-find-your-server-ip-address.md)
>
> On Linux and Windows.

> [card] [VPS network settings](https://help.freakhosting.com/portals/vps-panel/how-to-view-and-manage-network-settings.md)
>
> Your gateway, netmask and resolvers.

***

> [!NOTE]
>
> **Checked against Microsoft Learn: [New-NetIPAddress](https://learn.microsoft.com/en-us/powershell/module/nettcpip/new-netipaddress), [Remove-NetRoute](https://learn.microsoft.com/en-us/powershell/module/nettcpip/remove-netroute), [Set-DnsClientServerAddress](https://learn.microsoft.com/en-us/powershell/module/dnsclient/set-dnsclientserveraddress), [netsh interface](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-interface) and [SConfig](https://learn.microsoft.com/en-us/windows-server/administration/server-core/server-core-sconfig)** on 4 November 2026. Commands were not tested on a live Windows server for this page; sample output is shortened.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.