- Networking
- Check this awesome Cheat sheet
- Query DNS
- Alternative to dig. It doesn't use the system local DNS.
- Check packets hop and route
- Network Probing
- Port scanning TCP,UDP ports open or closed
- Sends ICMP pings. checks latency
- Test port 80 netcat
- Examine the IPv4 TCP-based sockets that are listening for connections on your system
- Examine the IPv6 TCP-based sockets that are listening for connections on your system
- Creating Unix Domain Sockets
- examine unix domain sockets
- Connect to an UNIX Socket
- Simulate traffic in IPV4 and IPV6
- Traffic capture
- Network management
- Load testing
- Benchmarking
- Flush DNS by resetting the network DEBIAN based
- Inspect TCP socket states e.g. 443
- Netstat statistics
- Find ports in use
- Make sure the
firewalld
service is enabled - Install netcat in Fedora/Redhat
- CentOS Linux Open Port 8080 on the firewall
- Find user behind a process
- Test connectivity to a port
- Check server status
- Check Any URL and get output in Text
- Get listening ports
- Get a report with nmap. install it first
sudo snap install nmap
- The
ip
command - CURL Client URL
- Download a file and save it with a custom name
- Get HTTP headers. use the
-I
or the— head
option - Ignore invalid certs
-k or --insecure
- Make a POST request.
- get the HTTP headers and verbose mode
- Simplified view
- Specify the type of request
- Include the Basic Auth
- Update name resolution
- Check service health
- Upload a file
- Timing Curl connection
- VPN
- Network Probing
Commands and useful cheat sheet used in networking
Accessing a service, DNS
whois
= servers
DNS queries and shows associated records
dig $DOMAIN
nslookup $DOMAIN
traceroute $DOMAIN
Which TCP or UDP ports are open.
Can i open a TCP connection to this destination?
nmap -sS localhost
ping/ping6
nc -lvz 80
telnet
a complete protocol
tcdump -i eth0 icmp
ss -4 -tln
ss -6 -tln
socat unix-listen:/tmp/stream.sock,fork /dev/null&
socat unix-recvfrom:/tmp/datagram.sock,fork /dev/null&
ss -xln
nc -U -z /tmp/stream.sock
- The
-U
tells netcat that it is connecting to a Unix Domain Socket - The
-z
option ensures that netcat only connects to a socket, without sending any data - The
/tmp/stream.sock
is the address of the socket on the filesystem
socat TCP4-LISTEN:8080,fork /dev/null&
socat TCP6-LISTEN:8080,ipv6only=1,fork /dev/null&
socat
can listen on any available port on a system, so any port from 0 to 65535 is a valid parameter for the socket option.
tcpdump
traffic capture uses bpf filters
tcpdump -i eth0 -vvv -d dst $IP
wireshark
ifconfig
see info about interfaces. get your IP address
route -n
routing info. Routing table
arp -a
ip
see neighbor table. add routes
- Answers questions what are the net interfaces, ips, subnets, broadcast address?? how do i add routes?
tcpreplay
replays traffic from packet capture fire
tcpdump -i eth0 -w traffic.pcap
tcpreplay -i eth0 httptraffic.pcap
wrk2
Send Http load
Threads connections duration Requests
wrk2 -t1 -c10 -d60 -R100 -L http://$IP
iperf3
nuttcp
info siege
BPF/eBPF potential for new programs
source: Digital ocean talk Handy Linux networking tools
sudo /etc/init.d/networking restart
ss -nta '( dport = :443 )'
netstat
is a great tool for monitoring network connections.
netstat --statistics
netstat -tulpn
- The
-t
option checks for TCP connections. - The
-u
option checks for UDP connections. - The
-l
option tells netstat to list only LISTENING connections. If you want to see all connections, use the -a option instead. - The
-p
option shows the PID id of the process. - The
-n
option shows numerical addresses, instead of trying to resolve host, port, or user names.
ll /usr/lib/systemd/system | grep firewalld
ll /etc/systemd/system | grep firewalld
systemctl status firewalld
sudo systemctl enable firewalld
sudo systemctl restart firewalld
sudo systemctl status firewalld
yum install -y nc
sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload
sudo netstat -tulpe | grep 8090
nc -vvz $host $port
sudo netstat -tuple | grep smtp
curl -l localhost:80
ss -tulwn
nmap -sV -p- localhost
ip route show
ip route list
cat /etc/network/interfaces
- Policy routing
- Tunnels
sudo service nscd restart
curl -o custom_file.tar.gz https://testdomain.com/testfile.tar.gz
curl -I https://www.google.com
curl -k https://localhost/my_test_endpoint
If using JSON -H 'Content-Type: application/json'
curl --data "param1=test1¶m2=test2" http://test.com
curl --head --verbose HOST
curl --list-only $HOST
# updating the value of param2 to be test 3 on the record id
curl -X 'PUT' -d '{"param1":"test1","param2":"test3"}' \http://test.com/1
curl -u <user:password> https://my-test-api.com/endpoint1
curl --resolve www.test.com:80:localhost http://www.test.com/
curl -Is http://www.google.com
curl -F @field_name=@path/to/local_file <upload_URL>
curl -w "%{time_total}\n" -o /dev/null -s www.test.com
OpenVPN setup in ubuntu