Top

A Linux User Reference

Search tips
  • search ignores words that are less than 4 characters in length
  • searches are case insensitve
  • if a search does not return anything try it in Boolean mode then Query expansion mode by checking the appropriate radio button e.g. searching for 'cron' in just the Administration category returns nothing - presumably because the 50% threshold is reached. Boolean mode ignores this threshold so a search for 'cron' returns several hits
  • in Boolean mode preceding a word with a '+' means the result must include that word, a '-' means it must not
  • in Boolean mode '+crontab -anacron' means match articles about crontab that DO NOT mention anacron
  • to match a phrase e.g. 'manage system' check the Boolean mode radio button and enclose the phrase in quotes "some phrase ..."
  • in Query expansion mode the search context is expanded beyond the keywords you entered - relevancy of hits may well be degraded

NETWORK APPLICATIONS

DHCP

  • DHCP server

    The Dynamic Host Configuration Protocol(DHCP) allows multiple network clients to receive their network configuration parameters from a single source thus simplifying this aspect of network administration for medium to large networks.

    • a DHCP server manages the allocation of IP addresses to clients
    • an IP address is leased to the client
    • the lease determines for how long a client may /use the IP address it has been allocated
    • leases are stored in the database file /var/lib/dhcp/dhcpd.leases
    • a server will also provide a number of network configuration parameters
    • server configuration file is /etc/dhcpd.conf or /etc/dhcp3/dhcpd.conf

    Reserved bootp entries - /etc/services

    # Format: <application> <port/protocol> 
    
    bootps  67/tcp  # BOOTP server
    bootps  67/udp
    bootpc  68/tcp  # BOOTP client
    bootpc  68/udp
    
  • Server configuration with dns-updates
    /etc/dhcpd.conf

    Sample configuration for an internal lan

    # Global settings
    # DHCP allows the client to receive options from the DHCP server describing the network
    # configuration and various services that are available on the network.
    option domain-name "my-home.com";
    option domain-name-servers f86local.my-home.com, dnssrv.my-home.com;
    option routers 192.168.10.1;
    option broadcast-address 192.168.10.15;
    
    default-lease-time 3600;               # if a client does not ask for a specific period
    max-lease-time 7200;                   # max period in seconds that a lease will last
    log-facility local7;                   # use this syslog/rsyslog facility
    ignore-client-updates;                 # ignore all client requests for DDNS update
    authoritative;                         # this is the official dhcp server for my-home.com
    
    # Settings here override global ones
    # Subnet with dynamic dns updates
    subnet 192.168.10.0 netmask 255.255.255.240 {     
       range 192.168.10.4 192.168.10.14;
    
       ddns-update-style interim;
       ddns-ttl 14400;
    
       ddns-updates on;
    
       key "dhcp-updates" {
         algorithm hmac-md5;
         secret "iTgkclA........wA==";
         }
    
       zone my-home.com. {                  # ddns-domainname "my-home.com.";
         primary 127.0.0.1;                 # name server whose zone information is to be updated. 
         key "dhcp-updates";
         }
    
        zone 0.168.192.in-addr.arpa. {      # ddns-rev-domain "0.168.192.in-addr.arpa.";
         primary 127.0.0.1;
         key "dhcp-updates";
        }
    }
    

    If entry in /etc/syslog.conf or /etc/rsyslog.d/50-default.conf is

    local7.*                   /var/log/dhcp/dhcpd.log
    

    may clash with boot messages in some distributions.

    then a sample lease log entry in /var/log/dhcp/dhcpd.log

    Lease  192.168.1.17  {                   # A sample log entry
     starts  5  2008/01/02   10:53:18;
    

    You can do all sorts of things with 'rsyslog' so record format could be well different.

  • Further server configuration examples
    /etc/dhcpd.conf

    Use 'man dhcp-options' to find out more.

    A client's boot parameters are determined by consulting

    • that client's host declaration (if any) and then
    • consulting any class declarations matching the client
    • followed by the pool, subnet and shared-network declarations for the IP address assigned to the client
    # Global parameters
    option smtp-server 21.31.0.3;
    option pop-server 21.31.0.4;
    option nntp-server 21.31.0.5;
    option time-servers 21.31.0.6;
    
    # single host with static address NOT in pool/range
    host fantasia {
         hardware ethernet 08:00:07:26:c0:a5;
         option routers 192.168.10.1;
         option netmask 255.255.255.0;
         option broadcast-address 192.168.10.255;
         fixed-address 192.168.0.100;
    }
    
    # Clients can be separated into classes, and treated differently depending on what
    # class they are in. This separation can be done either with a conditional statement, 
    # or with a match statement within the class declaration.
    # ----
    # Assigns a class of 'foo' to host if it is a Sun Workstation
    class "foo" {
         match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
         }
    
    # used to inform the DHCP server that some IP subnets actually
    # share the same physical network
    shared-network 224-29 {
         subnet 10.17.224.0 netmask 255.255.255.0 {
         option routers rtr-224.example.org;
         }
    subnet 10.0.29.0 netmask 255.255.255.0 {
         option routers rtr-29.example.org;
         }
    
    # The pool declaration can be used to specify a pool of addresses that will be treated
    # differently than another pool of addresses, even on the same network segment or subnet.
    # ----
    # Using pools you can subdivide the available IP range e.g. members
    # of group foo get a subset of addresses that are available
    pool {
         allow members of "foo";
         range 10.17.224.10 10.17.224.250;
         }
    
    pool {
         deny members of "foo";
         range 10.0.29.10 10.0.29.230;
         }
    
    # Use a group statement to provide common parameters for a set of hosts
    group {
      # group-specific parameters...
      host zappo.test.isc.org {
        host-specific parameters...
      }
      host beppo.test.isc.org {
        host-specific parameters...
      }
      host harpo.test.isc.org {
        host-specific parameters...
      }
    
    Some 'kind of' rules

    If clients on a subnet are to be assigned addresses dynamically, a 'range' declaration must appear within the subnet declaration.

    For clients with statically assigned addresses or for installations where only known clients will be served, each such client must have a 'host' declaration.

    If parameters are to be applied to a group of declarations which are not related strictly on a per-subnet basis, the 'group' declaration can be used.

    A subnet declaration is required for each subnet even if no addresses will be dynamically allocated on that subnet.

  • DHCP server daemon
    dhcpd

    By default 'dhcpd' listens on all configured interfaces.

    dhcpd [-p <UDP port>]
          [options]
          [-cf conffile]
          [-lf leasefile]
          [-t|-T]
          [-s server]
          [if0 ...]
    
    Options:
     -t | -T            Test the lease DB but do not carry out any operations
     -f                 Do not fork
     -d                 Debug, log to stdout, '-f' is implied
     -q                 Quiet, do not print out copyright message etc. on startup
    

    Reload the DHCP-server after making changes

    # /etc/init.d/dhcp restart
    

    Probably via 'sudo service dhcp [command]' as well ...

  • PXE boot server
    /etc/dhcpd.conf
    • Pre-boot eXecution Environment.
    • Enables booting of a remote system over a network.
    • The remote system gets it's network configuration via DHCP and a kernel boot image via tftp.

    Example configuration (for a single PC) - /etc/dhcpd.conf

    # If /etc/ltsp/dhcpd.conf exists it will take precedence
    # GLOBAL
    ddns-update-style none;                                     # Not using
    deny booting;                                               # Use PXE - default=allow
    deny bootp;                                                 # Use PXE - default=allow
    default-lease-time 600;
    max-lease-time 7200;
    authoritative;                                              # Only dhcp on subnet
    log-facility local7;                                        # Logging
    option domain-name-servers 194.155.3.101, 194.155.7.101;    # ISP's nameservers
    
    # SUBNET
    subnet 192.168.0.0 netmask 255.255.255.0 {                  # My internal lan
         range 192.168.0.5 192.168.0.10;                        # allocate an IP from this range
         option broadcast-address 192.168.0.255;
         option routers 192.168.0.1;
         }
    
    # USE GROUP
    # used to apply one or more parameters to a group of declarations
    # It can be used to group hosts, shared networks, subnets, or even other groups
    group {
         host ubtest {
              allow booting;                                    # This host can net boot
              allow bootp;
              server-name "ubuntusrv";                          # Sent to client, name of server it is booting from
              next-server 192.168.0.2;                          # Get boot image from this server
              hardware ethernet 00:0f:ea:cb:7a:c4;
              filename "pxelinux.0";                            # Use this boot image (/var/lib/tftpboot/..)
              fixed-address 192.168.0.3;                        # Cannot be in range of dynamic ip allocation
              }
         }
    }
    
  • DHCP relaying

    If a client were able to connect to the DHCP-server through a router, the DHCP-server would see the router's NIC address not the client's. This means the server cannot recognise the client via it's hardware (MAC) address.

    A relay, relays broadcasts on one subnet to a server on another and returns the responses back to the client.

  • DHCP and BOOTP relay agent
    dhcrelay
    • A dhcp-relay agent, provides a means for relaying DHCP and BOOTP requests from subnets to the DHCP-server.
    • It runs in the foreground until it has configured an interface then goes into the background.
    dhcrelay [options] server0 ...
    
    Some options:
     -p port               Listen and transmit on a non-standard port -standard port is 67
     -d                    Run in the foreground
     -q                    Usually prints network configuration on startup, disable with '-q',
                           useful for startup scripts.
     -i if0 [-i ifN ...]   Interface(s) to listen on
    

    Relay dhcp requests arriving on eth0 to server 192.168.1.5

    # dhcrelay -i eth0 192.168.1.5
    

    Forward client traffic to server(s) listed on the command line.

  • Client DHCP configuration
    • The DHCP protocol allows the client to request only the information it wants.
    • Clients can reject offers from servers if they don't contain information the client needs or if the information provided is not satisfactory.
    • Clint configuration via /dhclient.conf file in /etc/dhcp/ or /etc/dhcp3/.
    • There are a number of parameters/options that determine a client's behaviour.

    Configuration considerations:

    • protocol timing
    • information requested from the server
    • information required of the server
    • defaults to use if the server does not provide certain information
    • values with which to override information provided by the server
    • values to prepend or append to information provided by the server
    • can also be pre-initialised with addresses to use on networks that don't have DHCP servers

    There are a number of available clients. 'dhclient' and 'dhcp' is ISC's software. It is the most widely used open source DHCP implementation on the Internet. The name used to include the version number but since version 3 this is no longer appears to be the case.

  • Client DHCP statements
    request, require, send
    Request statement

    Requests any responding server to send the values for the options specified in the request statement. The server has values for these options configured in it's *dhcpd.conf' file.

    request [ option ] [, ... option ];
    

    Sample request - /etc/dhcp3/dhclient.conf

    request;              # Request values for all available options
    

    Probably 'dhcp' and not 'dhcp3'.

    Default request options are: subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, host-name

    Require statement

    A list of options that are required to be sent by the server if it's offer is to be accepted, if not supplied the offer is ignored.

    require [ option ] [, ... option ];
    
    Send statement

    Send the stated option values to the server - override the server's default values.

    Commonly used to request a lease time where the 'requested-lease-time' is greater than the default 'default-lease-time' (2hrs) and to differentiate the client from other clients.

    send { [ option declaration ] [, ... option declaration ]}
    

    All options are specified in the 'dhcp-options' man-page.

  • DHCP client program
    /sbin/dhclient

    Dynamic Host Configuration Protocol client.

    $ dhclient --help
    Internet Systems Consortium DHCP Client 4.2.4
    Copyright 2004-2012 Internet Systems Consortium.
    All rights reserved.
    For info, please visit https://www.isc.org/software/dhcp/
    Usage: dhclient [-4|-6] [-SNTP1dvrx] [-nw] [-p <port>] [-D LL|LLT]
                    [-s server-addr] [-cf config-file] [-lf lease-file]
                    [-pf pid-file] [--no-pid] [-e VAR=val]
                    [-sf script-file] [interface]
    
    Some options:
     -r             Release IP
     -d             Force dhclient to run as a foreground process.
     -x             Stop the client without releasing the current lease.
    

    Sample client configuration - /etc/dhcp3/dhclient.conf

    # Consists of a request statement followed by ',' separated list of information
    # the client desires from the server.
    
    request subnet-mask, broadcast-address, time-offset, routers, \
    domain-name, domain-name-servers, host-name, ntp-servers;
    

    Probably 'dhcp' and not 'dhcp3'.

  • Client leases

    Lease files location - /var/lib/dhcp3/

    dhclient.eth0.leases  dhclient.eth1.leases  dhclient.leases
    dhclient.wlan0.leases  dhcpd.leases
    

    Probably 'dhcp' and not 'dhcp3'.

    **Sample lease file - /var/lib/dhcp3/dhclient.eth0.leases

    lease {
      interface "eth0";
      fixed-address 192.168.0.2;
      option subnet-mask 255.255.255.0;
      option routers 192.168.0.1;
      option dhcp-lease-time 946080000;
      option dhcp-message-type 5;
      option domain-name-servers 192.168.0.1;
      option dhcp-server-identifier 192.168.0.1;
      option domain-name "my-home.com";
      renew 0 2020/11/1 02:24:58;
      rebind 5 2035/5/4 01:38:31;
      expire 2 2038/1/19 03:14:07;
    }
    

    Probably 'dhcp' and not 'dhcp3'.