Skip to content

Instantly share code, notes, and snippets.

@carlosrodlop
Last active January 31, 2023 08:18
Show Gist options
  • Save carlosrodlop/6f5870199b918dab5aa1376b421615c6 to your computer and use it in GitHub Desktop.
Save carlosrodlop/6f5870199b918dab5aa1376b421615c6 to your computer and use it in GitHub Desktop.
Network Troubleshooting snippets
# Check connection FROM Host > TO my-example.com (e.g. port 8443)
telnet my-example.com 8443 #It maintains a socket open to port 8443 (as example), so it can be useful to validate if there is a man a middle closing the channel Connection closed by foreign host
curl -IvL -X GET https://my-example.com #It also accepts to curl to a specific port e.g. https://my-example.com:8443
nc -z -v -w 2 my-example.com 8443 # It will tell if the port is open or not
# Check if a services is running in the Host
sudo lsof -i -P -n | grep LISTEN # Prefered method, it provides more information including the process. For extended output use sudo
netstat -pnatu | grep LISTEN
lsof -i :50001 # Check if an application is listening to specific PORT (50001)
netstat -ntpl | grep 50001 # Check if an application is listening to specific PORT (50001)
# Check internal tables of IP packet filter rules in the Linux kernel Host
sudo iptables -L
# Check an endpoint (e.g. http://example.com:4516/deployit) is reachable with proxy vs without ptoxy
## No proxy
curl -IvL http://example.com:4516/deployit
## Using proxy
curl -x https://proxy.example.com:3128 --proxy-user <username>:<password> -IvL http://example.com:4516/deployit
### Also you can set variables http_proxy, https_proxy, ftp_proxy, no_proxy: https://wiki.archlinux.org/index.php/Proxy_server
### Same proxy can redirect HTTP and HTTPS https://serverfault.com/questions/817680/https-through-an-http-only-proxy
export https_proxy="https://proxy.example.com:3128" ;curl -ILv http://example.com:4516/deployit
# Check Domain Names
nslookup example.com
# Configuration files
## network interface
nano /etc/network/interfaces
## network hosts
nano /etc/hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment