Configuring IP addresses on Windows, Linux and macOS: GUI, PowerShell, Netplan and nmcli
In short: Every operating system can get its address from DHCP or use a static configuration. On Windows you can use the adapter settings or PowerShell commands such as New-NetIPAddress. Ubuntu uses Netplan YAML files, many other Linux systems use NetworkManager with nmcli, and macOS uses System Settings or networksetup. Use DHCP reservations where possible and static addresses only for infrastructure.
DHCP or static?
Most devices should use DHCP, because changes to gateways and DNS servers then happen centrally. Servers, network devices and printers need predictable addresses, which you can provide with either DHCP reservations (still managed centrally) or static configuration on the device. Infrastructure that DHCP itself depends on, such as DNS servers, domain controllers and the DHCP server, should always be static.
Windows
Graphical: Settings, Network and Internet, the adapter, then Edit IP assignment (or the classic ncpa.cpl adapter properties).
Get-NetIPConfiguration
Get-NetAdapter
# static address, mask /24, gateway
New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 10.10.5.30 -PrefixLength 24 -DefaultGateway 10.10.5.1
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses 10.10.5.53,10.10.5.54
# back to DHCP
Set-NetIPInterface -InterfaceAlias "Ethernet" -Dhcp Enabled
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ResetServerAddresses
ipconfig /release ; ipconfig /renew
Linux with Netplan (Ubuntu)
Netplan uses YAML files in /etc/netplan/. Indentation matters.
network:
version: 2
ethernets:
ens160:
dhcp4: false
addresses: [10.10.5.31/24]
routes:
- to: default
via: 10.10.5.1
nameservers:
addresses: [10.10.5.53, 10.10.5.54]
search: [corp.example.com]
Apply with sudo netplan try, which rolls back automatically after two minutes if you lose access and do not confirm, then sudo netplan apply.
Linux with NetworkManager (RHEL, Fedora, desktops)
nmcli connection show
nmcli connection modify "Wired connection 1" ipv4.method manual \
ipv4.addresses 10.10.5.32/24 ipv4.gateway 10.10.5.1 ipv4.dns "10.10.5.53 10.10.5.54"
nmcli connection up "Wired connection 1"
Temporary changes for testing can be made with ip addr add and ip route add, but they disappear on reboot.
macOS
System Settings, Network, the interface, Details, TCP/IP and DNS. From the terminal:
networksetup -listallnetworkservices
networksetup -setmanual "Ethernet" 10.10.5.33 255.255.255.0 10.10.5.1
networksetup -setdnsservers "Ethernet" 10.10.5.53 10.10.5.54
networksetup -setdhcp "Ethernet"
Common mistakes
- Gateway in a different subnet from the address (for example 10.10.5.30/24 with gateway 10.10.6.1).
- Typing the mask wrong, which makes remote addresses look local or the other way round.
- Using an address that is inside the DHCP pool, causing a conflict later.
- Forgetting DNS servers, so the internet "works by IP but not by name".
Real-world example: the remote server that disappeared
An engineer changed a remote Ubuntu server's address by editing Netplan and running netplan apply. A typo in the gateway cut off the SSH session, and someone had to drive to the site. Since then, the team always uses netplan try, which would have rolled the change back automatically.
Practice
Which PowerShell command sets a static IPv4 address and default gateway?
New-NetIPAddress with -IPAddress, -PrefixLength and -DefaultGateway.Why is netplan try safer than netplan apply on a remote server?
Which devices should always have static addresses?
Key takeaways
- Use DHCP and reservations for most devices; static for core infrastructure.
- Windows: adapter settings or New-NetIPAddress and Set-DnsClientServerAddress.
- Linux: Netplan on Ubuntu, nmcli with NetworkManager; macOS: networksetup.
- Check the gateway is in the same subnet and the address is outside the DHCP pool.
Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.