惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
J
Java Code Geeks
IT之家
IT之家
Last Week in AI
Last Week in AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog RSS Feed
P
Proofpoint News Feed
博客园 - Franky
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 【当耐特】
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
B
Blog
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
博客园 - 聂微东
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
大猫的无限游戏
大猫的无限游戏
U
Unit 42
aimingoo的专栏
aimingoo的专栏

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
IP Configuration in Linux: A Beginner-Friendly Guide
Manoj Kumar · 2026-05-06 · via DEV Community

Manoj Kumar Vemula

For me, Linux used to be much more intimidating at first. But once I understood the basics and started using it regularly, it became straightforward. Assigning an IP address—either automatically via DHCP or manually—is not as hard as it looks. However, troubleshooting can be challenging because Linux provides multiple ways to handle network configurations.


1) The Easiest Way: DHCP (Automatic IP)

This is the simplest way to get an IP address. It automatically assigns network configurations such as IP address, gateway, DNS, and default route.

Command:

sudo dhclient -v eth0

Enter fullscreen mode Exit fullscreen mode

  • dhclient → Requests an IP from the DHCP server
  • -v → Verbose mode (shows packet activity)
  • eth0 → Network interface (may vary: eth0, ens33, wlan0, etc.)

Types of IP Configuration in Linux

There are two main types:

1. DHCP (Automatic)

  • IP is assigned automatically
  • No manual configuration needed

2. Static IP

  • IP is assigned manually
  • Useful for servers or systems requiring a fixed address

Temporary vs Persistent IP Configuration

You can assign IP addresses either temporarily or permanently.

Temporary Static IP (Non-Persistent)

This method stores the IP in RAM. Once the system reboots, the configuration is lost.

sudo ip addr add 192.168.1.225/24 dev eth0
sudo ip route add default via 192.168.1.1

Enter fullscreen mode Exit fullscreen mode

Temporary DNS Configuration:

echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf

Enter fullscreen mode Exit fullscreen mode


Persistent Static IP Configuration

For permanent configuration, Linux uses different tools depending on the distribution.

Since I am using Kali Linux, I prefer nmcli, as Kali uses NetworkManager.

Check Connection Name:

nmcli con show

Enter fullscreen mode Exit fullscreen mode

Static IP Configuration:

sudo nmcli con mod "Wired connection 1" ipv4.addresses 192.168.1.225/24
sudo nmcli con mod "Wired connection 1" ipv4.gateway 192.168.1.1
sudo nmcli con mod "Wired connection 1" ipv4.dns "8.8.8.8 1.1.1.1"
sudo nmcli con mod "Wired connection 1" ipv4.method manual

Enter fullscreen mode Exit fullscreen mode

Restart Connection:

sudo nmcli con down "Wired connection 1"
sudo nmcli con up "Wired connection 1"

Enter fullscreen mode Exit fullscreen mode

Switch Back to DHCP (Automatic Mode):

sudo nmcli con mod "Wired connection 1" ipv4.method auto
sudo nmcli con up "Wired connection 1"

Enter fullscreen mode Exit fullscreen mode


Configuration Files in Linux

Different Linux distributions use different configuration systems.

Kali Linux / Debian (NetworkManager)

Managed via:

/etc/NetworkManager/system-connections/

Enter fullscreen mode Exit fullscreen mode


Ubuntu (Netplan)

Modern Ubuntu systems use Netplan.

Configuration File:

/etc/netplan/01-netcfg.yaml

Enter fullscreen mode Exit fullscreen mode

Static IP Example (Netplan):

network:
  version: 2
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 192.168.1.225/24
      gateway4: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8, 1.1.1.1]

Enter fullscreen mode Exit fullscreen mode

Apply Changes:

sudo netplan apply

Enter fullscreen mode Exit fullscreen mode

DHCP (Automatic) Configuration:

network:
  version: 2
  ethernets:
    eth0:
      dhcp4: yes

Enter fullscreen mode Exit fullscreen mode

Troubleshooting Commands :

1. Check IP

ip a

2. Check route

ip route

3. Check connection config

nmcli con show
nmcli con show "Wired connection 1"

4. Reset connection (fast fix)

sudo nmcli con delete "Wired connection 1"
sudo systemctl restart NetworkManager

5. Get fresh IP

sudo dhclient -v eth0

6. Test

ping 8.8.8.8
curl google.com