🖥️ip
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ip command with important options and switches using examples.
3 minute read
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██╗██████╗
# ██║██╔══██╗
# ██║██████╔╝
# ██║██╔═══╝
# ██║██║
# ╚═╝╚═╝
#==============================#
# CMD IP
#==============================##==============================#
# Display all interfaces with addresses
ip addr
# Take down / up the wireless adapter
ip link set dev wlan0 {up|down}
# Set a static IP and netmask
ip addr add 192.168.1.100/32 dev eth0
# Remove a IP from an interface
ip addr del 192.168.1.100/32 dev eth0
# Remove all IPs from an interface
ip address flush dev eth0
# Display all routes
ip route
# Display all routes for IPv6
ip -6 route
# Add default route via gateway IP
ip route add default via 192.168.1.1
# Add route via interface
ip route add 192.168.0.0/24 dev eth0
# Change your mac address
ip link set dev eth0 address aa:bb:cc:dd:ee:ff
# View neighbors (using ARP and NDP)
ip neighbor show
#==============================##==============================#
ip route add $destination via $gateway
#
ip route add default via 192.168.2.1 dev ens33
# route add default gateway
ip a | grep -oP '(?<=inet |addr:)(?:\d+\.){3}\d+'
# grep expression (perl regex) to extract all ip addresses from both ip and ifconfig commands output
# It uses the following GNU grep options: "-o" which shows only the matching part of the line and "-P" which allows the use of Perl regular expressions.
# Show Sample Output:
ip a | grep -oP '(?<=inet |addr:)(?:\d+\.){3}\d+'
# # 127.0.0.1
# # 10.0.2.15
# # 172.17.0.1
ifconfig | grep -oP '(?<=inet |addr:)(?:\d+\.){3}\d+'
# # 96.126.108.191
# # 192.168.135.145
# # 127.0.0.1
# Really lazy way to print the first instance of $foo that occurs after $bar
ifconfig | grep ^en1 -A5 | grep inet | head -n 1
# Explanation: This is just for the sake of an example of finding $foo that occurs after $bar. Substitute ifconfig and the arguments of grep appropriately for your use case.
# In the output of ifconfig there are several lines with inet. We want to get to the first one that comes after a line starting with en1
# grep ^en1 -A5 will print the line starting with en1 and the next 5 lines that follow it
# grep inet will print only the lines matching inet
# head -n 1 will print only the first line
# The value 5 in -A5 is really just a guess that the line we're interested in will be within the next 5 lines, the appropriate number depends on your use case. Kind of a dumb technique, but it's easy to remember.
# How to set the ip address in Solaris 11
ipadm create-addr -T static -a 192.168.1.10/24 eth0/staticaddr
# Explanation:
# eth0 is the name of the network interface
# ipadm show-if shows the list of network interfaces
# staticaddr is a name you can choose
# More details here: http://docs.oracle.com/cd/E19963-01/html/821-1458/gjwiq.html
#==============================##==============================#
# CMD IP
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command ip in a clear format. This allows users to quickly access the needed information for ip without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for ip are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.