Cheatsheet: Linux Networking


- PDF Link: cheatsheet-networking-A4.pdf, Category: interview
- Blog URL: https://cheatsheet.dennyzhang.com/cheatsheet-networking-A4
- Related posts: CheatSheet: Linux File, CheatSheet: Linux Process, #denny-cheatsheets
1.1 Top 10 Networking Questions
Num | Name | Summary |
---|---|---|
1 | Difference between switch and router? | L2, L3 |
2 | What is a DNS amplification attack? | |
3 | Difference between L2 and L3 switch? | |
4 | What is TCP SYN scan? How it’s conducted? | |
5 | Which port ICMP is using? | Neither TCP or UDP. Link |
6 | Proxy server vs Loadbalancer. Proxy server vs Reverse proxy server | |
7 | Brief introduction about 802.1x | |
8 | List all methods which can stop one ip ssh to the server |
|
9 | Explain how iptable routing rules works |
1.2 Linux Networking
Name | Comment |
---|---|
Examine network nic traffic | ethtool -S eth0 |
Check system configuration | sysctl -a |
Change linux machine hostname | /etc/sysconfig/network , /etc/hostname |
Ports for well-known services | cat /etc/services |
Reference | SSH CheatSheet, Tcpdump CheatSheet, CheatSheet: Curl & Wget |
Reference | CheatSheet: Linux File, CheatSheet: Linux Process, CheatSheet: Linux Networking |
1.3 HTTP
Name | Command |
---|---|
How HTTPS works | |
Explain X509 certificates | |
See HTTP request statistics | httpstat https://www.google.com (brew install httpstat ) |
Monitor HTTP URLs | SaaS: uptimerobot.com |
Examine web page performance | SaaS: pingdom.com |
Test webpage from different browsers | SaaS: www.browserling.com |
Export local http service to Internet | SaaS: ngrok.com |
Reference | CheatSheet: Curl & Wget, GitHub: free-for-dev |
1.4 TCP
Name | Comment |
---|---|
List all listening tcp ports | netstat -tunlp |
Port scan for a given host | sudo nmap -O 192.168.1.103 , SaaS: viewdns.info/portscan |
Add 97ms latency to eth0 | Link: tc, tc qdisc add dev eth0 root netem delay 97ms |
Check tc status | tc -s qdisc |
Remove tc rule | tc qdisc del dev eth0 root netem |
Check network speed | SaaS: www.att.com/speedtest |
Tcp manual | man 7 tcp |
Disable ipv6 | Change systcl, by adding net.ipv6.conf.*.disableipv6 |
Check for IPv6 support in the current kernel | /proc/net/if_inet6 |
Reference | Tcpdump CheatSheet |
1.5 Route
Name | Comment |
---|---|
List route rules | route -n , netstat -nr |
Add default rule | route add default gw 10.0.0.1 netmask 255.255.255.0 dev eth0 |
Add route rule | route add -net 0.0.0.0 gw 192.168.1.1 netmask 0.0.0.0 dev eth0 |
Del route rule | route del -net 192.168.3.0 netmask 255.255.255.0 dev eth1 |
1.6 DNS
Name | Comment |
---|---|
Check dns naming | sudo nslookup www.google.com |
Print routing table | netstat -rn |
List all the router hops | traceroute |
DNS lookup utility | host www.google.com |
DNS pin test | SaaS: viewdns.info |
Websites To Register DNS | Link: Google Domain DNS, Link: GoDaddy, Link: Amazon Route 53 |
1.7 CDN
Name | Command |
---|---|
CDN services | cloudflare, jsDelivr |
1.8 TCP sockets workflow
Name | Comment |
---|---|
create a new anonymous socket | s = socket(<parameters>) |
Bind tcp port to a socket | bind(s, <local IP:port>) |
Create a socket to remote endpoint | connect(s, <remote IP:port>) |
Create local socket and make it eligible to take requests | listen(s, ...) |
Accept client requests | s2 = accept(s) |
Read n bytes from a socket | n = read(s, buffer, n) |
Write n bytes to a socket | n = write(s, buffer, n) |
Close a socket | close(s) |
Shutdown stdin and stdout/stderr for a socket | shutdown(s, <side>) |
Read socket options | getsockopt(s, ..) |
Change socket options | setsockopt(s, ..) |
1.9 More Resources
License: Code is licensed under MIT License.