Introduction to Networking Tools for Gnubies
By Joshua Birnbaum <Pg.2>
1. Summary: Show characteristics of all network interfaces present
on the system.
Command: netstat -ina [-i: show interfaces, -n:
don't use DNS, -a: show downed interfaces]
mir 1% netstat -ain
Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR
TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 0 1561687
0 0 0 1332073
1 0
0 BMRU
eth1 1500 0 0
0 0
0 0 0
0 0 BM
lo 16436 0 419
0 0
0 419 0
0 0 LRU
2. Summary: Identify the program (PID) that opened a given port.
1st Command: netstat -ln
[-l: show listening sockets, -n: don't use DNS]
2nd Command: netstat -lpn
[-p: show PID that opened port
[NOTE: requires root]]
3rd Command: ps -e |
grep
mir 1# netstat -ln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address
Foreign Address
State
tcp 0
0 0.0.0.0:22
0.0.0.0:*
LISTEN <ssh>
tcp 0
0 0.0.0.0:111
0.0.0.0:*
LISTEN <???>
mir 2# netstat -lnp
Active Internet connections (only servers)
tcp 0 0
0.0.0.0:111
PID TTY TIME CMD
90 ? 00:00:00 portmap
3. Summary: Take an inventory of all IP addresses in use on the network.
1st Command: ping
mir 1% ping 192.168.1.255
mir 2% arp -a
saturn.rockets.com (192.168.1.4) at 08:00:20:75:C7:0C
[ether] on eth0
atlas.rockets.com (192.168.1.2) at 08:00:69:0A:4C:42
[ether] on eth0
titan.rockets.com (192.168.1.3) at 08:00:20:81:07:33
[ether] on eth0
4. Summary: Change an IP address on a network interface.
1st Command: ifconfig <INTERFACE>
2nd Command: ifconfig
3rd Command:
mir 1# ifconfig eth0 down
mir 2# ifconfig eth0 192.168.1.10
mir 3# ifconfig eth0
[NOTE: always check your work]
eth0 Link encap:Ethernet
HWaddr 08:00:20:20:11:76
inet addr:192.168.1.10
Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING
MULTICAST MTU:1500 Metric:1
RX packets:1564440
errors:0 dropped:0 overruns:0 frame:0
TX packets:1333782
errors:1 dropped:0 overruns:0 carrier:1
collisions:14669
txqueuelen:1000
RX bytes:735535580
(701.4 MiB) TX bytes:363638832 (346.7 MiB)
Interrupt:38
5. Summary: Check if any interfaces are in promiscuous mode - if so,
shut them down.
Command: ifchk -d [-d: shut down promiscuous interfaces
[NOTE: requires root]]
mir 2# ifchk -d
interface(s): 3
lo: normal
eth0: PROMISC [*] <--- promisc interface eth0
was shut down
eth1: *down*
6. Summary: Configure a default route for the system.
1st Command:
2nd Command: netstat -r [-r: display the system routing
table]
mir 1# route add default gw 192.168.1.1
mir 2# netstat -r
[NOTE: always check your work]
Kernel IP routing table
Destination Gateway
Genmask Flags MSS
Window irtt Iface
192.168.1.0 *
255.255.255.0 U
40 0 0 eth0
127.0.0.0 *
255.0.0.0
U 40 0
0 lo
default 192.168.1.1
0.0.0.0 UG
40 0 0 eth0
<< PG.1 << | About | Contact | FAQ | Publications | Resume | Software | Speaking | Noorg
Copyright © 1998-2008 Noorg, Inc.
All Rights Reserved.