Networking

Network

  • Networks is what transports traffic between hosts
  • Logical grouping of hosts which require similar connectivity
  • Networks can contain other networks
    • These are sometimes called sub-networks or subnet
  • Networks connect to other networks

Network Protocols

  • A network protocol is a set of rules that allows for data transmissions across different technologies.

Protocols

  • ARP - Address Resolution Protocol
  • FTP - File Transfer Protocol
  • SMTP - Simple Mail Transfer Protocol
  • HTTP - Hyper Text Transfer Protocol
  • TLS - Transport Layer Security
  • SSL - Secure Sockets Layer
  • HTTPS - HTTP Secured with TLS/SSL
  • DNS - Domain Name System
  • DHCP - Dynamic Host Configuration Protocol

Commands

ping

  • uses ICMP protocol
  • send 10 packets
    • shows % packet loss also
ping <ip> -n 10

traceroute

  • print the route packets take to network host
traceroute example.com

tracert

  • Available on Windows
  • shows hops
  • Uses ICMP Time to Live (TTL)
  • If stars are in output then, device used in particular hop is not configured to reply to ICMP and UDP traffic
    • does not mean that the traffic was not passed successfully
tracert <ip>
 
# check google DNS
tracert 8.8.8.8
 
# google website
tracert www.google.com

route

  • Manually manipulate the network routing tables

netsh

  • Available on Windows
  • Check the current Wifi standard
netsh wlan show interfaces

lsof

  • LiSt Open Files
  • Check the process on port
lsof -i:8080
  • Check all open ports
sudo lsof -PiTCP -sTCP:LISTEN

nmap

  • Network Mapper
  • Network exploration tool and port scanner
  • See nmap
# find live hosts in local subnet
nmap -sn 192.168.1.0/24
 
# find live hosts in local subnet when ICMP is blocked
# (usually slower)
nmap -Pn 192.168.1.0/24
 
# scan a host when ICMP is blocked
nmap -Pn 192.168.1.10
 
# find common ports on a host
nmap 192.168.1.10

nslookup

  • Query Internet name servers interactively
# --- Interactive Mode ---
nslookup
 
## Check for google.com
> google.com
Server:		10.119.64.1
Address:	10.119.64.1#53
 
Non-authoritative answer:
Name:	google.com
Address: 142.250.194.174
 
# --- Non-Interactive Mode ---
 
## Check for example.com
nslookup example.com
 
## Check for example.com on 8.8.8.8 DNS Server
nslookup example.com 8.8.8.8

ss

  • Socket Statistics
  • part of iproute2 package
  • It deprecates netstat from net-tools

netstat

  • Show network status
  • Displays the contents of various network-related data structures

ip

  • part of iproute2 package
  • It deprecates all net-tools commands
Legacy command
(net-tools)
Modern replacement
(ip)
Function
ifconfigip addr / ip linkManaging IP addresses and interfaces
routeip routeView and alter IP routing tables
arpip neighView and configure the ARP neighbor cache
iptunnelip tunnelSetting up network tunnels over IP
nameifip link set nameNaming network hardware interfaces

arp

  • Displays and modifies the Internet-to-Ethernet address translation tables (ARP Cache) used by the ARP protocol
# Show arp cache
arp -a
 
# Remove one ARP entry
arp -d 192.168.1.10
 
# clear all ARP cache entries
sudo arp -a -d

dig

  • DNS lookup tool with detailed record output
  • useful for checking specific DNS record types and DNS server responses
# A record
dig example.com
 
# MX records
dig example.com MX
 
# use specific DNS server
dig @8.8.8.8 example.com
 
# short output only
dig +short example.com

nc

  • aka netcat
  • manual TCP or UDP connectivity checks
  • useful for testing open ports and grabbing service banners
# test if TCP port is reachable
nc -vz 192.168.1.10 22
 
# scan small port range
nc -vz 192.168.1.10 20-30
 
# send raw HTTP request and read response
printf "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n" | nc example.com 80

whois

  • shows domain registration and registrar information
  • useful for ownership, registration dates, and name server checks
# domain ownership and registrar data
whois example.com
 
# IP ownership and ASN data
whois 8.8.8.8