Network - jasper-zanjani/dotfiles GitHub Wiki
- bmon
- brctl
- curl
- dig
- ethtool
- firewall-cmd
- host
- hping3
- ifconfig
- iftop
- ifup-wireless
- ip
- iperf
- ipset
- iscsiadm
- iw
- iwconfig
- iwlist
- kinit
- klist
- mtr
- netcat
- netplan
- netstat
- nmap
- nmblookup
- nmcli
- nmtui
- nslookup
- ping
- rfkill
- route
- sftp
- ss
- stty
- sysctl
- tcpdump
- tracepath
- tracepath6
- traceroute
- tshark
- wget
- whois
- xinetd
[ref][https://www.networkworld.com/video/99387/how-to-use-the-bmon-command-2-minute-linux-tips] [ref][https://www.networkworld.com/article/3447936/viewing-network-bandwidth-usage-with-bmon.html]
DNS lookup tool that returns the text of the actual response from the DNS server, useful when troubleshooting a DNS issue (cf. nslookup )
Nameserver
dig example.com NS
Mail server
dig example.com MX
Perform a reverse DNS lookup on an IP address
dig -x 8.8.8.8Specify an alternate DNS server to query
dig @8.8.8.8 example.comFind authoritative nameservers for the zone and display SOA records
dig +nsearch example.comLookup the IP associated with a domain name
dig +short example.comLookup the mail server IP associated with a domain name
dig +short example.com MX example.com MXPerform iterative queries and display the entire trace path to resolve a domain name
dig +trace example.comGet all types of records for a given domain name
dig example.com ANYDisplay Start of Authority information for a domain
dig example.com soaadd-port
add-service
get-active-zones
get-default-zone
get-services
list-services
new-zone
permanent
reload
remove-service
state
Successor to iptables in Red Hat, and like its predecessor a frontend to the netfilter protocols. Places network traffic into zones. Commands have to be written twice: once to affect running config and again to have the change saved
| Configuration file | Description |
|---|---|
| /etc/sysconfig/network-scripts/ifcfg-ens33 | interface settings |
| /usr/lib/firewalld/services | .xml files that define services ("ZONE=public") |
Add a new zone, and write the change to disk
firewall-cmd --new-zone=testlab --permanent
Hping3 crafts "SYN" (sequence) packets from random spoofed IP addresses and sends them out at very short intervals. [Sec+ Lab][Sec+ Lab]
| Option | POSIX option | Effect [ref][https://tools.kali.org/information-gathering/hping3] |
|---|---|---|
-i |
--interval |
wait for specified number of microseconds |
-p |
--destport |
destination port |
-q |
--quiet |
quiet |
-S |
--baseport |
base source port (default random) |
--rand-source |
random source address mode |
hping3 192.168.0.2 -p 80 -i u10 -S -q --rand-source"RX" and "TX" stand for received and transmitted.
Apply a static IP address to interface {eth0} and turn it on ("up")
ifconfig eth0 up 10.1.230.245 netmask 255.255.255.0
Bring an interface up or down
ifup eth0
ifdown eth0
ifconfig eth0 up
ifconfig eth0 down
Display details of all interfaces (even disabled)
ifconfig -aDisable eth0
ifconfig eth0 downConfigure eth0 with an additional IPv6 address
ifconfig eth0 inet6 add fdd6:551:b09e::/128Enable eth0
ifconfig eth0 upTurn network interface {eth0} on or off using ifconfig
ifconfig eth0 up
ifconfig eth0 downTurn off network interface {eth0}
ifdown eth0Bring online all interfaces marked as auto within the networking configuration
ifup -aTurn on network interface {eth0}
ifup eth0Newer alternative to the old ifconfig
ip addrShow L2 status (links)
ip linkListen for netlink messages
ip monitor Display routing information
ip routeChange the default gateway to 192.168.1.1 on eth0
ip route change default via 192.168.1.1 dev eth0Turn on interface wlp2s0
sudo ip link set wlp2s0 upA popular firewall, like firewalld, a frontend for the kernel-level netfilters service. Interface configuration, used to assign a TCP/IP configuration to a network interface, but no longer installed on modern distros.
| Config files | Description |
|---|---|
| /etc/sysconfig/iptables | location of saved config |
Display rules as written on disk
iptables --list-rulesAccept SSH traffic from a particular IP
iptables -A INPUT -p ssh -s 10.0.222.222 -j ACCEPTAccept incoming TCP traffic to port 80
iptables -A INPUT -p tcp --dport 80 -j ACCEPTReload configuration file
iptables -FShow statistics for configuration lines
iptables -vnL --linesDisplay rules as written on disk
iptables --list-rulesSet an iptable rule to accept SSH traffic from a particular IP
iptables -A INPUT -p ssh -s 10.0.222.222 -j ACCEPTSet an iptable rule to accept incoming TCP traffic to port 80
iptables -A INPUT -p tcp --dport 80 -j ACCEPTReload configuration file
iptables -FShow statistics for configuration lines
iptables -vnL --linesShow or manipulate wireless devices and their configuration; followed by dev, phy, or reg depending on the device.
Check the name of network device Fedora Docs
iw devCheck the connecdtion status of the Wi-Fi device wlp2s0
iw wlp2s0 linkThe netcat utility allows testing of a host's ports, similar to ping, but more versatile because ping only uses the portless ICMP protocol. GNU and OpenBSD versions available (itp-l+: 28)
| Option | Effect |
|---|---|
-l |
listening mode |
Connect to host on port 80
nc example.com 80
Scan ports
# Scan a single port
nc -v -w 2 z 192.168.56.1 22
# Scan multiple ports
nc -v -w 2 z 192.168.56.1 22 80
# Scan a range of ports
nc -v -w 2 z 192.168.56.1 22-25
Transfer files between servers
This example uses the pv utility to monitor progress.
# Run `nc` in listening mode (`-l` option) on port 3000
tar -zcf - debian-10.0.0-amd64-xfce-CD-1.iso | pv | nc -l -p 3000 -q 5
# On the receiving client, to obtain the file:
nc 192.168.1.4 3000 | pv | tar -zxf -
Create a command-line chat server
# Create chat server listening on port 5000
nc -l -vv -p 5000
# Launch a chat session on the other system
nc 192.168.56.1 5000
Find a service running on port
Obtain port banners (-n disables DNS lookup)
nc -v -n 192.168.56.110 80
Create stream sockets Create and listen on a UNIX-domain stream socket
nc -lU /var/tmp/mysocket &
ss -lpn | grep "/var/tmp/"
Create a backdoor
Netcat needs to listen on a chosen port (here 3001): -d disables reading from stdin; -e specifies the command to run on the target system
nc -L -p 3001 -d -e cmd.exe
Connect to {port} at {host}
nc host portNetcat command that retrieves a webpage
nc host port \getShow network traffic
netstat -anRefresh every five seconds
netstat -c5Show the current default route without performing DNS lookups on the IP addresses involved
netstat -rnCount number of TCP connections
netstat -a | grep tcp - | wc -l
Active sessions
netstat -tp
All sessions
netstat -atp
Routing table with name resolution
netstat -rn
Get the list of IPs and ports that are connected via https on your webserver every second
watch -n 1 'netstat -an | grep ":443"'
Get the total number of connections on port 80 every second
watch -n 1 'netstat -an | grep ":80" | wc -l'
Control NetworkManager and report network status
Display devices and statuses
nmcli device status
Display information on interfaces as well as status Including other network connections not managed by network manager ("unmanaged") or not connected ("unavailable")
nmcli dev status
Display what connections are enabled
nmcli general status
Display UUIDs associated with network connections
nmcli connection show --active
Display much more information on network devices
nmcli device show
Configure settings for network interface {ens01} via interactive shell
nmcli connection edit ens01List all connections NetworkManager has
nmcli connection showShow settings for network interface {ens01}
nmcli device show ens01Show status for all devices
nmcli device statusDisplay devices and status
nmcli device statusDisplay currently configured hostname
nmcli general hostnameSet hostname to {hostname}
nmcli general hostname hostnameShow overall status of NetworkManager
nmcli general statusScan hosts and ports on a network
Scan hosts from a text file
nmap -iL hosts.txtIdentify a host's operating system
nmap -A localhost.example.comDetermine whether a host has a firewall enabled
nmap -sA localhost.example.comScan a specified range of ports
nmap -p 10-300 localhost.example.comPerform a SYN TCP scan, stealthier than the TCP connect scan
nmap -sT localhost.example.comAggressive scan
nmap -A 192.168.1.0/24Ping scan home network (not bothering with ports)
nmap -sn 192.168.1.0/24Fast port scan using SYN packets
nmap -sS -F 192.168.1.0/24Port scan using SYN ("synchronize") packet, first element of TCP handshake
nmap -sS 192.168.1.0/24Port scan using normal TCP
nmap -sT 192.168.1.0/24Port scan using UDP
nmap -sU 192.168.1.0/24Xmas scan
nmap -sXScan a range of IPs [ref][Sec+ Lab]
nmap 192.168.27.0/24 > hosts.txtIdentify operating system and scan ports using TCP SYN packets [ref][Sec+ Lab]
nmap -O -sS 192.168.27.0/24 > hosts.txtPerform a DNS lookup in an interactive shell with cleaner output than dig. Enter a domain name and you get output in two sections. Retrieve IP address of {host}
nslookup hostGet IP address of a website
nslookup url
Get only nameservers
nslookup -type=ns url
Get only MX records
nslookup -type=mx url
Get Start of Authority (SOA) record
nslookup -type=soa url
Display all available records
nslookup -type=any url
Perform reverse DNS lookup on {ipaddress}
nslookup ipaddress
Specify port {portno} in the lookup
nslookup -port=portno url
Tool for enabling and disabling wireless devices
Unblock Bluetooth, if it is blocked [ref][https://computingforgeeks.com/connect-to-bluetooth-device-from-linux-terminal/]
rfkill unblock bluetoothOptions are of two kinds:
- Connection type (listening or established)
- Protocol type
Display port numbers instead of protocol names
ss -n
ss --numeric
Do name lookups and display all information
ss -an
Display all active TCP sessions
ss -atp
Display active TCP sessions
ss -tp
Display routing table (cf. ip route)
ss --route
Display programs with open ports
ss --program
Show all running servers "Tuna please"
ss -tunapl
Do name lookups and display all information
ss -an
ss --all --numericDisplay all sessions, filtering to just TCP that are actively listening
ss -atp
ss --all --tcp --processesDisplay active TCP connections
ss -tp
ss --tcp --processessysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1Re-enable IPv6 networking
sysctl -w net.ipv6.conf.all.disable_ipv6=0
sysctl -w net.ipv6.conf.default.disable_ipv6=0Inspect actual IP packets
All network data will be displayed to STDOUT
tcpdump -i eth0
Set snapshot length of capture (default 65,535B)
tcpdump -sAllow traffic associated with SSH, HTTP, and HTTP
ufw allow ssh
ufw allow http
ufw allow htts