Skip to content

command reference

DNS

dig

use the +nsid option to find the DNS resolver processing the DNS query

dig blog.neni.io +nsid

nslookup

#find the DNS resolver processing the DNS query
nslookup -q=txt -class=CHAOS id.server. 1.1.1.1
nslookup -q=txt -class=CHAOS id.server. 69.252.81.81

Curl

curl <options> <url> <optional headers>

commonly used options:
-v: verbose
-k: allow insecure connections. generally used with https
-I: use HEAD method. default is GET method. 
-0: (zero and not 'O': to use http version 1.0 instead of http version 1.1)
-L: Follow redirects (generate new request using the location information in redirect like 302)

Test HTTP request via proxy

curl -vx http://proxy.example.net:3128  http://myexternalip.com/json

Resolve FQDN to temporary address

curl -v https://blog.neni.io --resolve blog.neni.io:80:192.168.10.5

Run man curl or curl --help to know more.

OpenSSL

Check Certificate Subject, Issuer, Issued and Expiration dates.

echo Q | openssl s_client -connect 192.168.10.5:443 2>/dev/null | openssl x509 -dates -noout -serial -issuer -subject | sed 's/notBefore=/Issued Date: /' | sed 's/notAfter=/Expiration Date: /' 

echo Q | openssl s_client -servername blog.neni.io -connect 185.199.108.153:443  2>/dev/null | openssl x509 -dates -noout -serial -issuer -subject | sed 's/notBefore=/Issued Date: /' | sed 's/notAfter=/Expiration Date: /' 

hostport=blog.neni.io:443
echo Q | openssl s_client -connect ${hostport} 2>/dev/null | openssl x509 -dates -noout -serial -issuer -subject | sed 's/notBefore=/Issued Date: /' | sed 's/notAfter=/Expiration Date: /' 

Create Self-signed Certificate and Private key with Subject Alternative Name

openssl req -x509 -newkey rsa:2048 -sha256 -days 3650 -nodes -keyout 'server.key' -out 'server.crt' -subj '/C=US/ST=Pennsylvania/L=Philadelphia/O=Neni.io/CN=blog.neni.io' -extensions san -config <( echo '[req]'; echo 'distinguished_name=req'; echo '[san]'; echo 'subjectAltName=DNS:blog.neni.io'; echo 'extendedKeyUsage=serverAuth,clientAuth')

or

echo '[req]' > /tmp/cert-san.conf; echo 'distinguished_name=req' >> /tmp/cert-san.conf; echo '[san]' >> /tmp/cert-san.conf; echo 'subjectAltName=DNS:blog.neni.io' >> /tmp/cert-san.conf; echo 'extendedKeyUsage=serverAuth,clientAuth' >> /tmp/cert-san.conf

openssl req -x509 -newkey rsa:2048 -sha256 -days 3650 -nodes -keyout 'server.key' -out 'server.crt' -subj '/C=US/ST=Pennsylvania/L=Philadelphia/O=Neni.io/CN=blog.neni.io' -extensions san -config /tmp/cert-san.conf

Check the modulus of Certificate and Private key

openssl rsa -modulus -noout -in server.key | openssl md5
openssl x509 -modulus -noout -in server.crt | openssl md5

Create PKCS#12 (.pfx) format file from Certificate and Private key

openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt
openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt 

Ciphers Testing

nmap --script ssl-enum-ciphers -p PORT HOST

nmap --script ssl-enum-ciphers -p 443 blog.neni.io

Tcpdump

tcpdump <options> <interface> <protocol> <host and port combinations>

Commonly used options:
-s0 : set snaplen to 0, meaning capture entire packet
-vvv : verbose output
-nn : do not resolve IP addresses and ports to their names.
-c : Number of packets to capture. Useful when filtering and capturing high traffic flows
-i : pass the interface name
-w : write to a file typically with extension .pcap. Always write to a file in tmp folder. Ex. /tmp/abcapp.pcap


tcpdump -s0 -v -nni eth0 host 10.1.1.1
tcpdump -s0 -v -nni eth0 host 10.1.1.1 -w /tmp/abcapp.pcap
tcpdump -s0 -v -nni eth0 host 10.1.1.1 and port 443
tcpdump -s0 -v -nni eth0 host 10.1.1.1 and port 443 -c 100

# For F5s, use 0.0 which is an internal TMM (Traffic Management MicroKernel) interface
tcpdump -s0 -v -nni 0.0 host 10.1.1.1 -w /tmp/abcapp.pcap
tcpdump -s0 -v -nni 0.0:p host 10.1.1.1 -w /tmp/abcapp.pcap
tcpdump -s0 -v -nni 0.0:nnnp host 10.1.1.1 -c 100 -w /tmp/abcapp.pcap

A10

#Reset to factory defaults
device(config)#system-reset 

Arista

Cisco

ASR 9K
show inventory rack # Chassis serial number
sh controllers Te0/2/0/17 phy.  # Optic power levels

F5

Fortinet

Juniper

show interfaces diagnostics optics et-0/0/61  # Optic power levels
show chassis hardware                 # Chassis serial number

Sonic

ZPE

From the ZPE cli

Viewing configs:

show /system/about       # system version, model, uptime
show /settings/network_connections/ # interfaces, ip configs
show /settings/network_settings/

Connecting to a device's console:

cd /access
ls
cd <name of the device>
connect