Date Added: 14/01/2015

ifconfig : 

print the network interface
$ ifconfig | cut -c-10 | tr -d ' ' | tr -s '\n'  

grep ing ip address
$ ifconfig wlan0 | egrep -o "inet addr:[^ ]*" | grep -o "[0-9.]*"

192.168.0.82

host muslum21.com

nslookup muslum21.com

sembolic name for ip
# echo IP_ADDRESS symbolic_name >> /etc/hosts

route: showing routing table info

ping -c 2  muslum21.com (ctrl+C)

traceroute  muslum21.com

listing alive  machines on a network shell script 

for ip in 192.168.0.{1..255}
do
ping $ip -c 2 &> /dev/null;

if [ $? -eq 0 ];

then
echo $ip is alive
else
echo $ip is not
fi

done

parallel ping   () & () subshell wait

#!/bin/bash
#Filename: fast_ping.sh
# Change base address 192.168.0 according to your network.
for ip in 192.168.0.{1..255} ;
do
(
ping $ip -c2 &> /dev/null ;
if [ $? -eq 0 ];
then
echo $ip is alive
fi
)&
done
wait

SSH

ssh root@ip command

from local stdin to remote stdin
$ echo 'text' | ssh user@remote_host 'echo'
text

# Redirect data from file as:
$ ssh user@remote_host 'echo' < file

Transfering files through the network 

FTP, SFTP, RSYNC, SCP

lftp:
  • You can type commands in this prompt. For example:
  •  To change to a directory, use cd directory
  •  To change the directory of a local machine, use lcd
  •  To create a directory use mkdir
  •  To list files in the current directory on the remote machine, use ls
  •  To download a file, use get filename as follows: lftp username@ftphost:~> get filename
  • f To upload a file from the current directory, use put filename as follows: lftp username@ftphost:~> put filename
  • f An lftp session can be terminated by using the quit command
  • Autocompletion is supported by in the lftp prompt.
Auto-login with SSH
  • Creating the SSH key on the machine, which requires a login to a remote machine
  •  Transferring the public key generated to the remote host and appending it to ~/.ssh/authorized_keys
Mounting a Remote Drive to local mount point

# sshfs -o allow_other user@remotehost:/home/path /mnt/mountpoint
Password:

Network Traffic and port Analysis

lsof, netstats

lsof -i : In order to list all opened ports on the system along with the details on each service attached to it

netstat-tnp : Use netstat -tnp to list opened port and services as follows:

Creating arbitrary sockets

command : nc, netcat

1. Set up the listening socket using the following:
nc -l 1234
This will create a listening socket on port 1234 on the local machine.
2. Connect to the socket using the following:
nc HOST 1234
If you are running this on the same machine that the listening socket is, replace HOST
with localhost, otherwise replace it with the IP address or hostname of the machine.
3. To actually send messages, type something and press Enter on the terminal
where you performed step 2. The message will appear on the terminal where
you performed step 1

Quickly copying files over the network

We can exploit netcat and shell redirection to easily copy files over the network:
  •  On the receiver machine, run the following command: nc -l 1234 > destination_filename
  •  On the sender machine, run the following command: nc HOST 1234 < source_filename
Sharing internet connection 

basic firewall using iptables

Last Update: Posted by: müslüm ÇEN
Not Commented Yet !
Please login in order to comment . Login