Ubuntu networking commands
$cat /etc/os-release = view Linux distro info
$sudo apt-get install openssh-server = install openssh-server so you can putty in to that machine
$ssh -v username@ipaddress = debug mode for connecting to ssh
$ifconfig -a = find your IP
$iwconfig (for wireless) = find your wireless IP
$ip addr = find your IP
$nbtscan PublicIPAddress = find hostname based on your machine IP address
$/etc/init.d/networking restart = restart network service
$nano /var/cache/bind/domainname.com = if you need to make changes to DNS records
$sudo netstat -tupln = check all active network connections to the server
$netstat -tupln | grep listen = find on what ports your machine are listening
$netstat -tun | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n = print Foreign IP Addresses with unique connections to your server and sort
$sudo route -n = check routing table
$ss -lnt = socket statistic listener ports list
$nc -vz <hostname or ip address> 1-1000 = netcat command to scan ports 1 to 1000
$nc -v google.ca 443 = verify if google listens on port 443
$telnet IPaddress 80 = verify if remote IP machine listens on port 80
$tcptraceroute google.ca 443 = trace route up to google.ca on port 443 (always provided FQDN domain name only)
$nslookup IPaddress = checking if public DNS resolves the IPaddress
$curl -ivs destinationURL = test connection to that destination server
$curl http://169.254.169.254/latest/meta-data/public-ipv4 = displays the local webserver public IP address
$curl -is https://google.ca | head -1 = status code 200 OK means that the request has succeeded and the URL is reachable
$sudo update-ca-certificates --fresh = refresh all SSL Certificates on Ubuntu as these certs expire and your local cache will not validate
$sudo lsof -i:443 = check local network activity on port 443
$openssl s_client -connect clientprod.domainnameapi.com:443 -CApath /etc/ssl/certs
$sudo openssl req -new -newkey rsa:2048 -keyout domainname.com.key -out domainname.com.csr = generate initial private key and csr request
$dig mx domainname.com +short = check MX records of a domainname on the internet
How to configure network IP:
$vi /etc/network/interfaces = set static IP on old ubuntu systems
$sudo vim /etc/netplan/50-cloud-init.yaml = set static IP on new ubuntu 18.04 servers
## To configure a dynamic IP address auto eth0
iface eth0 inet dhcp
## Or configure a static IP
auto eth0
iface eth0 inet static
address 192.168.1.14
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
dns-nameservers 8.8.8.8 8.8.4.4 x.x.x.x