Networking basics
This post shows some basics of networking
Basic
Firstly, review the 7 layers of the OSI model:
- Physical: coax, fiber, wireless, hub, repeater
- Data link: ethernet, ppp, switch, bridge, arp
- Network: ip, ICMP, router
- Transport: TCP, UDP
- Session: API, socket, sock
- Presentation: SSL, SSH, IMAP, FTP
- 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 interfaceip l set <interface> up
: plug the interface in. Replaceup
withdown
to plug outip -br l show
: show brieflyip -s l show
: show with statisticethtool <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 tableip n delete <ip> dev <interface>
: delete arp entry
Ip address command
ip -br a show
: show all ip addressesip r show
: show all default gateway (router) addresses
Network manipulation
To create a network device and connect its slaves
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