Networking 102
Linux SysAdmin DeCal Fall 2018
Abizer Lokhandwala
Overview
OSI Model
or CS 168 in 10 minutes
Conceptual Model of Network Architecture
Conceptual Model: OSI
OSI Layers - Metal
OSI Layers - Kernel
OSI Layers - Application
Layers and tools available at each
Layer 2: link layer network interface
Network Interface Card or NIC
* or virtual
ip link
MAC address
maximum transmission unit size
UP: logical interface is enabled in kernel
LOWER_UP: physical interface on, cable plugged in, L2 works
MAC Addresses and ARP
ARP subsystem
$ arp - look at entries in the system’s ARP table (or $ ip neigh)
useful commands: arp -e to show entries, arp -d to delete entries, arp -s to add new static entries
data actually in /proc/net/arp, /etc/ethers for static assignments
Interface Configuration
$ ip link - manage interfaces at L2
$ ip link set <iface> [up|down] - enable/disable logical interface
$ ip link [add|delete] <iface> type [type] - add/remove interfaces themselves, e.g. bridge or vlan virtual devices
static configuration (on Debian) lives in /etc/network/interfaces
/etc/network/interfaces
Layer 3: logical network layer
IP Addresses
Managing L3 Addresses
$ ip addr [iface] - show all L3 info / on a specific iface
$ ip addr [add|del] addr/mask dev iface - add/delete an address to an interface
$ ip [-6] route - show routing table
$ ip [-6] route [add|del|replace] [default] via [address] [dev] dev -� add/remove routes to kernel routing table
CIDR walkthrough
Host Bits
Network Prefix
Dynamic Host Configuration Protocol
DHCP Tools
$ dhcpcd <iface> (IPv4 and IPv6)
$ dhclient [-4|-6] iface (deprecated, but still useful in specific cases)
dhcpcd starts a daemon that will attempt to renew leases, so in order to re-dhcp, the daemon needs to be restarted or reloaded
Domain Name System
DNS Records
DNS Tools
$ dig <domain>
$ host <domain>
--
$ rndc reload (reload bind9 zones)
$ nscd -i hosts (flush local DNS cache)
DNS files
Layer 4 - Transport
Transmission Control Protocol
User Datagram Protocol
Ports and Sockets
/proc/net
/proc/sys/net
/proc/sys/net/core
/proc/sys/net/ipv4
/proc/sys/net/ipv4
Common Tools
host(name) - get DNS info (simple)�ping - see connectivity/latency info�traceroute / mtr - see network path to dest.�arp - view L2/L3 address table�dig / drill - get more detailed DNS info�ip - base of iproute2, complete management of networking subsystems in Linux�netstat / ss - inspect active sockets on system�nc - netcat, simple TCP/UDP client/server
curl / wget - versatile L7 network interaction�iptables - stateful firewall and packet inspection, routing, forwarding (pretty complicated)�ufw - easier-to-use wrapper around iptables�tcpdump - literally dump all packets on an interface
ping
RTT = Round Trip Time
traceroute
Print the route that a packet takes to the destination
Details of the number of routers, i.e. 'hops', in the packet path.
How many router hops away is death from supernova? Hint: They are both on the same network (OCF)
0
mtr
combination of ping and traceroute, live, very useful for testing
iproute2
demo:
Iptables
Questions?