Networking basics

Networking basics

This post shows some basics of networking


Firstly, review the 7 layers of the OSI model:

  1. Physical: coax, fiber, wireless, hub, repeater
  2. Data link: ethernet, ppp, switch, bridge, arp
  3. Network: ip, ICMP, router
  4. Transport: TCP, UDP
  5. Session: API, socket, sock
  6. Presentation: SSL, SSH, IMAP, FTP
  7. Application: HTTP, FTP, IRC, SSH, DNS

Useful commands

  • ip <sub>, this is a new tool which was invented to replace ifconfig, arp, route, netstat
  • ndp
  • iptables, ufw
  • nc, telnet
  • lsof | grep :8080
  • curl, wget
  • ping
  • iperf
  • tcpdump, tcptrack
  • traceroute, tracepath, tracert, traceroute6
  • nslookup, dig, nmap, whois (dig ns, dig +track)
  • host, hostname
  • iwconfig
  • nmcli
  • ethtool

Practical commands with flags

Ip link commands

  • ip l show: show all physical interface
  • ip l set <interface> up: plug the interface in. Replace up with down to plug out
  • ip -br l show: show briefly
  • ip -s l show: show with statistic
  • ethtool <interface>: diagnostics tool for the network interface. Especially, check the "Speed" section to see whether it matches the designed speed

Ip network (neighbor, i.e. arp) command

  • ip n show: show arp table
  • ip n delete <ip> dev <interface>: delete arp entry

Ip address command

  • ip -br a show: show all ip addresses
  • ip r show: show all default gateway (router) addresses

Network manipulation

To create a network device and connect its slaves

ip l add br-name type bridge
ip l set <interface> master br-name

This command creates a new bridge device named br-name and connect <interface> as its slave.

To remove the salve ip l set <interface> nomaster

To remove the bridge network ip l delete br-name type bridge

Buy Me A Coffee