Unix networking stuff.
TCP / IP networking model
layer 0 physical layer standards for voltages, frequencies and other physical properties layer 1 link layer communication with devices that share a physical connection Ethernet, 802.11a/b/g/n, and Token Ring layer 2 network layer talk to machines without knowing where they are physically located IP layer 3 transport layer determine which program to deliver messages to, usually through port numbers TCP, UDP layer 4 application layer protocol set of protocols for a specific program HTTP, SMTP, IMAP, POP3
On top of that there are an infinite amount of layers, most commonly:
layer 5 security layer make sure communication is private TLS, SSL layer 6 API layer talk to a program living within the application layer Twitter API, GitHub API
But these layers are not fixed, sometimes protocols switch between layers. OSI, for example, has 7 layers.
- little overhead
- reliable (retries)
nc is the
netcat command. It does anything surrounding TCP and UDP /
create a direct chat connection
Implement a rudimentary IRC chat using netcat. When a connection is established, messages will be echoed on both sides. terminal 1
$ nc -l 1337 # listen on port 1337
$ nc localhost 1337
Create a proxy
# proxy.sh url=$2
$ nc -lk 127.0.0.1 80 | ./proxy.sh
$ nc -z host.example.com 20-30
DNS is about naming things and pointing them in the right direction. DNS uses "records" to store this relation. There's different types of records:
- MX: mail exchange record, specify a mail server that can accept emails
- A: return a 32-bit IPv4 address
- AAAA: return a 128-bit IPv6 address
- CNAME: canonical name record, alias of one name to another
- CERT: certificate record, stores PGP, etc.
- SRV: service locator, used for newer protocols instead of creating a new record type
- TXT: used for human readable data, can be leveraged for protocols
- URL: used for redirects
Records are cached by default using a TTL (Time To Live) value. Using
;; ANSWER SECTION: yoshuawuyts.com. 299 IN A 220.127.116.11 yoshuawuyts.com. 299 IN A 18.104.22.168
The value here is 299 seconds.
dnsmasq(1)- DNS forwarder and server
dig(1)- DNS lookup utility
DNS Response Policy Zone
Interactive Connectivity Establishment. Used amongst others for WebRTC handshakes.
Network Address Translation
Session Traversal Utilities for NAT. Standardized set of methods and a network protocol to allow an end host to discover its public IP address if it is located behind a NAT.
Traversal Using Relays around NAT (TURN) is a protocol that assists in traversal of network address translators (NAT) or firewalls for multimedia applications. It may be used with the Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). It is most useful for clients on networks masqueraded by symmetric NAT devices. TURN does not aid in running servers on well known ports in the private network through a NAT; it supports the connection of a user behind a NAT to only a single peer, as in telephony, for example.
Inspect if port is open
ss(1) is a tool to validate if a port is open.
$ ss -tl4 '( sport = :<port_number> )' $ ss -tl4 '( sport = :22 )'
$ netstat -lnt
Change ip of router
$ open http://192.168.1.1/ $ open http://192.168.0.1/