http://www.linuxplanet.com/linuxplanet/tutorials/7044/1

Back to article

7 Useful Linux Networking Commands

ifconfig, iwconfig, ethtool

April 19, 2010

Though you can usually manage your network settings via the GUI in most Linux distros these days, it's always good to be familiar with the command-line tools. So we're going to review some select commands from a couple of tools that are typically included in the popular Linux distros. Remember, if you want full details on the tool and its options, refer to its man page: type man followed by the tool name. Now bring up a terminal and let's get started!

ifconfig for basic interface and IP configuration

The ifconfig tool (derived from interface configurator) provides a few very basic, but important, functions. It lets you turn network adapters on and off and assign IP address and netmask details. Here are some of the common commands:

View current configuration of network interfaces, including the interface names:

ifconfig

Turn an adapter on (up) or off (down):

ifconfig

Assign an IP address to an adapter:

ifconfig

Assign a second IP address to an adapter:

ifconfig

Example: ifconfig eth0:0 192.168.1.101

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

Sitemap | Contact Us