April 17, 2014
 
 
RSSRSS feed

7 Useful Linux Networking Commands - page 2

ifconfig, iwconfig, ethtool

  • April 19, 2010
  • By Eric Geier

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.

Ping, your network sonar

The Ping tool is similar to what Microsoft provides in Windows. However, the option types and names vary. Plus in Linux, it will continuously ping forever by default rather than only send four.

Start pinging an IP address or a host/domain name:

ping

To stop the pinging, hit Ctrl + C.

Here are a few options that you might want to use:

  • -c: Count, or number, of packets to send
  • -i: Wait interval; number of seconds between packets
  • -s: Packet size of pings; default is 56 (64 with ICMP)
  • -w: Waitsecs or how long in seconds to perform pinging

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

Hostname lets you view and change your hostname

If you're an administrator, you know what a hostname is. For everyone else: a hostname helps identify network devices in a more user-friendly (alphabetic) way rather just by a crude IP address. Linux distros usually include a simple tool called hostname to view and temporarily change your hostname.

View the current hostname setting:

hostname

Temporarily change the hostname (until restart):

hostname

To permanently change the hostname, you'll have to edit the /etc/hostname or /etc/sysconfig/network files.

Eric Geier is the Founder and CEO of NoWiresSecurity, which helps businesses easily protect their Wi-Fi with enterprise-level encryption by offering a hosted RADIUS/802.1X authentication service. He is also the author of many networking and computing books for brands like For Dummies and Cisco Press.

Sitemap | Contact Us