How to Set a Static IP Address on Various Operating Systems
Setting a static IP address ensures your server always has the same local network address. This is useful for port forwarding, remote access, and self-hosting.
Ubuntu / Debian (Linux)
Edit the netplan config (for Ubuntu 18.04+):
bashsudo nano /etc/netplan/01-netcfg.yaml
Example static IP config:
yamlnetwork: version: 2 # Netplan config version ethernets: eth0: # Name of your network interface (may be enp3s0, ens33, etc.) dhcp4: no # Disable DHCP (dynamic IP) addresses: [192.168.1.100/24] # Set your static IP and subnet (change as needed) gateway4: 192.168.1.1 # Your router's IP address nameservers: addresses: [1.1.1.1,8.8.8.8] # DNS servers (Cloudflare, Google)
Apply changes:
bashsudo netplan apply
Recommended DNS servers
Cloudflare DNS: 1.1.1.1 / 1.1.0.0
Google DNS: 8.8.8.8 / 8.8.4.4
Windows 10/11
- Open Settings > Network & Internet > Ethernet (or Wi-Fi).
- Click your network, then Edit under IP settings.
- Set to Manual, enable IPv4, and enter your static IP, subnet, gateway, and DNS.
macOS
- Open System Settings > Network.
- Select your network interface (Wi-Fi or Ethernet).
- Click Details (or Advanced), then TCP/IP.
- Set Configure IPv4 to Manually and enter your static IP, subnet mask, and router.
Router (Recommended for Beginners)
- Many routers let you reserve a static IP for your device (DHCP reservation) via the web interface. This is often easier and avoids OS-level config.
For more details, see your OS or router documentation.