Thursday, 6 February 2014

Linux Network Commands

3 comments

Linux Networking Commands, Networking Commands

Making optimal use of the network with Linux for varied purposes such as remote login, network statistics, alive test, and many more, is very essential in day-to-day usage. Linux Networking is incredibly simplified with the following elaborated Linux Network Commands.

Linux Network Commands in a Nutshell


ifconfig [devicename] [reqd. action] [options] : With this command and its different options one can obtain statistics as well as configure any network adapter connected in the system.
example : To assign IP Address to a  network adapter.
ifconfig eth0 192.168.1.1

whois [options]  <arg[@server]> : Queries the WHOIS database, to retrieve available information about the given server / domain-name.
example : To obtain information about a domain, suppose google.com.
whois google.com

ping [options] [host-address/name] : This command sends Internet Control Message Protocol (ICMP) to the specified network host.
example : To ping a network host "192.168.1.1"
ping 192.168.1.1

netstat [options] : Gives information about the all the network connections established by the system through different ports.
-t  : Displays only TCP socket connections
-a : Displays all the sockets that is listening and non-listening ones
For example :
netstat -a

traceroute [options] [host-name/address] : Displays identity of hosts visited by the packet while routing from its source to destination.
-n : This option disables the DNS lookups for the IP Addresses
example :
traceroute 192.168.1.1

route [options] [destination host-name/address] : Displays as well as allows to manipulate the IP routing table.
-n : Displays IP addresses as by default hostnames are displayed
example : The command below displays the numerical IP addresses in the IP routing table
route -n

telnet [options] [host] [port_number] : Does an interactive communication with another host through TELNET protocol on the specified port number. By default it uses TCP port number 23 and the connection is not encrypted.
-l : specify user name to login as on the remote system
example : To login into remote host 192.168.1.1 in username "abc"
telnet -l abc 192.168.1.1

ssh [options] [username@host-address] : Enables a user to make secure remote login to the specified host address.
-C : Compresses the data which sent over the connection to specified host
-X : Enables the user to use X server features. 
example : In order to ssh to host 192.168.1.1 with username "abc" following is the command.
ssh -X abc@192.168.1.1

scp [options] [username@host-address:file_location] : Enables a user to make secure copy of the file to the specified host-address.
-r  : Recursively copies the data in directories
-C : Compresses the data which sent over the connection to specified host
example : In order to scp file.txt to host 192.168.1.1 with username "abc" following is the command.
scp file.txt abc@192.168.1.1:~\

wget [options] [URL] : Performs HTTP request from through the shell to get data from the URL
-r  : Get the URL and all its links in recursive manner

iptables [options] : This command requires root permission. It enables to carry out packet filtering and Network Address Translation.
-F  : Flush set of rules
-n  : Show rules without carrying out DNS lookups
-A :  Appends one or more rules to the end of the selected chain.
-j   : Specify the target of the rule
-s  : specify source
-L : Current rules are listed
For example : To block packets from certain IP Address 192.168.1.1, can be done by
iptables -A INPUT -s 192.168.1.1 -j DROP

tcpdump [options] : Outputs the contents of packets on the network interface. It can also output only certain packets based on the condition provided.


3 comments:

  1. Nice ...Want more linux network command..waiting to learn more

    ReplyDelete
  2. Shouldn't X-Windows be somewhere in this list? It seems that if you have ssh and telnet both, you ought to wave people away from the unsecure remote access. Similarly, it would seem rsh should be on the list, if only to wave people away from it as insecure. A valuable thing to cover is how to securely do X-windows via ssh tunneling. Secure setup of X-windows takes some doing, but once you've got it, you can pretty much forget the details and just use it. Alas, I'd have to figure it out again as I don't have an existing configuration here and I've forgotten the details of how I did it last time.

    The route command could use a lot more explanation. speaking for myself, whenever confronted with a system with multiple network controllers, I find myself having to scratch my head more than I'd like to get routing of the networks working right.

    ssh also deserves a few more words talking about ssh versions and public key/private key certificates and use of ssh-add to cache decrypted certificates so you don't drive yourself crazy having to retype passwords over and over, yet remain secure when accessing a boatload of remote systems.

    ReplyDelete