Network utils

From Wikitech
Jump to: navigation, search

here's some useful stuff i use to diagnose network problems:

  • IP addresses
[root@ariel root]# ip addr
1: lo: <LOOPBACK,UP> mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
4: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:50:45:5b:d0:8c brd ff:ff:ff:ff:ff:ff
    inet 207.142.131.244/26 brd 207.142.131.255 scope global eth0
    inet6 2001:470:1f01:367:250:45ff:fe5b:d08c/64 scope global deprecated dynamic
       valid_lft 1897645sec preferred_lft -89555sec
    inet6 fe80::250:45ff:fe5b:d08c/64 scope link
       valid_lft forever preferred_lft forever
5: eth1: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:50:45:5b:d0:8d brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.2/16 brd 10.0.255.255 scope global eth1
    inet6 fe80::250:45ff:fe5b:d08d/64 scope link
       valid_lft forever preferred_lft forever
6: sit0: <NOARP> mtu 1480 qdisc noop
    link/sit 0.0.0.0 brd 0.0.0.0

iproute2 is much better than ifconfig; example:

ip addr add 10.0.0.3 dev eth0
....
ip addr del 10.0.0.3 dev eth0

with no need for eth0:X virtual interfaces

ip route add default via 10.0.0.4
  • packet sniffing; tcpdump:
tcpdump -s 1520 -lni eth0 host bacon and port not 22

(exclude port 22 to avoid seeing your own traffic)

  • or tethereal (nicer for some things, can decode http requests, mysql data streams etc):
tethereal -s 1520 -ni eth0 host bacon and port not 22
  • arping: like ping but uses ARP instead of ICMP (gets through firewall on the LAN)