Showing posts with label Networking. Show all posts
Showing posts with label Networking. Show all posts

ping sweep

You have a machine on the subnet for which you know the MAC address but you don't know what IP address it got after a restart, use nmap and do a ping sweep:

sudo nmap -n -sP 192.168.1.0/24 | grep "00:11:22:33:44"

-n tells nmap not to never do reverse DNS resolution on the active IP address it finds. Makes scanning faster
-sP Only perform a ping scan (host discovery) and prints the results, go no further.

Getting the VPN to work

Update: Doesn't work

-+-

After connecting to the VPN server, can't access the sites. Need to add stuff to the routing table. Wrote the bash script for that:

Soon after getting connected on VPN, do ifconfig, get the IP address associated to the ppp0 (p-t-p), specify your local router gateway and the interface you are connected through (wireless or wired) and fire the script!

#!bin/sh
# Check for command line
if [ -z "$1" ]; then
  echo "usage: ./vpn.sh [p-t-p] [GW] [Interface]"
  exit
fi

if [ -z "$2" ]; then
  echo "usage: ./vpn.sh [p-t-p] [GW] [Interface]"
  exit
fi

if [ -z "$3" ]; then
  echo "usage: ./vpn.sh [p-t-p] [GW] [Interface]"
  exit
fi

VPN_REMOTE_IP=$1
ALLTARGET="198.82.0.0/16" # All class C addresses
GATEWAY=$2
INTERFACE=$3 #eth0 or eth1

# change!
route add -host $VPN_REMOTE_IP gw $GATEWAY dev $INTERFACE
route add -net $ALLTARGET dev ppp0


Run this script as sudo!

Useful tool to analyze network traffic on Linux

Darkstat, is a simple packet sniffer, runs in the background and gives you basic information about the traffic on your network.

On Ubuntu, install it using

sudo apt-get install darkstat

After installation,

sudo darkstat -i eth0

The data is displayed in the browser (http://localhost:666/)

Linux networking commands

Some useful networking commands. (Source wimi.com). Note that you would have to run these as a root on RedHat\Fedora or using sudo on Ubuntu\Debian

Display Current Config for all NIC's: ifconfig

Display Current Config for eth0: ifconfig eth0

Assign IP:ifconfig eth0 192.168.1.2

Assign IP/Subnet: ifconfig eth0 192.168.1.2 netmask 255.255.255.0

Assign Default Gateway: route add default gw 192.168.1.1

Assign multiple IP's: ifconfig eth0:0 192.168.1.2

Assign second IP: ifconfig eth0:1 192.168.1.3

Disable network card: ifconfig eth0 down

Enable network card: ifconfig eth0 up

View current routing table: route "or" route -n

View arp cache: arp "or" arp -n

Ping: ping -c 3 192.168.1.1

Trace Route: traceroute www.whatismyip.com

Trace Path: tracepath www.whatismyip.com

DNS Test:host www.whatismyip.com

Advanced DNS Test: dig www.whatismyip.com

Reverse Lookup: host 66.11.119.69

Advanced Reverse Lookup: dig -x 66.11.119.69