Tuesday, May 17, 2011

Networking Commands

.dhclient eth0       active interface ‘eth0′ in dhcp mode
.ethtool eth0     show network statistics of eth0
.host www.example.com     lookup hostname to resolve name to ip address and viceversa
.hostname     show hostname of system
.ifconfig eth0     show configuration of an ethernet network card
.ifconfig eth0 192.168.1.1 netmask 255.255.255.0     configure IP Address
.ifconfig eth0 promisc     configure ‘eth0′ in promiscuous mode to gather packets (sniffing)
.ifdown eth0     disable an interface ‘eth0′
.ifup eth0     activate an interface ‘eth0′
.ip link show     show link status of all network interfaces
.iwconfig eth1     show wireless networks
.iwlist scan     wifi scanning to display the wireless connections available
.mii-tool eth0     show link status of ‘eth0′
.netstat -tup     show all active network connections and their PID
.netstat -tupl     show all network services listening on the system and their PID
.netstat -rn     show routing table alike “route -n”
.nslookup www.example.com     lookup hostname to resolve name to ip address and viceversa
.route -n     show routing table
.route add -net 0/0 gw IP_Gateway     configure default gateway
.route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1     configure static route to reach network ’192.168.0.0/16′
.route del 0/0 gw IP_gateway     remove static route
.echo “1″ > /proc/sys/net/ipv4/ip_forward     activate ip routing temporarily
.tcpdump tcp port 80     show all HTTP traffic
.whois www.example.com     lookup on Whois databas