From dd029a4dca04eae95757bbc3f861dc29259b5408 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 27 Jul 2025 22:43:14 +0330 Subject: [PATCH] linux doc: ip command --- Linux/LPIC1/20-ip.md | 148 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 Linux/LPIC1/20-ip.md diff --git a/Linux/LPIC1/20-ip.md b/Linux/LPIC1/20-ip.md new file mode 100644 index 0000000..954de61 --- /dev/null +++ b/Linux/LPIC1/20-ip.md @@ -0,0 +1,148 @@ + +# 🌐 IP Command Cheat Sheet + +The `ip` command is a powerful tool for network configuration and management in Linux. It replaces many of the older `ifconfig` functionalities. + +--- + +## 📌 General Syntax + +```bash +ip [ OPTIONS ] OBJECT { COMMAND | help } +``` + +**Common OBJECTS:** + +* `addr` – IP addresses +* `link` – Network interfaces +* `route` – Routing tables +* `neigh` – ARP table +* `rule`, `netns`, etc. + +--- + +## 🔍 View Network Information + +### Show All IP Addresses + +```bash +ip addr show +# or shorthand: +ip a +``` + +### Show IP for Specific Interface + +```bash +ip addr show dev eth0 +``` + +### Show Link Layer Information + +```bash +ip link show +``` + +--- + +## 🔧 Interface Management + +### Bring Interface Down + +```bash +ip link set eth0 down +``` + +### Bring Interface Up + +```bash +ip link set eth0 up +``` + +--- + +## 🌐 IP Address Configuration + +### Add an IP Address + +```bash +ip addr add 192.168.1.10/24 dev eth0 +``` + +### Delete an IP Address + +```bash +ip addr del 192.168.1.10/24 dev eth0 +``` + +--- + +## 🛣️ Routing + +### Show Routing Table + +```bash +ip route show +``` + +### Add a Default Gateway + +```bash +ip route add default via 192.168.1.1 +``` + +### Add a Specific Route + +```bash +ip route add 192.168.10.0/24 via 192.168.5.2 +``` + +### Delete a Specific Route + +```bash +ip route del 192.168.10.0/24 via 192.168.5.2 +``` + +--- + +## 🧱 Bridge Interface Management + +### Create a Bridge + +```bash +ip link add name br0 type bridge +``` + +### Delete a Bridge + +```bash +ip link delete br0 +``` + +### Bring Bridge Up + +```bash +ip link set br0 up +``` + +--- + +## 🛠️ Example: Set a Static IP Address + +```bash +ip link set ens33 up +ip addr add 10.10.40.12/24 dev ens33 +ip route add default via 10.10.40.1 +``` + +--- + +### ✅ Tip: + +Always verify with: + +```bash +ip a +ip r +``` +