🖥️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.

▁ ▂ ▃ ▄ ꧁ 🔴☠ 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
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░