\input{gl2.slide-header-beamer}%
\errorcontextlines=99
%% Subtopic Number = '1.112.3'
%% Title from filename: 'TCP/IP configuration and troubleshooting'
%% Weight: 7
%% Description:
%% Candidates should be able to view, change and verify
%%        configuration settings and operational status for various network
%%        interfaces. This objective includes manual and automatic configuration
%%        of interfaces and routing tables. This especially means to add, start,
%%        stop, restart, delete or reconfigure network interfaces. It also means
%%        to change, view or configure the routing table and to correct an
%%        improperly set default route manually. Candidates should be able to
%%        configure Linux as a DHCP client and a TCP/IP host and to debug problems
%%        associated with the network configuration.
%% Key files, terms, and utilities include:
%%        /etc/HOSTNAME or /etc/hostname
%%        /etc/hosts
%%        /etc/networks
%%        /etc/host.conf
%%        /etc/resolv.conf
%%        /etc/nsswitch.conf
%%        ifconfig
%%        route
%%        dhcpcd, dhcpclient, pump
%%        host
%%        hostname (domainname, dnsdomainname)
%%        netstat
%%        ping
%%        traceroute
%%        tcpdump
%%        the network scripts run during system initialization.
\title{1.112.3\\TCP/IP configuration and troubleshooting\\Weight 7}%
\author[Angus Lees]{Angus Lees \texttt{gus@inodes.org} \and Geoffrey Robertson \texttt{ge@ffrey.com} \and Nick Urbanik \texttt{nicku@nicku.org}\\
  {\tiny This document Licensed under GPL---see
    section~\ref{sec:license}}}%
\subtitle{Linux Professional Institute Certification --- 102}%
\mode<article>{\chead{1.112.3}}%

% TODO Nick:

% Update resources: troubleshooting lecture notes
% include a lot more detail about tcpdump
% include dig
% explain much more
% Include much from my troubleshooting lecture notes

\begin{document}
\maketitle
\mode<article>{\thispagestyle{empty}}

\begin{frame}
  \frametitle{Outline}
  \mode<presentation>
  {%
    %\footnotesize
    \begin{multicols}{2}
      \tableofcontents
    \end{multicols}
    % You might wish to add the option [pausesections]
  }%
  \mode<article>
  {%
    \tableofcontents
  }%
\end{frame}


\section{Context}
\label{sec:context}

\begin{frame}
  \frametitle{Topic 112 Networking Fundamentals [14]}%
  \framesubtitle{Where we are up to}%
    \begin{description}
    \item[1.112.1] Fundamentals of TCP/IP [4]
    % \uline depends on \usepackage[normalem]{ulem}:
    \item[1.112.3] \textbf{\uline{TCP/IP configuration and troubleshooting [7]}}
    \item[1.112.4] Configure Linux as a PPP client [3]
    \end{description}
\end{frame}

\section{Objective}
\label{sec:objective}


\begin{frame}
  \frametitle{Description of Objective}%
  \framesubtitle{1.112.3\ \ TCP/IP configuration and troubleshooting}%
  \mode<presentation>{\large}%
  Candidates should be able to view, change and verify configuration
  settings and operational status for various network interfaces. This
  objective includes manual and automatic configuration of interfaces
  and routing tables. This especially means to add, start, stop,
  restart, delete or reconfigure network interfaces. It also means to
  change, view or configure the routing table and to correct an
  improperly set default route manually.  Candidates should be able to
  configure Linux as a DHCP client and a TCP/IP host and to debug
  problems associated with the network configuration.
\end{frame}

\begin{frame}[allowframebreaks]
  \frametitle{Key files, terms, and utilities include:}
  \framesubtitle{1.112.3\ \ TCP/IP configuration and troubleshooting}%
\begin{description}
 \item[\texttt{/etc/HOSTNAME} or \texttt{/etc/hostname}] --- a text
   file holding the hostname
 \item[\texttt{/etc/hosts}] --- a file mapping IP addresses
   $\leftrightarrow$ hostnames
 \item[\texttt{/etc/networks}] --- an obsolete file that maps
   only classful network addresses $\leftrightarrow$ names
 \item[\texttt{/etc/host.conf}] --- an obsolete file replaced by \texttt{nsswitch}
 \item[\texttt{/etc/resolv.conf}] --- configuration file used when
   system looks up a name or address
 \item[\texttt{/etc/nsswitch.conf}] --- name service switch
   configuration file: determines how system looks up name and various
   other things
 \item[\texttt{ifconfig}] --- a command to show and configure network
   interfaces
 \item[\texttt{route}] --- a command to show and configure network routes
 \item[\texttt{dhcpcd}, \texttt{dhcpclient}, \texttt{pump}] --- DHCP clients
 \item[\texttt{host}] --- a program to query and debug DNS servers
 \item[\texttt{hostname (domainname, dnsdomainname)}] --- commands to
   show the hostname, and NIS domain settings
 \item[\texttt{netstat}] --- a command that shows what service is
   listening on what port
 \item[\texttt{ping}] --- sends ICMP \texttt{ECHO\_REQUEST} to hosts,
   displays time it takes to get an answer
 \item[\texttt{traceroute}] --- command to show the path that a
   network connection takes, showing routes along the way
 \item[\texttt{tcpdump}] --- packet sniffer command that displays the
   contents of packets received on a network interface
 \item[the network scripts run during system
                        initialization.]
\end{description}
\end{frame}

% \begin{frame}[fragile]

% \frametitle{TCP/IP Configuration and Troubleshooting}
% \framesubtitle{Objective}

% Candidates should be able to view, change and verify configuration
% settings and operational status for various network interfaces. This
% objective includes manual and automatic configuration of interfaces
% and routing tables. This especially means to add, start, stop,
% restart, delete or reconfigure network interfaces. It also means to
% change, view or configure the routing table and to correct an
% improperly set default route manually. Candidates should be able to
% configure Linux as a DHCP client and a TCP/IP host and to debug
% problems associated with the network configuration.

% \vspace{2em}
% \begin{center}
% \bfseries Weight: 7
% \end{center}
% \end{frame}
 

% \begin{frame}[fragile]

% \frametitle{TCP/IP Configuration and Troubleshooting}
% \framesubtitle{Key files, terms, and utilities}
% \begin{semiverbatim}
% /etc/HOSTNAME or /etc/hostname    ifconfig
% /etc/hosts                        route
% /etc/networks                     netstat
% /etc/host.conf                    host
% /etc/resolv.conf                  ping
% /etc/nsswitch.conf                tcpdump
% traceroute
% dhcpcd, dhcpclient, pump
% hostname (domainname, dnsdomainname)
% \textrm{the network scripts run during system initialisation}
% \end{semiverbatim}
% \end{frame}


\section{Resources}
\label{sec:resources}

% OH, UPDATE ME, PLEASE!!!
\begin{frame}
  \frametitle{TCP/IP Configuration and Troubleshooting}%
  \framesubtitle{Resources of Interest}%
  \begin{description}
  \item[Linux Networking HOWTO by Joshua Drake]:
    \url{http://tldp.org/HOWTO/Net-HOWTO/index.html}
  \item[Linux Ethernet-Howto by Paul Gortmaker]:
    \url{http://tldp.org/HOWTO/Ethernet-HOWTO.html}
  \end{description}
\end{frame}


\section{Configuring network interfaces}
\label{sec:ifconfig}

\begin{frame}
  \frametitle{\textbf{ifconfig} -- Low level network config}%
  Network interface configuration
  \par
  \cmd{sudo ifconfig eth0 192.168.7.26
    netmask 255.255.255.0
    broadcast 192.168.7.255}
  \par
  \cmd{sudo ifconfig eth0 down}
\end{frame}


\section{Adding routes with \texttt{route}}
\label{sec:route}

\begin{frame}[fragile]
  \frametitle{\textbf{route} -- Low level network config}%
  \cmd{sudo route add -net 192.168.7.0
    netmask 255.255.255.0
    dev eth0}
  \par
  \cmd{sudo route add default gw 192.168.7.1}
  \par\vspace{2em}\par
  View routing table:
  \cmd{route -n}
\end{frame}

\section{\texttt{netstat}}
\label{sec:netstat}

\begin{frame}
  \framesubtitle{\textbf{netstat} -- See network stuff}
  \begin{tabular}{@{}l>{\ttfamily}l@{}}
    Ports in use & netstat -a -u -t \\
    Routing table & netstat -r \\
    Interfaces & netstat -i \\
    Multicast groups & netstat -g \\
    Masqueraded connections & netstat -M \\
    Statistics & netstat -s \\
  \end{tabular}
\end{frame}

\section{Troubleshooting Tools}
\label{sec:troubleshooting-tools}

\begin{frame}
  \frametitle{Network debugging}%
  \begin{description}
  \item[ping]
    \begin{itemize}
    \item Try to bounce an \textsc{ICMP} packet off a host
    \item Good for reachability, round trip delay, packet loss
    \end{itemize}    
  \item[traceroute]
    \begin{itemize}
    \item Show the network path to a particular host
    \item Good for testing routing problems, ``which ISP screwed up''
    \end{itemize}    
  \item[tcpdump]
    \begin{itemize}
    \item Dump raw network traffic
    \item Exceptional for diagnosing network problems involving a
      particular host
    \end{itemize}
  \end{description}
\end{frame}


\subsection{Using tcpdump}
\label{sec:tcpdump}


\begin{frame}[fragile]
  \frametitle{\textbf{tcpdump} again}%
  \textbf{tcpdump} is your friend, learn to use it
\begin{semiverbatim}\scriptsize\mode<article>{
$ \textbf{sudo tcpdump -i ppp0 not port ssh}
tcpdump: listening on ppp0
21:54:32.913475 10.0.128.107.1024 > 10.0.128.97.domain:  20147+ A?
  fatso.urnet.com.au. (36) (DF)
21:54:33.102745 10.0.128.97.domain > 10.0.128.107.1024:  20147* 1/3/3 (178) (DF)
21:54:33.103766 10.0.128.107 > 203.26.250.2: icmp: echo request (DF)
21:54:33.352745 203.26.250.2 > 10.0.128.107: icmp: echo reply
21:54:34.102912 10.0.128.107 > 203.26.250.2: icmp: echo request (DF)
21:54:34.302745 203.26.250.2 > 10.0.128.107: icmp: echo reply
21:56:09.908636 10.0.128.107.1068 > 203.26.250.2.www: S 1245080954:1245080954(0)
 win 5840 <mss 1460,sackOK,timestamp 5047727 0,nop,wscale 0> (DF) [tos 0x10] 
21:56:10.052743 203.26.250.2.www > 10.0.128.107.1068: S 3633684004:3633684004(0)
 ack 1245080955 win 5792 <mss 1460,sackOK,timestamp 409734147 5047727,nop,wscale 0> (DF)
21:56:10.052869 10.0.128.107.1068 > 203.26.250.2.www: . ack 1 win 5840
 <nop,nop,timestamp 5047742 409734147> (DF) [tos 0x10]
21:56:12.977510 10.0.128.107.1068 > 203.26.250.2.www: P 1:2(1) ack 1
 win 5840 <nop,nop,timestamp 5048034 409734147> (DF) [tos 0x10]}\mode<presentation>{
$ \textbf{sudo tcpdump -i ppp0 not port ssh}
tcpdump: listening on ppp0
21:54:32.913475 10.0.128.107.1024 > 10.0.128.97.domain:  20147+ A?
  fatso.urnet.com.au. (36) (DF)
21:54:33.102745 10.0.128.97.domain > 10.0.128.107.1024:  20147* 1/3/3
 (178) (DF)
21:54:33.103766 10.0.128.107 > 203.26.250.2: icmp: echo request (DF)
21:54:33.352745 203.26.250.2 > 10.0.128.107: icmp: echo reply
21:54:34.102912 10.0.128.107 > 203.26.250.2: icmp: echo request (DF)
21:54:34.302745 203.26.250.2 > 10.0.128.107: icmp: echo reply
21:56:09.908636 10.0.128.107.1068 > 203.26.250.2.www:
 S 1245080954:1245080954(0) win 5840 <mss 1460,sackOK,timestamp
 5047727 0,nop,wscale 0> (DF) [tos 0x10] 
21:56:10.052743 203.26.250.2.www > 10.0.128.107.1068:
 S 3633684004:3633684004(0) ack 1245080955 win 5792 <mss
 1460,sackOK,timestamp 409734147 5047727,nop,wscale 0> (DF)
21:56:10.052869 10.0.128.107.1068 > 203.26.250.2.www: . ack 1 win 5840
 <nop,nop,timestamp 5047742 409734147> (DF) [tos 0x10]
21:56:12.977510 10.0.128.107.1068 > 203.26.250.2.www: P 1:2(1) ack 1
 win 5840 <nop,nop,timestamp 5048034 409734147> (DF) [tos 0x10]}
\end{semiverbatim}
\end{frame}


\section{hostname}
\label{sec:hostname}

% Should probably discuss relevance of NIS here, else people will
% think these are interchangable.

\begin{frame}
  \frametitle{\texttt{/etc/HOSTNAME} or \texttt{/etc/hostname}}%
  \begin{itemize}
  \item System scripts set the hostname from one of these files during
    boot, using the \textbf{hostname} command.
  \item \textbf{dnsdomainname}, \textbf{ypdomainname},
    \textbf{nisdomainname} and \textbf{domainname} are variations on
    \textbf{hostname}
    \par\vspace{2em}\par
  \item \textbf{domainname} gives the NIS domainname, \textbf{NOT the
      DNS domain}
  \end{itemize}
\end{frame}

\section{nsswitch.conf}
\label{sec:nsswitch.conf}

\begin{frame}[fragile]
  \frametitle{\texttt{/etc/nsswitch.conf}}%
  ``Name Service Switch'' configuration
\begin{semiverbatim}
passwd:         compat
group:          compat
shadow:         compat

hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis
\end{semiverbatim}
\end{frame}


\section{\texttt{/etc/networks}}
\label{sec:networks}


\begin{frame}
  \frametitle{\texttt{/etc/networks}}%
  \begin{itemize}
  \item Labels for network addresses
  \item Only supports class A, B or C addresses (not CIDR)
  \item Rarely used or kept up to date
    \texttt{localnet 192.168.1.0}
  \end{itemize}
\end{frame}


\section{\texttt{/etc/hosts}}
\label{sec:/etc/hosts}

\begin{frame}[fragile]
  \frametitle{\texttt{/etc/hosts}}%
  \begin{itemize}
  \item Hostname to IP address mapping, mostly superseded by DNS
  \item Still matters before DNS is running
  \end{itemize}
\begin{semiverbatim}\small
127.0.0.1	localhost
192.168.1.1	cat.pasture.com.au	cat

# The following lines are desirable for IPv6 capable hosts

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
\end{semiverbatim}
\end{frame}

\section{\texttt{/etc/host.conf}}
\label{sec:/etc/host.conf}

\begin{frame}[fragile]
  \frametitle{\texttt{/etc/host.conf} --- Resolver configuration}%
  \begin{itemize}
  \item Various keywords to tweak non-DNS-specific resolver behaviour
  \item Rarely modified; most options no longer relevant
  \item See \cmd{man host.conf}
  \end{itemize}
\begin{semiverbatim}
order hosts,bind
multi on
\end{semiverbatim}
\end{frame}

\section{\texttt{/etc/resolv.conf}}
\label{sec:resolv.conf}

\begin{frame}[fragile]
  \frametitle{\texttt{/etc/resolv.conf} --- DNS configuration}%
  \begin{itemize}
  \item DNS configuration for resolver
  \item Nameserver defaults to \texttt{127.0.0.1}, search suffix
    defaults to DNS domain name
  \end{itemize}
\begin{semiverbatim}
search pasture.com.au
nameserver 10.0.128.97
\end{semiverbatim}
\end{frame}

\section{Debugging DNS}
\label{sec:debugging-dns}

\subsection{\texttt{host}}
\label{sec:host}

\begin{frame}[fragile]
  \frametitle{Debugging DNS with \texttt{host}}%
  \begin{itemize}
  \item \textbf{\texttt{host}} performs various DNS queries
\begin{semiverbatim}
host \textit{[options]} hostname \textit{[server]}
\end{semiverbatim}
  \item Common options:
    \begin{description}
    \item[-v] verbose
    \item[-l] list all hosts in a domain (using AXFR)
    \item[-t] query type (``-t any'' is useful)
    \end{description}
  \end{itemize}
\end{frame}

\section{DHCP}
\label{sec:dhcp}

\begin{frame}
  \frametitle{DHCP}%
  \begin{itemize}
  \item ``Dynamic Host Control Protocol'' configures networking details,
    DNS, etc automatically by querying a ``\textsc{DHCP} server''
  \item Various \textsc{DHCP} clients:
    \begin{description}
    \item[dhcpclient]  Comes with \textsc{ISC} \textsc{DHCP} server,
      highly configurable
    \item[dhcpcd]
    \item[pump]  Simple \textsc{DHCP} client written by RedHat
    \item[udhcpc] Very small \textsc{DHCP} client
    \end{description}
  \end{itemize}
\end{frame}

\mode<presentation>
{%
\begin{frame}
  \frametitle{Topics Covered}
  %\footnotesize
  %\begin{multicols}{2}
    \tableofcontents[pausesections,pausesubsections]
  %\end{multicols}
  % You might wish to add the option [pausesections]
\end{frame}
}

\section{License Of This Document}
\label{sec:license}

\begin{frame}
  \frametitle{License Of This Document}%
  \raggedright%
  Copyright \copyright\ 2005, 2003 Angus Lees \texttt{gus@inodes.org},
  Geoffrey Robertson <ge@ffrey.com> and Nick Urbanik
  <nicku@nicku.org>.
  \par
  Permission is granted to make and distribute verbatim copies or
  modified versions of this document provided that this copyright
  notice and this permission notice are preserved on all copies under
  the terms of the GNU General Public License as published by the Free
  Software Foundation---either version 2 of the License or (at your
  option) any later version.
\end{frame}
\end{document}
