Table of Contents

Linux IP Command

here

Show Subnet Data

sudo apt install sipcalc
sipcalc 192.168.1.0/24 -a

Show Network Data

Use nmcli

nmcli device show

or

#!/bin/bash

INTERFACE=ens34

echo "         Interface: $INTERFACE"
ip -4 addr show $INTERFACE | grep inet | awk -F " " '{print "              IPv4: " $2}'
ip route | grep default | grep "metric 100" | awk -F " " '{print "           Gateway: " $3}'
resolvectl -i $INTERFACE status --no-pager | awk '/DNS Server/,0'
nmcli connection show Wired\ connection\ 1 | grep -i dhcp_server_identifier | awk -F " " '{print "       DHCP Server: " $4}'

Get DHCP Server

nmcli connection show --active
nmcli connection show "<active-connection-name>" | grep -i dhcp_server_identifier

Ubuntu 20.04 Static IP

set the following in /etc/netplan/50-static-ip

network:
    version: 2
    ethernets:
        ens160:
            dhcp4: false
            addresses:
            - 192.168.1.2/24
            - 2001:db8:aaaa:bbbb:cccc::10/64
            gateway4: 192.168.1.1
            gateway6: 2001:db8:aaaa:bbbb:cccc::1/64
            nameservers:
              addresses:
              - 2001:db8:aaaa:bbbb:cccc::1/64
              - 192.168.1.1
              search: [internal.domain]

Then run

sudo netplan apply