Advanced Administration
Advanced Administration
administration
Remo Suppi Boldrito
PID_00148471
GNUFDL • PID_00148471 Network administration
Copyright © 2009, FUOC. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free
Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections,
no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation
License"
GNUFDL • PID_00148471 Network administration
Index
Introduction............................................................................................... 5
2. TCP/IP Concepts................................................................................. 13
5. DHCP Configuration......................................................................... 35
6. IP aliasing............................................................................................ 37
7. IP Masquerade..................................................................................... 38
Activities...................................................................................................... 55
GNUFDL • PID_00148471 Network administration
Introduction
The TCP/IP is, in reality, a set of basic protocols that have been added to
the original protocol, to meet the different needs in computer-to-com-
puter communication, such as TCP, UDP, IP, ICMP, ARP. [Mal96]
TCP/IP is most frequently used by most current users to remotely connect to Note
other computers (telnet, SSH Secure Shell), to use remote files (NFS network
Typical use of TCP/IP remote
file system) or to transfer them (FTP file transfer protocol, HTTP hypertext markup login:
protocol). telnet localhost Debian
GNU/Linux 4.0
login:
1.1. Services on TCP/IP
• File�transfer: the file transfer protocol (FTP) allows the user of a computer
to obtain files or send them from one computer to another. In order to do
this, the user must have an account in the remote computer and identify
themselves through their login name and password or the user must con-
nect to computers containing an information repository (software, docu-
mentation etc.) under an anonymous account to read those computers on
their computer. This is not the same as the more recent Network File Sys-
tems (NFS) (or netbios protocols over TCP/IP, a completely insecure "in-
vention" in Windows, which should be replaced with an older but more
secure version called netbeui) that make it possible to virtualise the file
system in a machine so that it can be accessed interactively from another
computer.
The progress in the technology and the increasingly lower cost of computers
has meant that determined services have specialised and are now configured
on determined computers working in a client-server model. A server is a sys-
tem that performs specific services for the rest of the network or connected
clients. A client is another computer that uses this service. All of these services
are generally offered within TCP/IP:
On the one hand, TCP (transmission control protocol) defines the com-
munication rules so that a (host) computer can talk to another com-
puter (if we use the OSI/ISO communications model as a reference, it
describes layer 4, see following table).
In other words, it routes the data between two computers through the net-
works. It corresponds to layer 3 of the OSI/ISO model and it is a connection-
less protocol (see following table). [Com01, Rid00, Dra99]
An alternative to TCP is the UDP protocol (user datagram protocol), which treats
the data as a message (datagram) and sends packets. It is a connectionless pro-
tocol (the recipient computer does not necessarily have to be listening when
the other computer establishes communication with it) and it has the advan-
tage of creating less overload on the network than a TCP connection, but it is
less reliable (the packets may not arrive or arrive duplicated).
There is another alternative protocol called ICMP (Internet control message pro-
tocol). ICMP is used for error or control messages. For example, if one tries to
connect to a host computer, the local computer may receive an ICMP message
indicating "host unreachable". ICMP may also be used to extract information
on a network. ICMP is similar to UDP in that it handles messages (datagrams),
GNUFDL • PID_00148471 10 Network administration
but it is simpler than UPD, because it does not have port identification (the
ports are mailboxes where the data packets are left and where the server ap-
plications read the packets) in the message header.
To summarise, TCP/IP is a set of protocols including IP, TCP, UDP that provide
a set of low-level functions used by most of the applications. [KD00, Dra99].
Some of the protocols that use the abovementioned services were designed by
Berkeley, Sun or other organisations. They are not imcluded (officially) as part
of the Internet protocol suite (IPS). However, they are implemented using TCP/IP
and they are therefore considered as a formal part of IPS. A description of the
protocols available by Internet can be found in RFC 1011 (see references on
RFC [IET]). There is currently a new version of protocol IPv6, also called IPng
(IP next generation) which replaces IPv4. This protocol significantly improves
the previous ones in elements such as having a greater number of nodes, traffic
control, security or improvements in the routing.
From the physical point of view (layer 1 of the OSI model), the most com-
monly used hardware for LAN is that known as Ethernet (or FastEthernet or
GigaEthernet). Its advantages consist of a lower cost, acceptable speeds (10,
100 or 1,000 megabits per second) and its user-friendly installation.
The first two are obsolete (they used coaxial cable) whereas the last is through
twisted pair cables and connectors similar to those used by telephones (known
as RJ45). The twisted pair connection is known as 10baseT or 100baseT (ac-
cording to the speed) and it uses repeaters known as hubs as interconnec-
tion points. Ethernet technology uses intermediate communication elements
(hubs, switches, routers) to configure multiple segments of the network and
divide the traffic to improve the performance of the data transfer. Normally,
in large organisations, these Ethernet LAN are interconnected through fibre
optic cables using FDDI (fibre distributed data interface) technology, which is
more expensive and more difficult to install, but with which we can obtain
transmission speeds equivalent to Ethernet whilst not having the limits on
distance involved in Ethernet (FDDI allows for distances of up to 200 km).
The costs are justified when they are used between buildings or other network
segments that are very congested. [Rid00, KD00].
At the same time, there are other types of hardware that are less common, but
no less interesting, such as ATM (asynchronous transfer mode). This hardware
allows us to set up a LAN with a high level of service quality and it is a good
option when we have to set up high-speed and low-latency networks, such as
those that require real time video streaming.
Example
In GNU/Linux, Ethernet is called with ethx (where, "x" indicates an order number begin-
ning with 0), the interface to serial lines (modems) is called up with pppx (for PPP) or slx
(for SLIP); fddix is used for FDDI. These names are used by the commands to configure
them and assign them the identification that will subsequently permit them to commu-
nicate with other devices in the network.
GNUFDL • PID_00148471 12 Network administration
In GNU/Linux, this may mean that we have to include the appropriate mod- Note
ules for the appropriate device (NIC network interface card) in the kernel or as
How do we see the network
modules, and this means compiling the kernel after choosing, the appropri- interfaces that are available?
ate NIC, with, for example, make menuconfig, indicating it as internal or as a ifconfig -a
module (in the latter case, the appropriate module must also be compiled). This command shows all of the
default interfaces/parameters
for each one.
The network devices can be seen in the /dev directory, where there is a file
(a special file, which may be a block file or a character file, according to the
transfer) that represents each hardware device.[KD00, Dra99].
GNUFDL • PID_00148471 13 Network administration
2. TCP/IP Concepts
• Node: the (host) node refers to a machine that is connected to the network
(in a wider sense, a node may be a computer, a printer, a CD (rack) etc.);
in other words, an active and differentiable element in the network that
requires or provides some kind of service and/or shares information.
• Host�name: each node must also have a unique network name. These may Note
simply be names or they may use a scheme based on a hierarchical domain
Machine IP address:
naming scheme. The names of the nodes must be unique, which is easy
more /etc/hosts
in small networks, more complex in large networks and impossible on the
Internet unless some form of control is implemented. The names must
have a maximum of 32 characters within the a-z, A-Z and 0-9 ranges and
they may not contain spaces or # beginning with an alphabetic character.
• Internet� Address (IP address): this consists of four numbers within the Note
range of 0-255 separated by dots (for example, 192.168.0.1) and it is used
Pre-assigned ports in UNIX:
universally to identify the computers on a network or on the Internet.
more /etc/services
The names are translated into IP addresses by a DNS (domain name system) This command shows the
server, that transforms the node names (legible to humans) in IP addresses ports predefined with support
to TCP or UDP communica-
(this service is performed by an application called named). tions.
• Port: numerical identifier of the mailbox in a node that allows a specific Note
application to read a message (TCP,UDP) (for example, two machines that
Visualisation of the routing's
communicate by telnet, will do so through port 23, but if they have a FTP configuration:
transaction they will do so through port 21). There may be different ap- netstat -r
GNUFDL • PID_00148471 14 Network administration
• Router�node (gateway): it is a node that performs the routing (data trans- Note
fer). A router, depending on its characteristics, may transfer information
Domain and our DNS server is:
between two similar or different network protocols and may also be selec-
more /etc/default do-
tive. main
more /etc/resolv.conf
• DHCP,�bootp: DHCP and bootp are protocols that permit a client node to
obtain information on the network (such as the node's IP address). Many
organisations with many machines use this mechanism to facilitate the
administration of large networks or networks in which there are roaming
users.
• ARP,�RARP: in some networks (such as IEEE 802 LAN, which is the stan-
dard for Ethernet), the IP addresses are dynamically discovered through
the use of two other members of the Internet protocol suite: address reso-
lution protocol (ARP) and reverse address resolution protocol (RARP). ARP uses
broadcast messages to determine the Ethernet address (MAC specification
for layer 3 of the OSI model), corresponding to a particular network-layer
address (IP). RARP uses broadcast messages (messages that reach all of the
nodes) to determine the network-layer address associated with a particu-
lar hardware address. RARP is especially important to diskless nodes, for
which network-layer addresses are usually unknown at boot time.
The way for a programmer to use them is through an API (application program-
ming interface) which implements this source-code interface. For TCP/IP, the
most common API is the Berkeley Socket Library (Windows uses an equivalent
library that is called Winsocks). This library makes it possible to create a com-
munication end-point (socket), associate it to a remote node and port (bind)
and offer the communication service (through connect, listen, accept, send, send-
to, recv, recvfrom, for example). The library also provides a more general com-
munication mode (AF INET family) and more optimised communications for
cases in which the process are communicating within the same machine (AF
UNIX family). In GNU/Linux, the socket library is part of the C standard li-
brary, Libc, (Libc6 in current versions), and it supports AF_INET, AF_UNIX,
AF_IPX (for Novell protocols), AF_X25 (for the X.25 protocol), AF_ATMPVC-
AF_ATMSVC (for the ATM protocol) and AF_AX25,F_NETROM, AF_ROSE (for
amateur radio protocol).
GNUFDL • PID_00148471 16 Network administration
This address is assigned by the NIC and it has two section or parts.
The one on the left represents network identification and the one on
the right represents the node identification. In consideration of the
point mentioned above (four numbers between 0-255, or 32 bits or four
bytes), each byte represents either the network or the node. The NIC
assigns the net and the institution (or provider) assigns the node.
There are some restrictions: 0 (for example, 0.0.0.0) in the network space is
reserved for the routing by default and 127 (for example, 127.0.0.1) is reserved
for the (local loopback or local host), 0 in the node part refers to this net-
work (for example,192.168.0.0) and 255 is reserved for sending packets to all
(broadcast) machines (for example, 198.162.255.255). There may be different
types of networks or addresses in the different assignations:
Some address ranges have been reserved so that they do not correspond to
public networks, and are considered private networks (interconnected com-
puters without external connection; the messages will not be sent through
Internet, but through an intranet). These address ranges are class�A 10.0.0.0
to 10.255.255.255, class�B 172.16.0.0 to 172.31.0.0 and class�C 192.168.0.0
to 192.168.255.0.
network and all nodes on the network will be able to read them. For example,
when ARP tries to find the Ethernet address corresponding to an IP, it uses a
broadcast message, which is sent to all the machines on the network at the
same time. Each node in the network reads this message and compares the IP
that is being searched and sends back a message to the sender node if they
match.
Two concepts that are related to the point described above are the subnets
and� routing between these subnets. Subnets subdivide the node part into
smaller networks within the same network, so as to, for example, improve the
traffic. A subnet is in charge of sending traffic to certain IP address ranges,
extending to the same concept of Class A, B and C networks, but only apply-
ing this rerouting in the IP node part. The number of bits interpreted as a
subnet identifier is provided by a netmask, which is a 32-bit number (as is an
IP). In order to obtain the subnet identifier, we will have to perform a logical
AND operation between the mask and the IP, which will provide us with the
subnet IP. For example, an institution with a B class network, with number
172.17.0.0, would therefore have a netmask with number 255.255.0.0. Inter-
nally, this network is formed by small networks (one per floor in the building,
for example). In this way, the range of addresses is reassigned in 20 subnets
(floors in our example, except 172.17.1.0, that has a special role), 172.17.1.0
to 172.17.20.0. The point that connects all these floors, called the backbone,
has its own address, for example 172.17.1.0.
These subnets share the same network IP, whereas the third is used to iden-
tify each of the subnets within it (which is why it will use the netmask
255.255.255.0).
The second concept, routing, represents the mode in which the messages are
sent through the subnets. For example, let us say there are three departments
with Ethernet subnets:
In order to route the messages between the computers on the three networks,
we need three gateways that will each have two network interfaces to switch
between Ethernet and FFDI. These would be:
When messages are sent between machines in the purchases area, it is not
necessary to leave the gateway, as the TCP/IP will find the machine directly.
The problem arises when the Purchases0 machine wishes to send a message to
HumanResources3. The message must pass through the two respective gate-
ways. When Purchases0 "sees" that HumanResources3 is on another network,
it sends the packet through the PurchasesGW gateway, which in turn sends
it to HumanResourcesGW, which, in turn, sends it to HumanResources3. The
advantage of having subnets is obvious, given that the traffic between all the
purchases machines, for example, will not affect the Clients or Human Re-
sources machines (although this is more complex and expensive in terms of
designing and building the network).
IP uses a table to route the packets between the different networks, in which
there is a default routing associated to net 0.0.0.0. All the addresses coincide
with this one, as none of the 32 bits are necessary; they are sent through the
default gateway to the indicated network. In the purchasesGW, for example,
the table would be:
The '-' means that the machine is directly connected and does not need rout-
ing. The procedure for identifying whether routing is required or not consists
of performing a very simple operation with the two logic ANDs (subnet AND
GNUFDL • PID_00148471 19 Network administration
mask and origin AND mask) and comparing the two results. If they match,
there is no routing, but the machine defined as gateway must be sent in each
machine, so that this machine routes the message.
As the results are the same, there would be no routing. On the other hand, if
we do the same from 172.17.2.4 to 172.17.6.6 we see that there will be rout-
ing through 172.17.2.1 with an interface change (eth0 to ffdi0) to 172.17.1.1
and from here to 172.17.1.2 with another interface change (fddi0 to eth0) and
then to 172.17.6.6. The default routing will be used when none of the rules
match. If two rules match, the routing that matches the most precisely, in
other words, the one with the least zeros, will be used. In order to build the
routing tables, we can use the route command during machine startup; how-
ever, if it is necessary to use more complex rules (or automatic routing), we
can use the routing information protocol (RIP) command or, between indepen-
dent systems, the external gateway protocol (EGP) or also the border gateway pro-
tocol (BGP) commands. These protocols are implemented through the gated
command.
Once the GNU/Linux kernel has loaded, it executes the init command, which,
in turn, reads the configuration file /etc/inittab and begins the start up pro-
cess. Generally, the inittab has sequences such as: si::sysinit: /etc/init.d/boot,
which represents the name of the commands file (script) that controls the
booting sequences. Generally, this script calls the other scripts, which include
the network startup script.
Example
The network devices are created automatically when the corresponding hard- Note
ware starts up. For example, the Ethernet driver creates the eth[0..n] interfaces
Consult
sequentially, when the corresponding hardware is located.
man ifconfig
for the different command op-
The network interface may be configured as of that moment, which requires tions.
two steps: assign the network address to the device and boot the network
parameters to the system. The command used for this is ifconfig (interface
configure). An example might be:
Which indicates that the eth0 device should be configured with IP address
192.168.110.23 and netmask 255.255.255.0. Up indicates that the interface
will be activated (to deactivate it, execute ifconfig eth0 down). If no values are
specified, the command assumes that the default values should be used. In the
previous example the kernel will configure this machine as a C-Type machine
with IP=192.168.110.23 and the broadcast address=192.168.110.255.
There are commands, such as ifup and ifdown, that make it possible to config-
ure/unconfigure the network more simply using the /etc/network/interfaces
file to obtain all the necessary parameters (consult man interfaces for syntax).
GNUFDL • PID_00148471 21 Network administration
In Debian, there is another simpler method for configuring the network (con-
sidered high-level), which uses the abovementioned commands ifup, ifdow-
nand the /etc/network/interfaces file. If we decide to use these commands, we
should not configure the network at low-level, as these commands are suffi-
cient for configuring/unconfiguring the network.
In order to modify the parameters of the eth0 interface network, we can (con-
sult man interfaces in section 5 of the Unix manual included with the operat-
ing system for more information):
If we have installed the resolvconf packet, we can add lines to specify the DNS
information. For example:
gateway 192.168.0.1
dns-search remix.org
dns-nameservers 195.238.2.21 195.238.2.22
After the interface has been activated, the command line arguments of the
options dns-search and dns-nameservers are available for resolvconf for inclu-
sion in resolv.conf. The command line argument remix.org of the dns-search
option corresponds to the argument of the search option in resolv.conf (we
will look at this in more detail later) and the arguments 195.238.2.21 and
195.238.2.22 of the dns-nameservers option corresponds to the arguments of
the nameserver options in resolv.conf (consult man resolv.conf). It is also pos-
sible to configure the network at low-level through the ip command (which
is equivalent to ifconfig and route). Although this command is much more
versatile and powerful (it can be used to establish tunnels, alternate routings
etc.), it is more complex and it is recommendable to use the preceding proce-
dures for basic network configurations.
GNUFDL • PID_00148471 22 Network administration
Red Hat and Fedora use a different file structure for network configuration:
/etc/sysconfig/network. For example, to configure the network statically:
/etc/sysconfig/network-scripts/ifcfg-eth0:
DEVICE=eth0
BOOTPROTO=static
BROADCAST=XXX.XXX.XXX.255
IPADDR=XXX.XXX.XXX.XXX
NETMASK=255.255.255.0
NETWORK=XXX.XXX.XXX.0
ONBOOT=yes Activates the network on boot.
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
Let's assume that we wish to configure an Intel Pro/Wireless 2200BG wireless network
card (very common in many laptops, such as Dell, HP...). The software that controls
the cards is usually divided into two parts: the software module that will be loaded in
the kernel through the modprobe command and the firmware that is the code that will
be loaded in the card and which is given to us by the manufacturer (consult the Intel
site for this model). As we are discussing modules, it is interesting to use the Debian
module-assistant package which allows us to create and install a module easily (another
option would be to install the sources and create the corresponding module). We will
compile and install the software (which we can find on the manufacturers' website and
is called ipw2200) using the m-a command in the module-assistant package.
We can download the compatible firmware version from the site address provided by the
manufacturer (in the product documentation) along with the version of the driver we
need, which in our case, would be driver version 1.8 and firmware version 2.0.4, obtained
from the following address:
http://ipw2200.sourceforge.net/firmware.php
We should then download the wireless tools package that contains iwconfig
in order to install wireless tools with aptget, among others, and if we execute
iwconfig, something similar to the following will display:
We must then configure the network file, for example, gedit /etc/network/interfaces, and
add the eth1 wifi interface, for example:
The pre-up lines execute the iwconfig command before activating the interface. This config-
uration is used if we wish to use the service in DHCP mode (automatic IP assignation, as we
shall see). Instead of DHCP, the word static should be used and the following lines, as an
example, must be entered (as in a cable card):
address 192.168.1.132
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.1.1
We can then start up the network with ifup eth1 and we will be given information on the
connection and the state and quality of reception. In order to scan the available WiFi net-
works (access points), we can use iwlist scan, which will show us information on the avail-
able networks, and if we want to connect to a different network, we can use the iwconfig
command to change the network or Access Point.
GNUFDL • PID_00148471 25 Network administration
The next step is to configure the name resolver, which changes names like
pirulo.remix.com to 192.168.110.23. The /etc/resolv.conf file is used for this.
The format is very simple (one line of text per sentence). There are three
key words for this purpose: domain (local domain), search (list of alternate do-
mains) and name server (IP address of the domain name server).
Example of /etc/resolv.conf
domain remix.com
search remix.com piru.com
name server 192.168.110.1
name server 192.168.110.65
This list of name servers often depends on the network environment, which
may change depending on where the machine is or where it is connected.
The programs for connecting to telephone lines (pppd) or obtaining IP ad-
dresses automatically (dhclient) can modify resolv.conf to insert or delete
servers; but these characteristics do not always work properly and they can
sometimes generate conflicts or incorrect configurations. The resolvconf
package adequately solves the problem and allows us to configure the name
servers easily and dynamically. resolvconf is designed to work without the
user having to configure anything manually; however, the package is quite
new and may require some manual assistance to make it work properly. For
more information:
http://packages.debian.org/unstable/net/resolvconf
Example of /etc/host.conf
order hosts,bind
multi on
The consulting process is much faster, but the disadvantage is that, if the node
changes, the address will be incorrect. In a system that is properly configured,
only the local node and an input for the loopback interface should appear.
GNUFDL • PID_00148471 26 Network administration
Example of /etc/hosts
Aliases may be used for the name of a machine; this means that this machine
may have different names for the same IP address. The loopback interface
is a special type of interface that makes it possible for a node to connect to
itself (for example, to verify that the network subsystem is working without
accessing the net). By default, the IP address 127.0.0.1 has specifically been
assigned to the loopback (a telnet 127.0.0.1 command will connect with
the same machine). Configuring aliases is very easy (generally, the network
startup script configures them).
Example of loopback
ifconfig lo 127.0.0.1
route add host 127.0.0.1 lo
Another aspect that has to be configured is the routing. Although the process Note
is considered to be very complex, in general, the routing requirements are
Consultation of routing tables:
very simple. In a node with multiple connections, routing consists of deciding
route -n
where to send and what to receive. A simple node (one single network connec- or also
netstat -r
tion) also needs routing, given that all the nodes have a loopback and a net-
work connection (for example, Ethernet, PPP, SLIP...). As we have explained,
there is a table known as a routing table that contains rows with various fields,
three of which are especially important: destination address, interface through
which the message will be sent and IP address, which will take the next step
in the gateway.
The route command can be used to modify this table so as to carry out
the appropriate routing tasks. When a message arrives, the destination
address is examined, compared with the entries in the table and sent
through the interface with the address that most resembles the packet's
destination. If a gateway is specified, it is sent to the appropriate inter-
face.
Let us assume, for example, that our node is in a C class network with the
address 192.168.110.0 and the address is 192.168.110.23; and the router con-
nected to the Internet is 192.168.110.3. The configuration will be:
• Subsequently, indicate that all the datagrams for nodes with 192.168.0.*
addresses must be sent to the network device:
route�add�-net�192.1�ethernetmask�255.255.255.0�eth0
-net indicates that it is a network route but -host 192.168.110.3. may also be
used. This configuration will allow it to connect with all the nodes within a
network segment (192.1), but, what would happen if we wanted to connect
with another node outside this segment? It would be very difficult to have all
the appropriate entries for all the machines to which we wish to connect. To
simplify this task, we have the default route, which is used when the destination
address does not match any of the entries in the table. One configuration
possibility would be:
route�add�default�gw�192.168.110.3�eth0
The bar (\) indicates that the command continues on the following line. The
result:
ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:46:7A:02:B0
inet addr:192.168.0.111 Bcast: 192.168.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
...
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
...
route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.0.0 U 0 0 0 eth0
10.0.0.0 192.168.0.1 255.0.0.0 UG 0 0 0 eth0
For more information, see the ifconfig (8) and route (8) commands.
The next step in the configuration of the network is to configure the servers
and services that will allow another user to access the local machine or its
services. The server programs will use the ports to listen to the requests from
the clients, which will be sent to this service as IP:port. The servers may work
in two different ways: standalone (in which the service listens to the assigned
port and is always active) or through inetd.
GNUFDL • PID_00148471 29 Network administration
The inetd is a server that controls and manages the network connec-
tions of the services specified in the /etc/inetd.conf file, which, when
a service request is made, starts up the appropriate server and transfers
the request.
echo 7/tcp
echo 7/udp
...
ftp 21/tcp
telnet 23/tcp
# 24 - private
...
The /etc/inetd.conf file is the configuration for the master network service
(inetd server daemon). Each line contains seven fields separated by spaces: ser-
vice socket_type proto flags user server_path server_args, where service is the service
described in the first column in /etc/services, socket_type is the type of socket
(possible values are stream, dgram, raw, rdm, or seqpacket), proto is the protocol
that is valid for this input (it must match that in /etc/services), flags indicates
the action that should be taken when there is a new connection on a service
that is attending another connection, (wait tells inetd not to start up a new
server or nowait means that inetd must start up a new server). user will be the
local user-name with which the client that has started up the service is iden-
tified, server_path is the directory where the server is located and server_args
GNUFDL • PID_00148471 30 Network administration
are possible arguments that will be passed to the server. An example of some
/etc/inetd.conf lines is (# is a comment, so if a service has # before the name,
it means that it is not available):
...
telnet stream tcp nowait root /usr/sbin/tcpd /usr/sbin/in.telnetd
ftp stream tcp nowait root /usr/sbin/tcpd /usr/sbin/in.ftpd
# fsp dgram udp wait root /usr/sbin/tcpd /usr/sbin/in.fspd
shell stream tcp nowait root /usr/sbin/tcpd /usr/sbin/in.rshd
login stream tcp nowait root /usr/sbin/tcpd /usr/sbin/in.rlogind
# exec stream tcp nowait root /usr/sbin/tcpd /usr/sbin/in.rexecd...
...
As of Debian Woody 3.0 r1, the inetd function has been replaced by xinetd
(recommendable), which needs the /etc/xinetd.conf configuration file
(see end of unit). If we wish to start up the inetd service, we must execute
(and create the appropriate links in the /etc/rcX.d directories) /etc/
init.d/inetd.real start (see the end of this chapter for examples of con-
figurations).
Apart from the inetd or xinetd configuration, the typical configuration of net-
work services in a desktop or basic server environment might also include
(some of these services will be examined in the chapter on servers):
• ssh: secure interactive connection to replace telnet that includes two con-
figuration files /etc/ssh/ssh_config (for the client) and /etc/ssh/
sshd_config (for the server)
• tcpd: Filtering services for enabled and disabled machines and domains
for connecting to the server (wrappers): /etc/hosts.allow, /etc/
hosts.deny
• lpr: daemon for the printing system, /etc/printcap (for the Ipr system
-not CUPS-)
There are other configuration files that are hardly ever used, but that can be
interesting. The /etc/protocols is a file that shows the protocol identifiers with
the protocol names; in this way, the programmers can specify the protocols
by their names in the programs.
Example of /etc/protocols
The /etc/networks file has a function similar to /etc/hosts, but where the net-
works are concerned, it shows the network names in relation to its IP address
(the route command will show the name of the network and not its address
in this case).
Example of /etc/networks
loopnet 127.0.0.0
localnet 192.168.0.0
amprnet 44.0.0.0 ...
• Modify the /etc/ftpusers file to deny access to certain users who may have
an FTP connection to your machine.
• Use the tcpd program. This server is a wrapper that makes it possible to
allow/deny a service from a given node and it is placed in /etc/inetd.conf
as a service intermediary. The tcpd verifies certain access rules in two files:
/etc/hosts.allow /etc/host.deny.
Example of access.conf
It permits access to u1, u2, g1 and all those in the remix.com domain:
+:u1 u2 g1 .remix.com:ALL
4.7. IP Options
There are further options with regard to IP traffic that we should mention.
This is configured by starting up the corresponding file in the /proc/sys/
net/ipv4/ directory. The file name is the same as the command and a 1 must
be placed in the file to activate them, or a 0 to deactivate them.
Example
The most widely used are: ip_forward used for routing between interfaces or
with IP Masquerading; ip_default_ttl, which is the lifetime for an IP packet (64
milliseconds, by default) ip_bootp_agent logical variable (BOOLEAN) which
accepts packets (or not) with the origin address of the 0.b.c.d type and the
destination of this node, broadcast or multicast.
ifconfig
cat /proc/pci
cat /proc/interrupts
dmesg | more
In order to verify the network connection, we can use the following com-
mands (netkit-ping, traceroute, dnsutils, iptables and net-tools must be in-
stalled):
5. DHCP Configuration
Configuring the server requires more care, but it is not especially complicated.
First, for the server to serve all the DHCP clients (including Windows), we
must address some questions concerning the broadcast addresses. In order to
do this, first the server must be able to send messages to the 255.255.255.255
address, which is not valid in GNU/Linux. In order to try this, execute:
The configuration of dhcpd can be carried out with the graphic interface of
linuxconf (not advisable) or by editing /etc/dhcpd.conf. An example of this
file is:
# Example of /etc/dhcpd.conf:
default-lease-time 1200;
max-lease-time 9200;
option domain-name "remix.com";
deny unknown-clients;
deny bootp;
option broadcast-address 192.168.11.255;
option routers 192.168.11.254;
option domain-name-servers 192.168.11.1,192.168.168.11.2;
subnet 192.168.11.0 netmask 255.255.255.0
{ not authoritative;
range 192.168.11.1 192.168.11.254
host marte {
hardware ethernet 00:00:95:C7:06:4C;
GNUFDL • PID_00148471 36 Network administration
This will allow the server to assign the address range from 192.168.11.1 to
192.168.11.254, as described for each node. If the corresponding host { ... }
segment does not exist, they will be assigned randomly. The IPs are assigned
for a minimum time of 1,200 seconds and a maximum of 9,200 (if these pa-
rameters do not exist, they will be assigned indefinitely).
6. IP aliasing
Let us say that we have an Ethernet network that supports two different IP
subnets simultaneously and that our machine wants to have direct access to
them. An example of the configuration would be:
Which means that we would have two IPs, 192.168.110.23 and 192.168.10.23
for the same NIC. In order to delete an alias, add a '-' at the end of the name
(for example, ifconfig eth0:0- 0). [Mou01, Ran05]
The eth0:0 interface is a virtual interface and its parent interface, eth0, will
activate when it does.
GNUFDL • PID_00148471 38 Network administration
7. IP Masquerade
This means that some services will not work (for example, talk) and others
must be configured in PASV (passive) mode for them to work (for example,
FTP). However, WWW, telnet or IRC will work properly. The kernel must be
configured with the following options: Network firewalls, TCP/IP networking,
IP: forwarding/gatewaying, IP: masquerading. Normally, the most common
configuration is to have a machine with a SLIP or PPP connection and to have
another network device (for example, an Ethernet card) with a reserved net
address. As we have seen and as described in RFC 1918, the following address
ranges (IP/Mask) can be used as private IPs: 10.0.0.0/255.0.0.0, 172.16.0.0/
255.240.0.0, 192.168.0.0/255.255.0.0. The nodes that must be masqueraded
will be on this second network. Each of these machines must have the address
of the machine that is masquerading such as default gateway or router. On
this machine, we can configure:
The IP network address translation, NAT, is a replacement that has made the fea-
tures of GNU/Linux IP Masquerade obsolete and that provides new features to
the service. One of the improvements included in the TCP/IP stack of GNU/
Linux 2.2 is that NAT is integrated into the kernel. In order to use it, we have
to compile the kernel with:
And if we need comprehensive control of the NAT rules (for example, to acti-
vate the firewall we must also have
In order to work with these new features, we need to use the ip program (which
can be obtained at ftp://ftp.inr.ac.ru/ip_routing/). Then, to translate the in-
coming datagram addresses, we can use:
The first makes the internal address 192.109.0.2 accessible as 240.0.11.34. The
second remaps the 192.109.0.0/31 block to 240.0.11.32/63. In this case, we
have used, as an example, translations to class D and E addresses, such as
240.0.*.* so as not to use a public address. The user must replace these address-
es (240.0.11.34 and 240.0.11.3263) for the corresponding public addresses to
which they wish to translate. [Ran05]
GNUFDL • PID_00148471 40 Network administration
To start with, we must have the following information: the modem init-string
(this is not normally necessary but if it is and it is not available, we can use
ATZ, which works in most modems or we can consult specialised init-string
lists).
We also need the ISP data: connection ID (login name), password and tele-
phone number. The DNS addresses would be advisable, but this is optional
in the current versions of pppd. Also, we should verify that the modem is
connected properly. With an external modem, we must execute echo > /dev/
ttyS0 and check the LEDs on the modem to see if it is active. Otherwise, try
with ttyS1, if the modem is connected to the 2nd serial port. With an internal
modem, check the supported hardware manual to see if this modem can be
recognised by GNU/Linux; if this is the case, it may be necessary to reconfig-
ure the kernel in order to use it. We can also use cat /proc/pci in case it is in
the PCI bus. [PPP00]
The easiest way to configure the modem now is through the kppp package (we
must install the kdenetwork-ppp* and ppp* packages). On a terminal, execute
/usr/bin/kppp. On the window, fill in the following boxes:
After entering the login name and password, we will be connected to the In-
ternet (to check that we are connected, execute ping www.google.com for exam-
ple). Here, we have used the kppp package, but we could as easily have used
linuxconf or gnomeppp indistinctly).
Once PPP has been configured, for it to work with, for example, my_isp, we
must edit /etc/network/interfaces so that it includes a section such as the fol-
lowing (the ifup, ifdown commands use the pon and poff commands to config-
ure PPP interfaces):
pon my_isp
Many broadband Internet Service Providers (ISP) use PPP to negotiate the con-
nection even when the clients' machines are connected through Ethernet and/
or ATM networks. This is achieved through PPP over Ethernet (PPPoE) which is
a technique for encapsulating PPP flow within Ethernet frames. Suppose that
the ISP is called my_isp. First, we must configure PPP and PPPoE for my _isp.
The easiest way of doing this consists of installing the pppoeconf package and
executing pppoeconf from the console. We then edit /etc/network/interfaces so
that it includes a fragment such as the following:
Sometimes, problems arise with PPPoE that are related to the maximum trans-
mit unit (or MTU) in DSL (digital subscriber line) lines; you may consult DSL-
HOWTO for further details. If the modem has a router, as the modem/router
will handle the PPPoE connection on its own and it will appear on the LAN
side as a simple Ethernet to Internet gateway.
GNUFDL • PID_00148471 43 Network administration
The hotplug package supports hot swapping when booting (the package in
question must have been installed). The network hardware can be hot plugged
either at start up, after inserting the card in the machine (a PCMCIA card, for
example) or after a utility such as discover has been executed and the neces-
sary modules have been loaded. When the kernel detects new hardware, it
starts up the driver for the hardware and then executes the hotplug program
to configure it. If the hardware is subsequently removed, the program exe-
cutes hotplug again, with different parameters. In Debian, when hotplug is
called, this executes the scripts of /etc/hotplug/ and /etc/hotplug.d/.
The network hardware that was recently connected is configured by /etc/
hotplug/net.agent. Let us assume that the PCMCIA network card has been
connected, which would mean that the eth0 interface would be ready to be
used. /etc/hotplug/net.agent performs the following:
ifup eth0=hotplug
mapping hotplug
script echo
If you only want eth0 to hotplug and not other interfaces, use grep instead
of echo as follows:
mapping hotplug
script grep
map eth0
In order to associate a Wi-Fi card with an access point, we may have to pro-
gram it with an appropriate WEP encryption code. If ifplugd is being used to
control ifup, as we have explained, then evidently it will not be able to con-
GNUFDL • PID_00148471 44 Network administration
figure the encryption code using ifup, as this is only called once the card has
been associated. The simplest solution is to use waproamd, which configures
the WEP encryption code according to the available access points that are dis-
covered through a WiFi network search. For more information, consult man
waproamd and the information on the package.
GNUFDL • PID_00148471 45 Network administration
This means that we have a network with connected VPN nodes tunnelled
through another network, through which the traffic passes and with which
no one can interact. It is used when remote users wish to access a corporate
network to maintain the security and privacy of the data. Various methods
can be used to configure a VPN, such as SSH (SSL), CIPE, IPSec, PPTP; they can
be consulted in the bibliography (we recommend consulting VPN PPP-SSH
HOWTO, by Scott Bronson and VPN-HOWTO by Matthew D. Wilson). [Bro01,
Wil02].
In order to perform the configuration tests in this section, we will use Open-
VPN, which is a solution based on SSL VPN and can be used for a wide range
of solutions, for example, remote access, VPN point to point, secure WiFi net-
works or distributed corporate networks. OpenVPN implements OSI layer 2 or
3 using SSL/TLS protocols and supports authentication based on certificates,
smart cards and other confirmation methods. OpenVPN is not a proxy appli-
cations server and does not operate through a web browser.
Then, we must copy the static.key file in the other peer over a secure chan-
nel (using ssh or scp, for example). The server configuration file of the
openVPN_server for example:
dev tun
ifconfig 10.8.0.1 10.8.0.2
secret static.key
remote myremote.mydomain
dev tun
ifconfig 10.8.0.2 10.8.0.1
secret static.key
Before verifying that the VPN works, we must verify the firewall to check that
port 1194 UDP is open on a server and that the virtual interface tun0 used
by OpenVPN is not blocked either over the client or over the server. Bear in
mind that 90% of the connection problems faced by new OpenVPN users are
related in some way to the firewall.
In order to verify the OpenVPN between two machines, we must change the
IPs for the real ones and the domain for the corresponding one, and then
execute the server side.
In order to check that it works, we might ping 10.8.0.2 from the server and
ping 10.8.0.1 from the client. For more information, please check http://
openvpn.net/howto.html.
To add compression to the link, we must add the following line to the two
configuration files:
comp-lzo
keng-timer-rem
persist-tun
peepalive 10 60
pirsist-key
To execute as a daemon with the privileges of the nobody user/group, add the
following to the configuration files:
user nobody
group nobody
Daemon
GNUFDL • PID_00148471 48 Network administration
There is a set of additional packages (that replace the conventional ones) and
tools that either improve the machine's security (recommended in hostile en-
vironments) or help to configure the network (and the system in general) in
a more user-friendly style.
• Does not respond to ICMP packages, such as the ping command for ex-
ample, which could mean that there is a denial-of-service (DoS) attack.
net.ipv4.icmp_echo_ignore_broadcasts = 1
• Useful for avoiding ICMP redirect acceptance attacks (these packages are
used when the routing does not have the appropriate route) in all the
interfaces.
net.ipv4.icmp_ignore_bogus_error_responses = 1
• The following parameters will permit the machine to attend the TCP con-
nections faster and better.
net.ipv4.tcp_fin_timeout = 40, By default, 60.
net.ipv4.tcp_keepalive_time = 3600, By default, 7.200.
net.ipv4.tcp_window_scaling = 0
net.ipv4.tcp_sack = 0
net.ipv4.tcp_timestamps = 0, By default, all at 1 (enabled).
• GnuPG: this tool makes it possible to encrypt data for subsequent send-
ing (emails, for example) or storage, it can also generate digital signatures
(it meets the RFC2440 standard) and it does not use patented algorithms,
which means that is open source, but we lose compatibility with other
tools (for example, PGP 2.0), which use algorithms such as IDEA and RSA.
For compiling and/or installing the tool, follow the instructions of the
programmers at http://www.gnupg.org/. Firstly, we must create a pair of
keys (public and private) by executing, in root, the gpg --gen-key com-
mand twice and answering the questions that appear. Generally, these keys
will be stored in /root. Then we export (to a website, for example) the pub-
lic key so that other users can use it to encrypt the mail/information that
may only be seen by the user that generated the public key. For this, we
must use gpg --export -ao UID, which will generate an ASCII file of
the UID user's public key.
In order to import another user's public key, we can use gpg --import
filename, and to sign a key (which is to tell the system that we are satis-
fied that the signed key is from who it says it is), we can use gpg --sign-
key UID. To verify a key, we can use gpg --verify file/data and to
encrypt/decrypt a key, gpg -sear UID file g, gpg -d file, respectively. [Gnu]
# xinetd.conf
# The default configuration options that are applied to all the
# servers may be modified for each service
defaults
{
instances = 10
log_type = FILE /var/log/service.log
log_on_success = HOST PID
log_on_failure = HOST RECORD
}
# The name of the service must be located in /etc/services to obtain
# the right port
# If the server/Port is not a standard one, use "port = X"
service ftp
{
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/sbin/proftpd
}
#service telnet
#{
# socket_type = stream
# protocol = tcp
# wait = no
# user = root
# no_access = 0.0.0.0
# only_from = 127.0.0.1
# banner_fail = /etc/telnet_fail
# server = /usr/sbin/in.telnetd
#}
service ssh
{
socket_type = stream
protocol = tcp
wait = no
user = root
port = 22
server = /usr/sbin/sshd
server_args = -i
}
service http
{
socket_type = stream
protocol = tcp
wait = no
user = root
GNUFDL • PID_00148471 52 Network administration
server = /usr/local/apache/bin/httpd
}
#service finger
#{
# socket_type = stream
# protocol = tcp
# wait = no
# user = root
# no_access = 0.0.0.0
# only_from = 127.0.0.1
# banner_fail = /etc/finger_fail
# server = /usr/sbin/in.fingerd
# server_args = -l
#}
# End of /etc/xinetd.conf
The above mentioned services (#) will not be available. In the defaults sec-
tion, we can install parameters such as maximum number of simultane-
ous service requests, the type of registry (log) that we require, from which
nodes the requests will be received by default, the maximum number of IP
requests that will be attended or the services that execute as superservers
(imapd or popd), such as:
default {
instances = 20
log_type = SYSLOG
authpriv log_on_success = HOST
log_on_failure = HOST
only_from = 192.168.0.0/16
per_source = 3
enabled = imaps
}
service imapd {
socket_type = stream
wait = no
user = root
server = /usr/sbin/imapd
only_from = 0.0.0.0/0 #allows every client
no_access = 192.168.0.1
instances = 30
log_on_success += DURATION USERID
log_on_failure += USERID
nice = 2
redirect = 192.168.1.1 993 #Makes it possible to redirect the traffic of port 993
to node 192.168.1.1
bind = 192.168.10.4
#Makes it possible to indicate the interface to which the service is associated to avoid
service spoofing problems.
}
working restart and logging out and back in, so that the current user
is included in the netdev group).
Activities
1)�Define the following network scenarios:
a) Isolated machine.
b) Small local network (4 machines, 1 gateway).
c) 2 segmented local networks (two groups of 2 machines and one router each and a general
gateway).
d) 2 interconnected local networks (two groups of 2 machines + a gateway each).
e) 2 machines connected through a private virtual network. Indicate the advantages/disad-
vantages of each configuration, for which types of infrastructure they are appropriate and
which important parameters are needed.
An important aspect for all the services is how they are started up. FC6 includes
a series of utilities for managing the service daemons (including the network
ones). As we have seen on the chapter on local administration, the runlevel is
the operating mode that will specify which daemons will be executed. In FC
we can find: runlevel 1 (single user), runlevel 2 (multiuser), runlevel 3 (mul-
tiuser with network), runlevel 5 (X11 plus /runlevel 3). Typically, we would
execute runlevel 5 or 3 if we do not need any graphical interfaces. In order
to determine the level that is being executed, we can use /sbin/runlevel, and
to know which level will start up by default cat /etc/inittab | grep
:initdefault:which will give us information such as id:5:initdefault: (we
can also edit /etc/inittab to change the default value.)
Ip6tables: the same applies but for the protocol and networks based on
Ipv6.
netfs: it is used to automatically mount the file systems through the net-
work (NFS, Samba etc.) during startup.
nfs,� nfslock: these are the standard daemons for sharing file systems
through the network in Unix/Linux/BSD-type operating systems.
sendmail: this service can be used to manage the mails (MTA) or support
services such as IMAP or POP3.
smb: this daemon makes it possible to share files over Windows systems.
sshd: SSH allows other users to connect interactively and securely to the
local machine.
xinetd: alternative service of inetd that presents a set of features and im-
provements, such as, for example, launching multiple services through
the same port (this service may not be installed by default).