Network Management
HTTP request
curl https://example.comReturn response bodycurl -i|--include https://example.comInclude status code and HTTP headerscurl -L|--location https://example.comFollow redirectscurl -O|--remote-name foo.txt https://example.comOutput to a text filecurl -H|--header "User-Agent: Foo" https://example.comAdd a HTTP headercurl -X|--request POST -H "Content-Type: application/json" -d|--data '{"foo":"bar"}' https://example.comPOST JSON-
curl -X POST -H --data-urlencode foo="bar" http://example.comPOST URL Form Encoded -
wget <https://example.com/file.txt>Download a file to the current directory wget -O|--output-document foo.txt <https://example.com/file.txt>Output to a file with the specified name
Network Troubleshooting
ping example.comSend multiple ping requests using the ICMP protocol-
ping -c 10 -i 5 example.comMake 10 attempts, 5 seconds apart -
ip addrList IP addresses on the system -
ip route showShow IP addresses to router -
curl ifconfig.meObtain external IP address -
netstat -i|--interfacesList all network interfaces and in/out usage -
netstat -l|--listeningList all open ports -
traceroute example.comList all servers the network traffic goes through -
mtr -w|--report-wide example.comContinually list all servers the network traffic goes through -
mtr -r|--report -w|--report-wide -c|--report-cycles 100 example.comOutput a report that lists network traffic 100 times -
nmap 0.0.0.0Scan for the 1000 most common open ports on localhost nmap 0.0.0.0 -p1-65535Scan for open ports on localhost between 1 and 65535nmap 192.168.4.3Scan for the 1000 most common open ports on a remote IP addressnmap -sP 192.168.1.1/24Discover all machines on the network by ping'ing them
DNS
dig example.comShow query information of a domain A recordsdig -4 example.comShow IPv4 A informationdig -6 example.comShow IPv6 AAA informationdig example.com @nameserverShow query of a specific nameserver-
dig example.com -p 123Show query of a specific port number -
cat /etc/resolv.confresolv.conflists nameservers