====== Commonly Used Network Commands / Tools ====== ===== Define DNS Servers ===== Add/update DNS Server configurations in /etc/resolv.conf in the format ''nameserver '', 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) netstat -pnutl netstat -pnutl | grep :80 Processes PID that opened tcp port 80 (run as root): fuser 80/tcp fuser -u -v 80/tcp Sample output: 80/tcp: 1741 7842 11760 14459 Process name associated with PID # ls -l /proc/1741/exe ===== Display Network Interface Statistics ===== netstat -i ===== Create a LISTEN address ===== nc Command to Create a service using bash script (to listen on port 8444 for example) nc -k -l 8444 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. echo "test-hello" | nc 8444 ===== Find systems without ping ===== Some servers/devices have ping (ICMP) disabled. In that case use arping to find them. Example use below. arping -c1 -f -w1 192.168.1.1 ==== arping usage help ==== 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 ===== Find open ports ===== nmap can be used to find open ports. Simple example below: nmap 192.168.1.1 Also ''nc'' can be used to find if a port is open nc -zv 192.168.1.100 80 On Windows PowerShell Test-NetConnection -ComputerName 192.168.1.21 -Port 22