Networking Flashcards
Show devices set on a system
nmcli dev show
Show network configuration settings on a system
nmcli con show
Turn off the connection
nmcli con down “Wired conn” [name of conn, ex- eth0]
Delete connection
nmcli con del “wired conn” [name of connection, ex eth0]
Check status of network devices
nmcli dev status
Show specified network device details
nmcli dev show eth0
Add new connection
nmcli con add con-name “backup” type ethernet ip4 192.168.0.122/24 gw4 192.168.0.1 ifname eth0 auroconnect
Edit current connection
nmcli con edit (which will prompt you for each setting and here you can enter in
each item based on the list printed out)
Add dns value for specified connection
nmcli con mod eth0 ipv4.dns “192.168.0.2”
Show dns field for specified connection
nmcli -f ipv4.dns con show backup/eth0
Display ip-address info
ip addr show
Display routing table
ip route show
Add/delete ip-address to specified interface
ip addr add/del 192.168.0.100/24 dev eth0
Show ip-address for specified interface
ip addr show eth0
ip addr show dev eth0
Switch on/off ip link
ip link set eth0 up/down
Add/delete route
ip route add/del default via 192.168.1.2 dev eth0
ip route add/del 10.10.0.0/16 via 192.168.1.2 dev eth0
Set host name for the system
hostnamectl set-hostname “CetnosWK”
Get hostname
hostname
Legacy networking tools- need to install package
yum install net-tools
Legacy: ip info details of configured interfaces
ifconfig
Legacy: change ip adress
ifconfig eth0 192.168.0.3 ifconfig eth0 (to show it's been change)
Legacy: turn on/off network interface
ifup/ifdown eth0
Legacy: print routing table
print routing table with ip-addresses rather than names, so destination instead of default will be shown as 0.0.0.0
route
route -n
Legacy: delete default route
route del default
Legacy: add default route
route add default gw 192.168.0.1
Legacy: add new route
route add -net 192.168.10.0 netmask 255.255.255.0 gw 192.168.0.1 dev eth0
Test availability of destination host
Test the same but with specified number of packets
Test the same using ipv4 proto
Test the same using ipv6 proto
ping 192.168.0.35
ping -c 10 192.168.0.35
ping -4 -c 10 198.168.0.35
ping -6 -c 10 ::1 or ping6 -c 10 ::1
Display all hops a packet will traverse to get the destination
The same but instead of using icmp use tcp packets
The same but using ipv6 proto
traceroute google.com
traceroute -T 8.8.8.8
traceroute -6 ::1/ traceroute6 ::1
Display all hops a packet will traverse to get the destination using UDP instead of icmp by default
tracepath google.com
Display network connections and their state on the system (now deprecated and need to install net-tools to use this)
netstat
Display network status and states listening on tcp, udp protos
Display the same and show process id listening on these ports
Display routing table
Display all listening and non-listening sockets , show numerical addr instead symbolic host
netstat -tul
netstat -tulp
netstat -r
netstat -an
Modern tool to display network status and states
ss
P.S. (no support to show routing table i.e. -r switch)
File contains host entries with ip-names mappings including where localhost IP is
/etc/hosts
File contains hostname of the system
this file is updated by hostnamectl
/etc/hostname
File contains DNS server ip
/etc/resolv.conf
Database file of name switch service conf file, to determine the sources from which to obtain ns info in range of categories, and in what order
/etc/nsswitch.conf
example of output
hosts: files DNS
The first thing to check will be files (/etc/hosts, /etc/hostname), then DNS (/etc/resolv.conf)
Simple DNS lookup
host (need to install bind-utils first)
host google.com
DNS lookup including types of DNS records
Lookup using specified DNS server
Lookup for specific record type
dig google.com
dig @8.8.8.8 reddit.com
dig -t MX google.com
dig @8.8.8.8 -t any google.com
Directly query /etc/nsswitch.conf for records
getent hosts
Network bonding (teaming) Network bridging
- Config that treats 2+ network interfaces as a single one
- Combines 2+ networks into a new logical network. Often used in virtualization, where the guest’s network communicates on the same network as the host system
- 1.install bridge-utils
- create bridge interface: brctl addbr br0
- add nic to bridge: brctl addif br0 veth0
- 4 check status: brctl show
Bonding modes
Mode=1 active-backup
sets all nics to backup state while one remains active
Mode=2 XOR policy
selects nic based on XOR operation
Mode=4 IEEE 802.3ad policy
creates aggregation teaming
Mode=5 adaptive transmit load balancing policy
ensures outgoing traffic distribution according to the load of each nic
List ethernet nics using pci
lspci | grep ethernet
Network port scanner
nmap -p 1-1023 -sV -sS -T4 192.168.1.1
nmap -A -T4 scanme.nmap.org
sV -probe open ports for service/version info
sS- TCP SYN, sT- connect, sA- ACK, sW -window, sU- UDP scan, sF -FYN, T4 -for faster execution
-A-to check OS and version detection, open ports etc
Utility for reading from and writing to network connections using TCP or UDP
netcat
on server (192.168.0.1) side: nc -l -p 1234
on client side: nc 192.168.0.1. 1234
on client side: nc -zv 192.168.0.1 20-80
z -report connection status (53- connection succeded, 24- connection refused etc)
CLI component of wireshark
tshark
Very common utility to sniff traffic similar to tshark
tcpdump
Show arp table
arp -n (show in numeric instead of symbolic names)
arp -d address - delete entry
arp -s address hw_address -set up a new table entry
Display bandwidth usage
iftop
iftop -i _if_name (listen on interface)
Measurement tool for tcp/udp bandwidth performance
iperf3
Network diagnostic tool, which
updates network status in real-time
Combines functionality of traceroute and ping
mtr google.com
mtr -r google.com -display only final report, will not be updated in real-time
Whois lookup, requests whois directory service
whois google.com