Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tech:linux:useful_network_tools [2019/10/30 06:27]
tech:linux:useful_network_tools [2019/10/30 06:27] (current)
Line 1: Line 1:
 +====== Commonly Used Network Commands / Tools ======
 +===== Define DNS Servers =====
 +Add/update DNS Server configurations in /​etc/​resolv.conf in the format ''​nameserver <​IP-Address>'',​ one for each line.  The /​etc/​resolve.conf file //does// get overwritten each time the system is rebooted. ​ In Ububtu the /​etc/​resolvconf/​resolv.conf.d/​head is the source file and updating it keeps the changes permanent. ​ In distros (such as Redhat) you can make the /​etc/​resolv.conf file read-only by ''​chattr +i /​etc/​resolv.conf''​. ​ Use the ''​-i''​ option to make the file read-write again. ​ By default, the default gateway resolves DNS.
 +
 +===== LISTEN address list =====
 +netstat Command to list LISTEN addresses (listening ports)
 +<code bash>
 +netstat -pnutl
 +netstat -pnutl | grep :80
 +</​code>​
 +
 +
 +Processes PID that opened tcp port 80 (run as root):
 +<code bash>
 +fuser 80/tcp
 +fuser -u -v 80/tcp
 +</​code>​
 +Sample output:
 +<​code>​
 +80/​tcp: ​              ​1741 ​ 7842 11760 14459
 +</​code>​
 +
 +Process name associated with PID #
 +<code bash>ls -l /​proc/​1741/​exe</​code>​
 +
 +===== Display Network Interface Statistics =====
 +<code bash>
 +netstat -i
 +</​code>​
 +
 +===== Create a LISTEN address =====
 +nc Command to Create a service using bash script (to listen on port 8444 for example)
 +<code bash>
 +nc -k -l 8444
 +</​code>​
 +Keywords: Listener socket server bash bind TCP netcat\\
 +Resources: [[http://​stackoverflow.com/​questions/​4739196/​simple-socket-server-in-bash|Simple Socket Server in Bash]]
 +
 +
 +===== To send to a LISTEN address =====
 +Target IP is the IP address of the server running ''​nc -k -l 8444''​ and waiting on requests.
 +<code bash>
 +echo "​test-hello"​ | nc <​target-ip>​ 8444
 +</​code>​
 +
 +
 +===== Find systems without ping =====
 +Some servers/​devices have ping (ICMP) disabled. In that case use arping to find them. Example use below.
 +<code bash>
 +arping -c1 -f -w1 192.168.1.1
 +</​code>​
 +==== arping usage help ====
 +<​code>​
 +Usage: arping [-fqbDUAV] [-c count] [-w timeout] [-I device] [-s source] destination
 +  -f : quit on first reply
 +  -q : be quiet
 +  -b : keep broadcasting,​ don't go unicast
 +  -D : duplicate address detection mode
 +  -U : Unsolicited ARP mode, update your neighbours
 +  -A : ARP answer mode, update your neighbours
 +  -V : print version and exit
 +  -c count : how many packets to send
 +  -w timeout : how long to wait for a reply
 +  -I device : which ethernet device to use (eth0)
 +  -s source : source ip address
 +  destination : ask for what ip address
 +</​code>​
 +
 +===== Find open ports =====
 +nmap can be used to find open ports. ​ Simple example below:
 +<code bash>
 +nmap 192.168.1.1
 +</​code>​
 +
 +Also ''​nc''​ can be used to find if a port is open
 +<​code>​
 +nc -zv 192.168.1.100 80
 +</​code>​
 +
 +On Windows
 +<code bat>
 +PowerShell
 +Test-NetConnection -ComputerName 192.168.1.21 -Port 22
 +</​code>​
  

QR Code
QR Code tech:linux:useful_network_tools (generated for current page)