Some Basic Networking Commands

network.png

Networking in general can go so in depth that the mind spins thinking about all there is to know, and there’s plenty of linux tools to deal with the simplest of home networks, to complex networking setups. The Linux+ and LPI certification exams require that you already have a working knowledge of networking principles, but they also expect you have a grasp on some of the basic networking tools in the Linux world. Some we’ll cover today, some of these may or may not be included on a specific exam’s test, but none the less, they will aid you in the Unix world.

ifconfig

The “ifconfig” command allows the operating system to setup network interfaces and allow the user to view information about the configured network interfaces. ifconfig has many options but some of the basics you’ll need to know:

ifconfig eth0

View the network settings on the first Ethernet adapter installed in the computer.

ifconfig -a

Display into on all network interfaces on server, active or inactive. Alternatively if you do not specify ‘-a’ or an Ethernet adapter ifconfig will show the network settings for all the adapters, as well as the loopback device.

ifconfig eth0 down

If eth0 exists would take it down causing it to not send or receive any information.

ifconfig eth0 up

If eth0 exists and in the down state would return it back to the up state allowing to to send and receive information.

ifconfig eth0 192.168.1.103 netmask 255.255.255.0 broadcast 192.168.1.255

Assign eth0 with the above values for IP, netmask and broadcast address.

‘man ifconfig’ will show you many of the options for the ifconfig command.

ifup / ifdown

ifup – bring a network interface up

ifdown – take a network interface down

Examples:

ifup -a

Bring up all the interfaces defined with auto in /etc/network/interfaces

ifup eth0

Bring up interface eth0

ifdown -a

Bring down all interfaces that are currently up.

 

traceroute

Traceroute prints the route packets take to network host. Most distributions don’t have this preinstalled so you may have to pull it from your repositories, but this tool is just as useful in linux as it is in Windows and a must have for troubleshooting connectivity problems.

traceroute tuxtraining.com will show you the route your machine sends packets to get to this website. Traceroute provides some insight where a connectivity problem could be going wrong.

ping

Ping sends ICMP ECHO_REQUEST packets to network hosts making it easy to see if you can get to an address (DNS or IP).

ping tuxtraining.com or ping 69.89.27.220 will do the same thing. If you can hit the IP but not the FQDN (fully qualified domain name) then you have a problem resolving a DNS address.

Unlike in Windows, ping will run indefinitely until you make it stop with a Ctrl+C.

Note: Many ISP’s are disabling the ping command in helping to prevent possible Denial Of Service attacks. In addition some commands may not be available or results may vary when pinging a host.

‘man ping’ will show you many of the options for the ping command.

netstat

Netstat displays generic net statistics of the host you are currently connected to. If you issue this command on its own you should see a slew of connections you linux pc had established currently. It will tell you the type, the connection state, the node, and the path that’s making of listening for that connection.

netstat -an

Shows all connections to the server including the source and destination ips and ports if you have proper permissions.

netstat -rn

Displays routing table for all ips bound to the server.

netstat -an | grep :80

Display all active connections on port 80.

Related Posts

Comments are closed.