Configuring the TCP/IP network software

Preliminary information required.

  1. Selecting a Name.
    Use the hostname command. This is not so easy, it must be unique and should be politically correct.As a guideline it shouldn't be too long or difficult to spell. This usually must be coordinated with network administrator for inclusion in nameserver if that is used.
  2. Getting an IP address.
    Usually assigned by network administrator. Need an address for each network interface. IP addresses take the form N.N.N.N, where N is a decimal number between 1-254 .

    Usually an organization will be assigned an address for there organization. For example, at UMBC we have a class B address of 130.85. This means we can assign addresses of 130.85.N.N

  3. Determine subnet and broadcast masks to use.
    Configure the subnet and broadcast addresses via the ifconfig command. This must be done in a consistent fashion with other hosts on the network. At UMBC broadcast addresses are set to 130.85.N.255 and the Netmask is set too 255.255.255.0.
  4. Select how packets are routed and your default gateway.
    We must decide if we are using static or dynamic routing. Dynamic routing may use many different types of routing protocols. We need to agree with other hosts on our network in how we will route. Choices often used are:
  5. RIP : Routing Information protocol. Simplest protocol, uses hop count as metric, good for sites with network links offer similar performance.
  6. IGRP: Developed by Cisco. Good when you have a mix of network links over different speeds.
  7. EGP: Exterior Gateway Protocol. Used for external internet communication.
  8. OSPF: New Protocol being provided that deals with routing in high speed WAN networks.
  9. Gated: Program which understands both RIP,OSPF, and EGP. Needed when you have a host which connected directly to an internal and external network. Gated, even when run in RIP only mode povides much better debugging information that standard software. As such, many sites use this to support internal routing.
  10. If using static routing you use the route command to build up a routing table. The format of this command is:
    route add net IP-network gateway metric
    An example would be
    route add net 136.160 ecs-gw 1

    On many systems all you need to do is define a default gateway for addresses not found on this subnet. That is done with the route command as well using:
    route add default IP-address 1.

  11. Plan what network services you want to support.

Setting up a network on a BSD based Machine.

For the example below, lets assume the hostname will be ifsm498.umbc.edu and the IP address will be 130.85.199.2
  • Define the hostname in the /etc/rc file with the command
    /bin/hostname ifsm498 .
  • Edit /etc/hosts file and add a line for this host
    130.85.199.2 ifsm498 ifsm498.umbc.edu
  • Edit /etc/rc.local file to add ifconfig command
    ifconfig en0 up netmask 255.255.255.0 broadcast 130.85.199.255 > /dev/console
  • Edit rc.local to add lines for routing. For static routing we use the /etc/route command.
    /etc/route add default 130.85.199.1 1
    For dynamic routing using RIP we start the routing deamon

    if [ -f /etc/routed ] ; then 
    /etc/routed -q & 
    ( echo -n  starting routed)>/dev/console
    
  • Edit the file /etc/resolv.conf to define the domain and nameservers to use. Example here at umbc

    domain umbc.edu
    nameserver 130.85.1.4  (note numeric form Why?)
    nameserver 130.85.1.3
    
  • Select application deamons to support.
    Unix uses the concept of a superserver that handles connection requests, forking off the appropriate server for each connection. This superserver is named INETD. Inetd is started up in /etc/rc.local with
     if [ -f /etc/inetd.conf ] ;  then
       /etc/inetd & ( echo Starting Inetd ) > /dev/console
    
    inetd manages applications such as telnet, ftp, rlogin, smtp, gopher, rcmd, finger,etc. Here is a sample inetd.conf file.

    Setting up the Network on System V (IRIX)

    The basic ideas are the same as in the BSD version but the configuration files are done differently. Under IRIX, there is a shell script /etc/init.d/network that controls all the network related setup. That shell script gets it information from some files described below.
  • The hostname can be defined by created a file named /etc/sys_id and placing the name of the host on a line in that file. The network script will check for that file and set the hostname.
  • Irix uses a file named /etc/config/netif.options to define the network interfaces available and the IP addresses associated with those interfaces. Instead of IP-addresses the interface addresses can be a hostname and IRIX will look up the IP address in the /etc/hosts file. The file /etc/config/netif.options has the format:
    if1name=et0
    if1addr=130.85.199.2     OR   if1addr=$HOSTNAME
    
  • To set the netmask and broadcast addresses you must define a config file for each interface under the name /etc/config/ifconfig-N.options where N is the interface number starting with 1. The contents of this file contain a single line with the netmask and broadcsat keywords, as in:
    netmask 255.255.255.0 broadcast 130.85.199.255 
    
  • To turn on routed for the system you must use the command
    chkconfig routed on
    Then upon startup, the network script will look for a file named /etc/config/routed.options. This file contains any command options you want run such as default route, etc. On our systems we just run this with the option -q to place the system in quiet mode and only listen for RIP requests. To set up a static route the routed.options file would contain the line:
    add default 130.85.199.1
  • Edit the /etc/resolv.conf file and list the nameservers to use. The format of this file is
    domain umbc.edu 
    hostresorder local bind nis
    nameserver 130.85.1.4
    nameserver 130.85.1.5
    
  • Select the application deamons to support. On Irix, the network script automatically starts the master internet service deamon inetd which reads a file named /etc/inetd.conf. This file has a line for each application to be served by inetd.
  • Configuring Inetd

    inetd is a deamon that manages other deamons. inetd, is responsible for handling incoming requests for applications like telnet, rlogin, finger, ftp, and mail. It starts up a client application when one is needed and kills them off when not needed. inetd only works with deamons that provide services over the network. The TCP/IP protocol supports the idea of ports, these ports are pre-defined for well-known applications. inetd works by attaching itself to these ports and listening for a network connection. When one occurs, inetd starts up the appropriate deamon and connects the standard I/O channels to the network port. The advantage of inetd is that the system has one file to update and it cuts down on overhead on the system. Without inetd, a deamon for each service supported would be required to be running at all time.

    inetd reads in a configuration file inetd.conf, this file has six fields, each seperated by a whitespace. The fields in order are:

    1. The service name. This name must be defined in the file /etc/services for TCP/UDP applications or handled by the portmap deamon for RPC services.
    2. The second column has the type of socket used, possible values are steam, dgram, and raw. Stream is generally used for TCP applications and dgram for UDP applications.
    3. The third column lists the protocol to use. This is either TCP or UDP. If this application uses RPC services also, then rpc is prepended to the protocol name as in rpc/tcp.
    4. The fourth field is either wait or nowait. Wait is used when you launch a deamon that itself asks as a server for multiple requests while nowait is used when you want a new copy for each new connection.
    5. The fifth field gives the username to run the program under. For some programs you want to select guest just incase bug is found that could be used to gain access.
    6. The last fields give the command name and parameters to use.
    Here is a small subset of a sample inetd.conf file:
    ftp     stream  tcp     nowait  root    /usr/site/etc/tcpd /usr/etc/ftpd -l
    telnet  stream  tcp     nowait  root    /usr/site/etc/tcpd /usr/etc/telnetd
    shell   stream  tcp     nowait  root    /usr/site/etc/tcpd /usr/etc/rshd -L
    login   stream  tcp     nowait  root    /usr/site/etc/tcpd /usr/etc/rlogind
    exec    stream  tcp     nowait  root    /usr/site/etc/tcpd /usr/etc/rexecd
    #finger stream  tcp     nowait  guest   /usr/etc/fingerd        fingerd
    #bootp  dgram   udp     wait    root    /usr/etc/bootp          bootp
    ntalk   dgram   udp     wait    root    /usr/etc/talkd          talkd
    tcpmux  stream  tcp     nowait  root    internal
    echo    stream  tcp     nowait  root    internal
    discard stream  tcp     nowait  root    internal
    chargen stream  tcp     nowait  root    internal
    

    Common Problems and Tools.

  • Duplicate IP addresses.
    - symptom-- intermitten application failure, unable to connect to hosts. Use arp command to debug.
  • Incorrect broadcast and netmask addresses.
    -symptom-- cannot connect to hosts on other networks. Use traceroute or netstat -R to verify.
  • Incorrect nameserver entry.
    -symptom-- not allowed to mount files, telnet or ftp connections are rejected. Use nslookup to verify.
  • Routing is not set up or running.
    -symptom-- cannot connect to selected hosts on network. Use netstat -r to verify.
  • Final Comments.

    Unix and networking go hand in hand. Setting up the network on a host isn't difficult but debugging problems as they arise is. Having an understanding of what is happening on the network is a great help.