User Tools

Site Tools


linux:linux-commands:networking

Networking Commands

Transfer files with low bandwidth

Transfer large files/directories with no overhead, over the network

# ssh user@host "cd targetdir; tar cfp - *" | dd of=file.tar

Identify Network Cards

Causes traffic lights to flash on the nic

# ethtool -p ethX

Watch Data output

Watch Data Usage on eth0

# watch ifconfig eth0

Show Open Ports

netcat as a portscanner. Show open ports.

# nc -v -n -z -w 1 127.0.0.1 22-1000

Show Listening ports

Lists all listening ports together with the PID of the associated process

# netstat -tlnp

Show activity on a port

what's running on a given port on your machine

# lsof -i -n -P | grep :22

SSH Tunnel

Start a tunnel from some machine's port 80 to your local post 2001

now you can access the website by going to http://localhost:2001/

# ssh -N -L2001:localhost:80 somemachine

SSH Tunnel via ...

If you want to connect to server behind the DMZ, you can use a intermediate. This is useful where your have your local machine outside a firewall; a visible machine on the DMZ; and a third machine invisible to the outside.

# ssh -f -N -q -L 80:192.168.1.69:80 username@dmz.example.com

The params explaination:

  • -f tells ssh to go into the background (daemonize).
  • -N tells ssh that you don't want to run a remote command (that is, you only want to forward ports)
  • -q tells ssh to be quiet
  • -L specifies the port forwarding
linux/linux-commands/networking.txt · Last modified: by 127.0.0.1