Home » Linux Basics » 11 - Linux Networking Utilities
11

Basic Protocols and Configuration

Knowing the different protocols supported by the Linux System

Linux supports the TCP/IP and UUCP networking protocols. TCP/IP (Transmission Control Protocol/Internet Protocol) is a networking paradigm that allows systems to communicate via the Internet. Linux users may browse the web, communicate with other users and machines via E-mail and newsgroups, and perform FTP file transfers as long as the system is on a network. Linux supports most Ethernet cards and interfaces. Linux also supports SLIP (Serial Line Internet Protocol) and PPP (Point-to-Point Protocol) that allow Internet access via a modem.

The NFS (Network File System) allows systems running Linux OS to share file systems with remote machines while FTP (File Transfer Protocol) allows file transfer to and from other machines. The sendmail utility is used to send and receive E-mail through SMTP (Simple Mail Transfer Protocol). The telnet, rlogin, and ssh utilities allow users to sign into remote machines located elsewhere and run and execute commands on the remote machine. The finger utility allows Linux users to get information about other Internet users. Popular mail and news readers include elm, pine, rn, nn, and tin. Your system probably supports a few of these. Linux may also be connected to systems running the Windows OS via Samba and systems running the Mac OS via AppleTalk.

TCP/IP software is normally installed with the OS in many Linux distributions. The kernel is configured and compiled with TCP/IP support enabled. Basic clients (telnet, ftp) utilities such as ifconfig and route and default network configuration files (such as /etc/hosts) are available. Network files are normally found in /etc. Sometimes, these files may be found in /usr/etc, /usr/etc/inet etc . You may have to use the find command to locate the files.

  • The IP address is the unique address of the system e.g. (128.223.73.8). The IP address 127.0.0.1 may be used to simply configure TCP/IP connections on Linux
  • The network mask is a dotted decimal number similar to the IP address. When overlayed onto an address on the network as a sequence of bits, the network mask reveals the subnet of the address. This is very important for routing. Most networks are class C subnetworks which use 255.255.255.0 as their netmask. Other Class B networks use 255.255.0.0.
  • If you are just configuring TCP/IP,your netmask is 255.0.0.0 (for IP address 127.0.0.1
  • The nameserver address is the address of the server that translates the IP address into a domain name (such as google.com or yahoo.com). This is important to know if SLIP is used to connect with the network.

The rc configuration files are scripts executed at boot time by init. These scripts start up basic system daemons (such as sendmail, cron, etc.) and configure network parameters, system hostname, and so on. The rc scripts are typically located in the directory /etc/rc.d or /etc.

The rc.inet1 and rc.inet2. files are used to configure TCP/IP. rc.inet1 and contains parameters like IP addresses and routing information while rc.inet2 starts up TCP/IP utilities and daemons like telnetd, ftpd, and etc. Many systems combine these two files into one rc.inet or rc.net script. These scripts have to be part of initrc and execute at boot time to enable network access. The following is an example of an rc.inet1 script. All ip addresses should be changed to reflect the correct values for the system.

    #!/bin/sh
 
HOSTNAME=`hostname`
 
/etc/ifconfig lo 127.0.0.1      # uses default netmask 255.0.0.0
/etc/route add 127.0.0.1        # a route to point to the loopback device
 
# configure the ethernet device. If you're only using loopback or
# SLIP, comment out the rest of these lines.
 
# Edit for your setup.
IPADDR="128.223.73.8"        
NETMASK="255.255.255.0"               
NETWORK="128.223.73.8"        
BROADCAST="128.223.73.255"    
GATEWAY="128.223.73.1"        
 
/etc/ifconfig eth0 ${IPADDR} netmask ${NETMASK} broadcast ${BROADCAST}
 
# If you don't have a broadcast address, change the above line to just:
# /etc/ifconfig eth0 ${IPADDR} netmask ${NETMASK}
 
/etc/route add ${NETWORK}
 
# The following is only necessary if you have a gateway
/etc/route add default gw ${GATEWAY} metric 1
 
# End of Ethernet Configuration

The rc.inet2 script starts-up various servers used by the TCP/IP related utilities. The inetd is a background process that listens (or waits) on various network ports. When another machine tries to connect to a certain port, inetd forks a process that executes the appropriate daemon for that port (e.g inetd starts in.telnetd for a telnet port). Using inetd to start daemons on an as-needed basis in this manner is more efficient than running standalone daemons such as telnetd, ftpd etc all the time. Following is a basic rs.inet2 script. Directories etc. should be changed to fit your system configuration:

    #! /bin/sh
 
# Start the log file
if [ -f /etc/syslogd ]
then
      /etc/syslogd
fi
 
# Start inetd
if [ -f /etc/inetd ]
then
      /etc/inetd
fi
 
# Start routed
if [ -f /etc/routed ]
then
      /etc/routed -q
fi

Other Configuration files

  • /etc/hosts contains a mapping of IP addresses to hostnames. Typically, /etc/hosts only contains entries for the local machine, the name server, and the gateway. The local name server will provide address-to-name mappings for other machines on the network.
  • The /etc/networks file lists the names and addresses the current system and other networks. It is used by the route command and allows users to specify names rather than IP addresses to connect to remote servers.
  • The /etc/host.conf contains the hostname resolution method for the system. For example, it contains directives that tell the OS whether hostname mappings should be recovered from the /etc/hosts file or the nameserver first and whether a single remote machine may be mapped to multiple IP addresses.
  • The netstat command may be used to display routing tables and other network related information.

Linux includes web server software as well as web browsers. Apache is the most popular Linux web server. Some Linux distributions include browsers like Firefox. Linux provides extensive support and an ideal development environment for web application development using Java applets. The Perl language is a standard tool in the Linux programming environment.