Tuesday, May 17, 2011

More linux networking commands


Ethtool managages ethernet card settings
Ethtool lets you view and change many different settings for ethernet adapters (which does not include Wi-Fi cards). You can manage many different advanced settings, including tx/rx, checksumming, and wake-on-LAN settings. However, here are more basic commands you might be interested in:
Display the driver information for a specific network adapter, great when checking for software compatibility:
ethtool -i
Initiate an adapter-specific action, usually blinking the LED lights on the adapter, to help you identify between multiple adapters or interface names:
ethtool -p
Display network statistics:
ethtool -S
Set the connection speed of the adapter in Mbps:
ethtool speed <10|100|1000>
——————————————————————————————————————
Iwconfig for wireless configuration
The iwconfig tool is like ifconfig and ethtool for wireless cards. You can view and set the basic Wi-Fi network details, such as the SSID, channel, and encryption. There’s also many advanced settings you can view and change, including receive sensitivity, RTS/CTS, fragmentation, and retries. Here are some commands you may want to try:
Display the wireless settings of your interfaces, including the interface names you’ll need for other commands:
iwconfig
Set the ESSID (Extended Service Set Identifier) or network name:
iwconfig essid
Example: iwconfig “my network”
Example: iwconfig any
Set the wireless channel of the radio (1-11):
iwconfig
Input a WEP encryption key (WPA/WPA2 isn’t supported yet; for this you need wpa_supplicant):
iwconfig eth0 key
Only allow the adapter to connect to an AP with the MAC address you specify:
iwconfig ap
Example: iwconfig eth0 ap 00:60:1D:01:23:45
Set the transmit power of the radio, if supported by the wireless card, in dBm format by default or mW when specified:
iwconfig txpower
Example: iwconfig eth0 txpower 15
Example: iwconfig eth0 txpower 30mW
————————————————————————————————————————-
tcpdump for sniffing network packets
This isn’t just a simple tool; its a network sniffer or analyzer. It can capture the packets traveling through your interfaces and on the network. You can inspect the raw packets or review statistics. The tool is often used by other GUI programs, but can also be useful in a terminal. Here are some command options to get you started:
* -i: Specifies the interface to capture on, such as eth0 or ath0.
* -n: Stops replacing IP addresses with hostnames.
* -nn: Stops resolving hostnames or port names.
* -s : Maximum bytes to display for each packet. Default is 68. Use 0 to display entire packets.
* v, -vv, and -vvv: Steps up the amount of details printed along with the packets, such as the total length and options in an IP packet, fully decoded SMB packets, and telnet details.
* -x: Displays the packet contents in the HEX format.
* -X: Prints the packet contents in the ASCII format.
———————————————————————————————————————–
Netstat for reviewing network statistics
The netstat (or network statistics) tool can display details of your network connections, interface statistics, routing tables, masquerade connections, and multicast memberships. Here are a few commands that might interest you:
View a list of open sockets:
netstat
Display a table of all the network interfaces:
netstat -i
Display the summary statistics for each protocol:
netstat -s