
Terminal - Commands tagged networking - 23 results
watch "lsof -i -P |grep ESTABLISHED |awk '{printf \"%15.15s \\t%s\\n\", \$1, \$9}'"
This is sample output - yours may be different.
Finder localhost:53255->localhost:26172
imagent mycomputer.foo.com:59319->qa-in-f125.1e100.net:5223
imagent mycomputer.foo.com:59339->bos-m015c-new-rdr2.blue.aol.com:443
Google mycomputer.foo.com:58776->qc-in-f125.1e100.net:5222
Google mycomputer.foo.com:60731->qa-in-f125.1e100.net:5222
Google mycomputer.foo.com:60858->qc-in-f125.1e100.net:5222
Google mycomputer.foo.com:60982->qc-in-f125.1e10
Shows which applications are making connections, and the addresses they're connecting to. Refreshes every 2 seconds (watch's default). Test on OSX, should work anywhere watch and lsof work.
This is sample output - yours may be different.
Simple way to test if a port is available to the public. Run this command on the "server" and run a `telnet host-ip port-number` on the client. Test by sending strings to the server, which will be displayed in the server terminal.
/sbin/ifenslave -c bond0 eth1
This is sample output - yours may be different.
This forces a bonded interface to switch to another slave in the bond as its active slave.
This is sample output - yours may be different.
$ ping 0
PING 0 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.497 ms
$ telnet 0 22
Trying 0.0.0.0...
Connected to 0 (0.0.0.0).
Escape character is '^]'.
SSH-2.0-OpenSSH_4.3
Super fast way to ftp/telnet/netcat/ssh/ping your loopback address for testing. The default route 0.0.0.0 is simply reduced to 0.
This is sample output - yours may be different.
Disabling an interface's multicast filter is like disabling IGMP snooping on a switch. It is useful for testing and troubleshooting.
tcpdump -w - |pv -bert >/dev/null
This is sample output - yours may be different.
# tcpdump -w - |pv -bert >/dev/null
tcpdump: listening on wlan0, link-type EN10MB (Ethernet), capture size 65535 bytes
756kB 0:00:12 [67.5kB/s]
Real gurus don't need fancy tools like iftop or jnettop.
nmap -v -sT 192.168.0.0/24
This is sample output - yours may be different.
Scanning 192.168.1.55 [1000 ports]
Discovered open port 22/tcp on 192.168.1.55
Discovered open port 80/tcp on 192.168.1.55
Discovered open port 21/tcp on 192.168.1.55
Completed Connect Scan at 12:35, 1.39s elapsed (1000 total ports)
Nmap scan report for 192.168.1.55
Host is up (0.013s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
80/tcp open http
MAC Address: 00:1B:2F:2C:53:F4 (Netgear)
TCP Connect scanning for localhost and network 192.168.0.0/24
This is sample output - yours may be different.
apache2 14485 www-data 8u IPv4 186095222 0t0 TCP *:443 (LISTEN)
apache2 14770 www-data 4u IPv4 186095213 0t0 TCP *:80 (LISTEN)
This option is much faster, as it checks only network nodes.
This is sample output - yours may be different.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
dhclient3 817 root 5u IPv4 3745 0t0 UDP *:bootpc
sshd 1014 root 3u IPv4 4770 0t0 TCP *:ssh (LISTEN)
sshd 1014 root 4u IPv6 4772 0t0 TCP *:ssh (LISTEN)
postgres 1117 postgres 3u IPv6 5608 0t0 TCP localhost:7175 (LISTEN)
postgres 1117 postgres 4u IPv4 5609 0t0 TCP localhost:7175 (LISTEN)
postgres 1117 postgres 6u IPv6 5622 0t0 UDP localhost:56982->localhost:56982
postgres 1487 postgres 6u IPv6 5622 0t0 UDP localhost:56982->localhost:56982
postgres 1488 postgres 6u IPv6 5622 0t0 UDP localhost:56982->localhost:56982
postgres 1489 postgres 6u IPv6 5622 0t0 UDP localhost:56982->localhost:56982
postgres 1490 postgres 6u IPv6 5622 0t0 UDP localhost:56982->localhost:56982
cupsd 1539 root 5u IPv6 5710 0t0 TCP localhost:ipp (LISTEN)
cupsd 1539 root 6u IPv4 5711 0t0 TCP localhost:ipp (LISTEN)
sshd 27689 root 3r IPv4 80824 0t0 TCP 172.16.221.137:ssh->vayu:59742 (ESTABLISHED)
sshd 27689 root 8u IPv6 80950 0t0 TCP localhost:6010 (LISTEN)
sshd 27689 root 9u IPv4 80951 0t0 TCP localhost:6010 (LISTEN)
This option selects the listing of all Internet and x.25 (HP-UX) network files.
This is sample output - yours may be different.
Proto Recv-Q Send-Q Adresse locale Adresse distante Etat PID/Program name
tcp 0 0 0.0.0.0:8118 0.0.0.0:* LISTEN 1284/privoxy
tcp 0 0 0.0.0.0:4001 0.0.0.0:* LISTEN 1901/java
tcp 0 0 0.0.0.0:7175 0.0.0.0:* LISTEN 1546/postgres
udp 0 0 0.0.0.0:68 0.0.0.0:* 2028/dhclient
udp 0 0 0.0.0.0:5353 0.0.0.0:* 1394/avahi-daemon:
udp 0 0 0.0.0.0:46876 0.0.0.0:* 1394/avahi-daemon:
udp6 0 0 :::58041 :::* 1394/avahi-daemon:
udp6 0 0 :::5353 :::* 1394/avahi-daemon:
Check open TCP and UDP ports
This is sample output - yours may be different.
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 13443/apache2
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 801/sshd
tcp6 0 0 :::25565 :::* LISTEN 1249/java
tcp6 0 0 :::6667 :::* LISTEN 12101/bitlbee
tcp6 0 0 :::22 :::* LISTEN 801/sshd
While `lsof` will work, why not use the tool designed explicitly for this job?
(If not run as root, you will only see the names of PID you own)
This is sample output - yours may be different.
This is sample output - yours may be different.
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:6012 0.0.0.0:* LISTEN -
tcp 0 0 :::111 :::* LISTEN -
tcp 0 0 :::5556 :::* LISTEN 20921/java
tcp 0 0 :::22 :::* LISTEN -
tcp 0 0 ::1:631 :::* LISTEN -
tcp 0 0 127.0.0.2:7001 :::* LISTEN 20842/java
tcp 0 0 127.0.0.1:7001 :::* LISTEN 20842/java
tcp 0 0 10.249.135.171:7001 :::* LISTEN 20842/java
tcp 0 0 ::1:7001 :::* LISTEN 20842/java
tcp 0 0 fe80::7a2b:cbff:fe:7001 :::* LISTEN 20842/java
tcp 0 0 ::1:25 :::* LISTEN -
tcp 0 0 ::1:6010 :::* LISTEN -
tcp 0 0 ::1:6011 :::* LISTEN -
tcp 0 0 ::1:6012 :::* LISTEN -
udp 0 0 0.0.0.0:111 0.0.0.0:* -
udp 0 0 0.0.0.0:631 0.0.0.0:* -
udp 0 0 0.0.0.0:670 0.0.0.0:* -
udp 0 0 0.0.0.0:26791 0.0.0.0:* -
udp 0 0 0.0.0.0:5353 0.0.0.0:* -
udp 0 0 0.0.0.0:39640 0.0.0.0:* -
udp 0 0 :::111 :::* -
udp 0 0 :::546 :::* -
udp 0 0 :::670 :::* -
udp 0 0 :::43339 :::* -
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:6012 0.0.0.0:* LISTEN -
tcp 0 0 :::111 :::* LISTEN -
tcp 0 0 :::5556 :::* LISTEN 20921/java
tcp 0 0 :::22 :::* LISTEN -
tcp 0 0 ::1:631 :::* LISTEN -
tcp 0 0 127.0.0.2:7001 :::* LISTEN 20842/java
tcp 0 0 127.0.0.1:7001 :::* LISTEN 20842/java
tcp 0 0 10.249.135.171:7001 :::* LISTEN 20842/java
tcp 0 0 ::1:7001 :::* LISTEN 20842/java
tcp 0 0 fe80::7a2b:cbff:fe:7001 :::* LISTEN 20842/java
tcp 0 0 ::1:25 :::* LISTEN -
tcp 0 0 ::1:6010 :::* LISTEN -
tcp 0 0 ::1:6011 :::* LISTEN -
tcp 0 0 ::1:6012 :::* LISTEN -
udp 0 0 0.0.0.0:111 0.0.0.0:* -
udp 0 0 0.0.0.0:631 0.0.0.0:* -
udp 0 0 0.0.0.0:670 0.0.0.0:* -
udp 0 0 0.0.0.0:26791 0.0.0.0:* -
udp 0 0 0.0.0.0:5353 0.0.0.0:* -
udp 0 0 0.0.0.0:39640 0.0.0.0:* -
udp 0 0 :::111 :::* -
udp 0 0 :::546 :::* -
udp 0 0 :::670 :::* -
udp 0 0 :::43339 :::* -
shows opened ports on machine in continuous mode (refreshing every 10 sec)
curl -s http://standards.ieee.org/regauth/oui/oui.txt | grep $1
This is sample output - yours may be different.
ping -I eth0 www.yahoo.com
This is sample output - yours may be different.
PING any-fp.wa1.b.yahoo.com (69.147.125.65) from <IP> eth0: 56(84) bytes of data.
This command only check the network connection from given eth. This is very useful if you are using more then one interface in your server or laptop.
python -c "import platform; print platform.node()"
This is sample output - yours may be different.
brian.intranet.example.com
tcpdump -i any -n tcp[13] == 2
This is sample output - yours may be different.
This is sample output - yours may be different.
ifconfig eth1 | grep inet\ addr | awk '{print $2}' | cut -d: -f2 | sed s/^/eth1:\ /g
This is sample output - yours may be different.
Sometimes, you don't really care about all the other information that ifconfig spits at you (however useful it may otherwise be). You just want an IP. This strips out all the crap and gives you exactly what you want.
python -c 'import socket; s = socket.socket(socket.AF_INET, socket.SOCK_STREAM); s.connect(("<hostname>", <port>)); print s.getsockname()[0] ; s.close() ;' 2> /dev/null
This is sample output - yours may be different.
$ python -c 'import socket; s = socket.socket(socket.AF_INET, socket.SOCK_STREAM); s.connect(("www.google.com", 80)); print s.getsockname()[0] ; s.close() ;' 2> /dev/null
192.168.26.198
on multihomed hosts, connected to several networks, could be usefull to know the source address (local ip address) used to reach the target host, this command does not require root priviledges.
The command use a TCP socket, if there is any error the command return an empty string, elsewhere return a valid ip address.
This is sample output - yours may be different.
$ netstat -ltun
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:60454 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:51413 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp6 0 0 :::51413 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
udp 0 0 0.0.0.0:45378 0.0.0.0:*
udp 0 0 0.0.0.0:68 0.0.0.0:*
udp 0 0 192.168.168.192:21328 0.0.0.0:*
udp 0 0 0.0.0.0:5353 0.0.0.0:*
udp 0 0 192.168.168.192:1900 0.0.0.0:*
Works only on Linux.
Last option (n) turn name of service resolving (/etc/services) off.
This is sample output - yours may be different.
sudo /usr/sbin/ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised auto-negotiation: Yes
Speed: Unknown! (65535)
Duplex: Unknown! (255)
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: g
Current message level: 0x000000ff (255)
Link detected: no
This is an commandline utility to get fair piece of information about the attached network card.
while true; do clear; nmap ${hostname} -PN -p ${hostport}; sleep 5; done
This is sample output - yours may be different.
Starting Nmap 4.76 ( http://nmap.org ) at 2009-08-14 22:14 CEST
Interesting ports on 192.168.0.1:
PORT STATE SERVICE
80/tcp open http
the command for the impatient sysadmin: simply checks every five secs, if a host or a specific service running on it is up. ideal for hosts that are configured not to respond on pings.