Basic Linux Networking Commands

Embed Size (px)

DESCRIPTION

Linux networking commands.

Citation preview

  • EXPERIMENT NO. 01 AIM: To study and implement basic networking commands in Linux. THEORY:

    1) HOSTNAME: Description:

    hostname is used to display the system's DNS name, and to display or set its hostname or NIS (Network Information Services) domain name.

    When called without any arguments, hostname will display the name of the system as returned by the gethostname function.

    When called with one argument or with the --file option, hostname will set the system's host name using the sethostname function. Only the superuser can set the host name.

    Option:

    hostname with no options displays the machines host name hostname d displays the domain name the machine belongs to hostname f displays the fully qualified host and domain name hostname i displays the IP address for the current machine

    Syntax:

    hostname [-v] [-a|--alias] [-d|--domain] [-f|--fqdn|--long] [-A|--all-fqdns] [-i|--ip-address] [-I|--all-ip-addresses] [-s|--short] [-y|--yp|--nis]

    2) PING: Description:

    ping is a simple way to send network data to, and receive network data from, another computer on a network. It is frequently used to test, at the most basic level, whether another system is reachable over a network, and if so, how much time it takes for that data to be exchanged.

    The ping utility uses the ICMP protocol's mandatory ECHO_REQUEST datagram to elicit an ICMP ECHO_RESPONSE from a host or gateway. ECHO_REQUEST datagrams ("pings") have an IP and ICMP header, followed by a struct timeval and then an arbitrary number of "pad" bytes used to fill out the packet.

    Option:

    -a Audible ping. -A Adaptive ping. Interpacket interval adapts to round-trip time, so that effectively

    not more than one (or more, if preload is set) unanswered probe is present in the

  • network. Minimal interval is 200msec for not super-user. On networks with low rtt this mode is essentially equivalent to flood mode.

    -b Allow pinging a broadcast address. -B Do not allow ping to change source address of probes. The address is bound to

    one selected when ping starts. -c count Stop after sending count ECHO_REQUEST packets. With deadline

    option, ping waits for count ECHO_REPLY packets, until the timeout expires. -d Set the SO_DEBUG option on the socket being used. Essentially, this socket

    option is not used by Linux kernel. Syntax:

    ping [-LRUbdfnqrvVaAB] [-c count] [-m mark] [-i interval] [-l preload] [-p pattern] [-s packetsize] [-t ttl] [-w deadline] [-F flowlabel] [-I interface] [-M hint] [-N nioption] [-Q tos] [-S sndbuf] [-T timestamp option] [-W timeout] [hop ...] destination

    3) IFCONFIG: Description:

    Ifconfig is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed.

    If no arguments are given, ifconfig displays the status of the currently active interfaces. If a single interface argument is given, it displays the status of the given interface only; if a single -a argument is given, it displays the status of all interfaces, even those that are down. Otherwise, it configures an interface.

    Options:

    -a display all interfaces which are currently available, even if down -s display a short list (like netstat -i) -v be more verbose for some error conditions

    Syntax:

  • ifconfig [-v] [-a] [-s] [interface]

    4) NETSTAT: Description:

    netstat ("network statistics") is a command-line tool that displays network connections (both incoming and outgoing), routing tables, and a number of network interface (network interface controller or software-defined network interface) and network protocol statistics. It is available on Unix-like operating systems including OS X, Linux, Solaris, and BSD, and on Windows NT-based operating systems including Windows XP, Windows Vista, Windows 7 and Windows 8.

    It is used for finding problems in the network and to determine the amount of traffic on the network as a performance measurement.

    Option:

    --verbose , -v Tell the user what is going on by being verbose. Especially print some useful information about unconfigured address families.

    --wide , -W Do not truncate IP addresses by using output as wide as needed. This is optional for now to not break existing scripts.

    --numeric , -n Show numerical addresses instead of trying to determine symbolic host, port or user names.

  • --numeric-hosts shows numerical host addresses but does not affect the resolution of port or user names.

    --numeric-ports shows numerical port numbers but does not affect the resolution of host or user names.

    --numeric-users shows numerical user IDs but does not affect the resolution of host or port names.

    --protocol=family , -A Specifies the address families (perhaps better described as low level protocols) for which connections are to be shown. family is a comma (',') separated list of address family keywords like inet, unix, ipx, ax25, netrom, and ddp. This has the same effect as using the --inet, --unix (-x), --ipx, --ax25, --netrom, and --ddp options.

    Syntax:

    netstat [address_family_options] [--tcp|-t] [--udp|-u] [--raw|-w] [--listening|-l] [--all|-a] [--numeric|-n] [--numeric-hosts] [--numeric-ports] [--numeric-users] [--symbolic|-N] [--extend|-e[--extend|-e]] [--timers|-o] [--program|-p] [--verbose|-v] [--continuous|-c]

    5) NSLOOKUP: Description:

    nslookup, which stands for "name server lookup", is a useful tool for finding out information about a named domain.

    Nslookup is a program to query Internet domain name servers. Nslookup has two modes: interactive and non-interactive. Interactive mode allows the user to query name servers for information about various hosts and domains or to print a list of hosts in a domain. Non-interactive mode is used to print just the name and requested information for a host or domain.

    By default, nslookup will translate a domain name to an IP address (or vice versa). Option:

  • host [server] Look up information for host using the current default server or using server, if specified. If host is an Internet address and the query type is A or PTR, the name of the host is returned. If host is a name and does not have a trailing period, the search list is used to qualify the name. To look up a host not in the current domain, append a period to the name.

    server domain lserver domain Change the default server to domain; lserver uses the initial

    server to look up information about domain, while server uses the current default server. If an authoritative answer can't be found, the names of servers that might have the answer are returned.

    Root not implemented finger not implemented ls not implemented view not implemented

    Syntax:

    nslookup [-option] [name | -] [server]

    6) ARP: Description:

    arp manipulates or displays the kernel's IPv4 network neighbor cache. It can add entries to the table, delete one, or display the current content.

    ARP stands for Address Resolution Protocol, which is used to find the address of a network neighbor for a given IPv4 address.

    Option:

    -v, --verbose Tell the user what is going on by being verbose.

  • -n, --numeric shows numerical addresses instead of trying to determine symbolic host, port or user names.

    -H type, --hw-type type When setting or reading the ARP cache, this optional parameter tells arp which class of entries it should check for. The default value of this parameter is ether (i.e. hardware code 0x01 for IEEE 802.3 10Mbps Ethernet). Other values might include network technologies such as ARCnet (arcnet) , PROnet (pronet) , AX.25 (ax25) and NET/ROM (netrom).

    -a Use alternate BSD style output format (with no fixed columns). -D, --use-device Instead of a hw_addr, the given argument is the name of an

    interface. arp will use the MAC address of that interface for the table entry. This is usually the best option to set up a proxy ARP entry to yourself.

    Syntax:

    arp [-vn] [-H type] [-i if] -a [hostname]

    7) RARP: Description:

    Rarp manipulates the kernel's RARP table in various ways. The primary options are clearing an address mapping entry and manually setting up one. For debugging purposes, the rarp program also allows a complete dump of the RARP table.

    Option:

    -V Display the version of RARP in use. -v Tell the user what is going on by being verbose. -a --list Lists the entries in the RARP table. -d hostname --delete hostname Remove all RARP entries for the specified host. -s hostname hw_addr

    Syntax:

    rarp [-V] [--version] [-h] [--help] rarp -a rarp [-v] -d hostname ... rarp [-v] [-t type] -s hostname hw_addr

  • 8) ROUTE: Description:

    In computer networking, a router is a device responsible for forwarding network traffic. When datagrams arrive at a router, the router must determine the best way to route them to their destination.

    On Linux, BSD, and other Unix-like systems, the route command is used to view and make changes to the kernel routing table. The command syntax is different on different systems; here, when it comes to specific command syntax, we'll be discussing the Linux version.

    Options:

    -A family use the specified address family (eg 'inet'; use 'route --help' for a full list). -F operate on the kernel's FIB (Forwarding Information Base) routing table. This is

    the default. -C operate on the kernel's routing cache. -v select verbose operation. -n show numerical addresses instead of trying to determine symbolic host names.

    This is useful if you are trying to determine why the route to your nameserver has vanished.

    -e use netstat-format for displaying the routing table. -ee will generate a very long line with all parameters from the routing table.

    del delete a route. add add a new route. target the destination network or host. You can provide IP addresses in dotted decimal

    or host/network names. -net the target is a network. -host the target is a host.

    Syntax:

    route [-v] [-A family] add [-net|-host] target [netmask Nm] [gw Gw] [metric N] i [mss M] [window W] [irtt I] [reject] [mod] [dyn] [reinstate] [[dev] If]

    9) DIG: Description:

    dig (which stands for domain information groper) is a flexible tool for interrogating DNS name servers. It performs DNS lookups and displays the answers that are returned from the name server(s) that were queried. Most DNS administrators use dig to

  • troubleshoot DNS problems because of its flexibility, ease of use and clarity of output. Other lookup tools tend to have less functionality than dig.

    Although dig is normally used with command-line arguments, it also has a batch mode of operation for reading lookup requests from a file. A brief summary of its command-line arguments and options is printed when the -h option is given. Unlike earlier versions, the BIND 9 implementation of dig allows multiple lookups to be issued from the command line.

    Option:

    The -b option sets the source IP address of the query to address. This must be a valid address on one of the host's network interfaces or "0.0.0.0" or "::". An optional port may be specified by appending "#"

    The -f option makes dig operate in batch mode by reading a list of lookup requests to process from the file filename. The file contains a number of queries, one per line. Each entry in the file should be organized in the same way they would be presented as queries to dig using the command-line interface.

    The -m option enables memory usage debugging. The -4 option forces dig to only use IPv4 query transport. The -6 option forces dig to

    only use IPv6 query transport. Syntax:

    dig [@server] [-b address] [-c class] [-f filename] [-k filename] [-m] [-p port#] [-q name] [-t type] [-x addr] [-y [hmac:]name:key] [-4] [-6] [name] [type] [class] [queryopt...]

  • 10) HOST: Description:

    host is a simple utility for performing DNS lookups. It is normally used to convert names to IP addresses and vice versa. When no arguments or options are given, host prints a short summary of its command line arguments and options.

    name is the domain name that is to be looked up. It can also be a dotted-decimal IPv4 address or a colon-delimited IPv6 address, in which case host will by default perform a reverse lookup for that address. server is an optional argument which is either the name or IP address of the name server that host should query instead of the server or servers listed in /etc/resolv.conf.

    Option:

    -a The -a (all) option is equivalent to setting the -v option and asking host to make a query of type ANY.

    -C When the -C option is used, host will attempt to display the SOA records for zone name from all the listed authoritative name servers for that zone. The list of name servers is defined by the NS records that are found for the zone.

    -c class The -c option instructs host to make a DNS query of class class. This can be used to lookup Hesiod or Chaosnet class resource records. The default class is IN (Internet).

    -d Verbose output is generated by host when the -d or -v option is used. The two options are equivalent. They have been provided for backwards compatibility. In previous versions, the -d option switched on debugging traces and -v enabled verbose output.

    -I The -i option specifies that reverse lookups of IPv6 addresses should use the IP6.INT domain as defined in RFC1886. The default is to use IP6.ARPA.

    Syntax:

    host [-aCdlnrsTwv] [-c class] [-N ndots] [-R number] [-t type] [-W wait] [-m flag] [-4] [-6] {name} [server]

    CONCLUSION: Thus, I studied and implemented basic networking commands used in Linux Operating System.