Skip to main content

Static IP Configuration

This guide covers how to configure static IP addresses on different Linux distributions and network management systems.


Prerequisites

Before configuring a static IP, gather the following information:

  • IP Address: The static IP you want to assign
  • Subnet Mask: Usually /24 (255.255.255.0) for home networks
  • Gateway: Your router's IP address (usually .1 or .254)
  • DNS Servers: Primary and secondary DNS servers

Find Current Network Information

# Get current IP configuration
ip addr show

# Get current gateway
ip route show default

# Get current DNS servers
cat /etc/resolv.conf

Configuration Methods

1. Using nmcli (Command Line)

# List available connections
nmcli connection show

# Create a new static connection
sudo nmcli connection add type ethernet con-name "static-eth0" ifname eth0

# Configure static IP
sudo nmcli connection modify "static-eth0" ipv4.addresses 192.168.1.100/24
sudo nmcli connection modify "static-eth0" ipv4.gateway 192.168.1.1
sudo nmcli connection modify "static-eth0" ipv4.dns "8.8.8.8,8.8.4.4"
sudo nmcli connection modify "static-eth0" ipv4.method manual

# Activate the connection
sudo nmcli connection up "static-eth0"

2. Using nmtui (Text Interface)

sudo nmtui

Steps in nmtui:

  1. Select "Edit a connection"
  2. Choose your network interface
  3. Select "Edit"
  4. Set IPv4 configuration to "Manual"
  5. Add your static IP, gateway, and DNS servers
  6. Select "OK" and "Back"
  7. Select "Activate a connection" and activate your new connection

3. Using GUI (Network Settings)

  1. Open SettingsNetwork
  2. Click the gear icon next to your connection
  3. Go to IPv4 tab
  4. Change method to Manual
  5. Enter your static IP configuration
  6. Click Apply

Verification

1. Check IP Configuration

# Check current IP address
ip addr show

# Alternative command
ifconfig

# Check routing table
ip route show

2. Test Connectivity

# Test gateway connectivity
ping -c 4 192.168.1.1

# Test DNS resolution
nslookup google.com

# Test internet connectivity
ping -c 4 8.8.8.8

3. Check DNS Resolution

# Test DNS
dig google.com

# Check DNS servers
cat /etc/resolv.conf

Troubleshooting

Common Issues

ProblemSolution
No internet accessCheck gateway and DNS configuration
IP conflictVerify IP is not in use by another device
Connection not workingRestart network service or reboot
DNS not resolvingCheck DNS server configuration

Debug Commands

# Check network interface status
ip link show

# Check routing table
ip route show

# Test specific interface
ping -I eth0 8.8.8.8

# Check network manager status
systemctl status NetworkManager

# View network logs
journalctl -u NetworkManager

Quick Reference

TaskCommand
List connectionsnmcli connection show
Show IP configip addr show
Show routingip route show
Test connectivityping -c 4 8.8.8.8
Restart networksudo systemctl restart networking
Apply netplansudo netplan apply

Security Notes

  • Use private IP ranges: 192.168.x.x, 10.x.x.x, or 172.16-31.x.x
  • Avoid IP conflicts: Check your network for existing IPs
  • Document changes: Keep track of static IP assignments
  • Backup configs: Save original network configurations before changes

Tip: Always test your configuration with netplan try (Ubuntu) or restart network services to ensure changes work before rebooting.