Linux Basic Networking
Linux 'Piping'
Check which applications listen on which ports and filter with grep
netstat -tulpn | grep <tcp port number>
Check if port 8080 is open
netstat -tap | grep 8080
Traceroute to specific TCP port - <"traceroute" + -p (port) + "TCP port number" + target host, dotted decimal>
sudo traceroute -p 9100
Allow blocked traffic on Linux Firewall (iptables)
sudo vi /etc/sysconfig/iptables.cust
Add the allowed subnet
sudo /usr/remote/odutils/stop-maintenance.sh
Check Printer
ping XX.XX.XX.XX
telnet XX.XX.XX.XX 9100/515
lpstat –s | grep XX.XX.XX.XX
tcpdump UAP RSF - [ Hint: An anagram for the TCP flags: Unskilled Attackers Pester Real Security Folk ]
Show me all URGENT (URG) packets...
tcpdump 'tcp[13] & 32 != 0'
Show me all ACKNOWLEDGE (ACK) packets...
tcpdump 'tcp[13] & 16 != 0'
Show me all PUSH (PSH) packets...
tcpdump 'tcp[13] & 8 != 0'
Show me all RESET (RST) packets...
tcpdump 'tcp[13] & 4 != 0'
Show me all SYNCHRONIZE (SYN) packets...
tcpdump 'tcp[13] & 2 != 0'
Show me all FINISH (FIN) packets...
tcpdump 'tcp[13] & 1 != 0'
tcpdump 'tcp[13] = 18'
Note: Only the PSH, RST, SYN, and FIN flags are displayed in tcpdump's flag field output. URGs and ACKs are displayed, but they are shown elsewhere in the output rather than in the flags field
Temporary routes Add, why temporary? Upon server reboot, routing table should be re-built
sudo ip route add via
sudo /sbin/route add –net X.X.X.X netmask 255.X.X.X gw Y.Y.Y.Y
sudo /sbin/route add -net netmask gw && sudo /sbin/route add -net netmask gw
Temporary routes Delete
sudo /sbin/route del –net X.X.X.X netmask 255.X.X.X gw Y.Y.Y.Y
Permanent Route editing with VI
sudo vi /etc/sysconfig/network-scripts/route-eth0
#Press (i)nsert
#Example route below <network id + '/' + cidr + 'via' + gateway ipv4 address> via via
#Press (esc)ape
#Save (wq!)
Restart network process
sudo /sbin/service network restart
Show routing table & open interface Route-Eth0 routes file
netstat -rn && sudo vi /etc/sysconfig/network-scripts/route-eth1
Specific to RHEL7
Restart network service using SYSTEMCTL; PING to host on defined subnet using range {1...(1+n)}
sudo systemctl restart network && netstat -rn && sudo tcpdump host && for i in {1..254}; do ping -c 5 192.168.1.$i | grep '1'; done
Specific to RHEL6
Restart network service using /sbin/service network + show routing table + PING host(s) within subnet - TESTING
sudo /sbin/service network restart && netstat -rn && for i in {1..254}; do ping -c 1 192.168.1.$i | grep '1'; done && sudo tcpdump host 192.168.1 -nvv
Testing - PING host(s) within subnet
for i in {1..254}; do ping -c 1 192.17.254.$i | grep '1'; done
Ping sweep and output only live hosts
for i in {1..255}; do ping -c 1 192.168.1.$i | grep "64 bytes from" | cut -d " " -f 4 | sed 's/.$//'; done
My Traceroute, -r for outputing the results on the terminal;
sudo mtr -r -c 5 --no-dns | grep "." | cut -d " " -f 4
My traceroute and PING test
sudo mtr -r -c 5 && sudo mtr -r -c 5 && for i in {1..254}; do ping -c 5 192.168.1.$i | grep '1'; done
For loop with mtr - For i in range 160-190 runs a mytraceroute to specified #X.X.X.$i IP address (no DNS resolution flag); greps prints the lines that #contain a "." (such as #ones with dotted decimal IP addresses); cut -d uses #space as delimiter ; done completes the loop. Useful for checking routing path in a whole subnet
for i in {160..190}; do sudo mtr -r -c 5 100.65.150.$i --no-dns | grep "." | cut -d " " -f 4; done
Copy link