Linux Network Configuration Guide
Linux Network Configuration Guide
SETTING
Structure Page Nos.
3.0 Introduction 46
3.1 Objectives 46
3.2 Configuring Networks 46
3.3 Dynamic Host Configuration Protocol (DHCP) 47
3.4 Network Domain System (DNS) 50
3.5 Network File System (NFS) 56
3.6 Web Server 63
3.7 Summary 67
3.8 Answers to Check Your Progress 68
3.9 Further Readings 69
3.0 INTRODUCTION
A computer network is a telecommunications network that allows computers to
exchange data. The physical connection between networked computing devices is
established using either cable media or wireless media. The best-known computer
network is the Internet.
In this unit, you will learn configuration settings of various network services such as
Dynamic Host Protocol (DHCP), Domain Name System (DNS) Network File System
(NFS) and Web Server
3.1 OBJECTIVES
After going through this unit, you will be able to:
• know how to install various network services;
• configure a Dynamic Host Control Protocol;
• understand and configure a Domain Name System; and
• know on how to configure a Samba server.
Managing the DHCP daemon is easy to do, but the procedure differs between Linux
distributions. Here are some things to keep in mind.
The dhcpd.conf configuration file formats in Debian / Ubuntu and Redhat / Fedora
are identical.
Here is a quick explanation of the dhcpd.conf file.
How do you configure DHCP?
The following is the dhcpd.conf file
ddns-update-style interim
ignore client-updates
default-lease-time 86400;
max-lease-time 86400;
host laser-printer {
hardware ethernet 08:00:2b:4c:59:23;
fixed-address 192.168.1.222;
}
}
#
# List an unused interface here
#
subnet 192.168.2.0 netmask 255.255.255.0 {
}
Routing
When a DHCP configured PC boots, it requests its IP address from the DHCP server.
It does this by sending a standardized DHCP broadcast request packet to the DHCP
server with a source IP address of 255.255.255.255.
If your DHCP server has more than one interface, you have to add a route for this
255.255.255.255 address so that it knows the interface on which to send the reply; if
not, it sends it to the default gateway.
You can temporarily add a route to 255.255.255.255 using the following route add
command:
#
# vi/etc/network/interfaces and add the following and then save
#
iface eth0 inet static
up route add -host 255.255.255.255 eth0 49
Network Administration Listening Netw
With Linux
Once you have defined the interface for your DHCP routing, you should also ensure
that your DHCP server only listens on that interface and no others. This methodology
to do this varies depending on your version of Linux.
DHCPDARGS=eth1
INTERFACES="eth0"
You will be able to verify success in one of two ways. First the netstat command
using the –au options will give the list of interfaces listening on the bootp (DHCP)
UDP port. The following is an example:
root#
Secondly, your /var/log/messages file will also reveal the following defined interfaces
used when the DHCPd daemon was restarted.
Once, the above messages revealed when DHCPd daemon was started, the
configuration is success then go for launch.
By setting up a DNS server, you become part of a hierarchy of DNS servers that
make up the internet. At the top of this hierarchy is the root server, represented by a
dot (“.”) below the root server are the top level domains (such as .com,org,and so on).
50
ion Understanding DNS Network Configuration
and Setting
The basic function of name server is to answer queries by providing the information
that those queries request. A DNS name server primarily translates domain and host
names into IP addresses. Each domain is typically represented by a least two DNS
servers. The following are different types of DNS servers:
• Secondary (slave) name server gets all information for the domain from the
primary. As is the case for the primary, DNS considers the secondary information
about the domain that it serves authoritative.
• Caching name server simply caches the information it receives about the
locations of hosts and domains. It holds information that it obtains from other
authoritative servers and reuses that information until the information expires.
Understanding Bind
Red Hat Linux (and most other Linux and UNIX systems) implement DNS services
by using the Berkeley Internet Name Domain (BIND) software. The Internet software
Consortium maintains BIND (at www.isc.org/products/BIND). The basic components
of BIND include the following:
• DNS server daemon (/usr/sbin/named): the named daemon listens on a port for
DNS services requests and then fulfills those requests based on information in the
configuration files that you create. Mostly named receives requests to resolve the
host names in your domain to IP address.
• DNS lookup tools to check that your DNS server is resolving host names
properly. These include commands such as host, dig, and nslookup (which are
part of the bind-utils software package).
To maintain your DNS server correctly, you can also perform the following
configuration tasks with your DNS server:
Logging indicates what you want to log and where log files reside.)
Remote server options can set options for specific DNS servers to perform such
tasks as blocking information from a bad server, setting encryption keys to you use
with a server, or defining transfer methods)
There is no need to give out DNS information to everyone who requests it. Restrict
access to those who request it based on the following.
51
Network Administration Access control list can contain those hosts, domains or IP addresses that one wants Netw
With Linux
to group together and apply the same level of access to DNS server. C acl records to
group those addresses, and then indicate what domain information the locations in
that acl can or can’t access.
Listen-on ports by default, name server accepts only name server requests that come
to port 53 on name server. You can add more port numbers if you want your name
server to accept name-service queries on different ports.
Authentication is to verify the identities of hosts that are requesting services from
DNS server, can use keys for authentication and authorization. (the key and trusted-
keys statements are used for authentication.)
• Daemon process (/usr/sbin/named ) is the daemon process that listens for DNS
requests and responds with information that the named.conf file presents.
The following are the points one has to keep it in mind in creating a DNS server:
• identifying your DNS servers
• creating DNS configuration files (named.conf and /var/names/*)
• starting the named daemon
• Monitoring named activities
For this activity, use three systems- one Linux server, second Linux clients and third
window clients.
Step 1 - bind and caching-nameserver rpm is required to configure DNS. Check them
for install, if not found then install
52
ion
Network Configuration
and Setting
Main configuration file for dns server is named.conf. By default, this file is not
created in /var/named/chroot/etc/ directory. Instead of named.conf , a sample file
/var/named/chroot/etc/named.caching-nameserver.conf is created. This file is used to
make a caching only name server. You can also do editing in this file after changing
its name to named.conf to configure master dns server or you can manually create a
new named.conf file.
53
Network Administration save this file with :wq and exit Netw
With Linux
Configure zone file
Defined two zone files example.com.zone for forward zone and 0.168.192.in-
addr.arpa for reverse zone. These files will be stored in /var/named/chroot/var/named/
location.
54
ion By default it will look like this Network Configuration
and Setting
If service restart without any error, it means successfully configured master name
server.
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
55
Network Administration 2. What are the different types of DNS servers? Explain. Netw
With Linux
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
When mounting any filesystem on a directory, one should know that the original
contents of the directory are ignored, or obscured, in favor of the files in the
mounted filesystem. When the filesystem is unmounted, then the original files in
the directory reappear unchanged.
Stateless Operation
Programs that read and write to files on a local filesystem rely on the operating
system to track their access location within the file with a pointer. As NFS is a
network-based file system, and networks can be unreliable, it was decided that the
NFS client daemon would act as a failsafe intermediary between regular programs
running on the NFS client and the NFS server.
56
ion Normally, when a server fails, file accesses timeout and the file pointers are reset to Network Configuration
zero. With NFS, the NFS server doesn't maintain the file pointer information, the and Setting
NFS client does. This means that if an NFS server suddenly fails, the NFS client can
precisely restart the file access once more after patiently waiting until the server
returns online.
Caching
NFS clients typically request more data than they need and cache the results in
memory locally so that further sequential access of the data can be done locally
instead of access from server. This is also known as a read ahead cache. Caching
therefore helps to reduce the amount of network traffic while simultaneously
improving the speed of some types of data access. The NFS server caches information
too, such as the directory information for the most recently accessed files and a read
ahead cache for recently read files.
NFS Daemons
NFS isn't a single program, but a suite of interrelated programs that work together to
get the job done. The following are several daemons that are started when a system
goes into run level 3 or multi-user mode. The mountd and nfsd daemons are run on
systems that are servers. The automatic startup of the server daemons depends on the
existence of entries that are labeled with the NFS file-system type in /etc/dfs/sharetab.
To support NFS file locking, the lockd and statd daemons are run on NFS clients and
servers.
i) automountd Daemon
This daemon handles the mounting and unmounting requests from the autofs
service. The syntax of the command is as follows:
The -v option runs the command in verbose mode. Every time an NFS server
determines the access that a client should be granted, a message is printed on the
console. The information that is generated can be useful when trying to determine
why a client cannot access a file system.
The -r option rejects all future mount requests from clients. This option does not
affect clients that already have a file system mounted.
v) nfslogd Daemon
This daemon provides operational logging. NFS operations that are logged
against a server are based on the configuration options that are defined in
/etc/default/nfslogd. When NFS server logging is enabled, records of all RPC
operations on a selected file system are written to a buffer file by the kernel
ix) nfslock
Used to allow NFS clients to lock files on the server via RPC processes. The
nfslock daemon needs to be run on both the NFS server and client.
x) netfs
It allows RPC processes run on NFS clients to mount NFS filesystems on the
server. The netfs daemon needs to be run on the NFS client only.
Installing NFS
RedHat Linux installs nfs by default, and nfs is also activated when the system boots.
One can check whether nfs installed or not using the RPM command in conjunction
with the grep command to search for all installed nfs packages.
There is also a need to have the RPC rpcbind package installed, and the rpm
command can tell whether it is installed or not. Use rpm in conjunction with grep, to
check all the rpcbind applications installed or not.
If nfs and rpcbind are not installed, they can be added fairly easily once find the nfs-
utils and rpcbind RPMs. Remember that RPM filenames usually start with the
software's name and a version number, as in nfs-utils-1.1.3-1.i386.rpm.
59
Network Administration Configuring NFS on The Server Netw
With Linux
Both the NFS server and NFS client have to have parts of the NFS package installed
and running. The server needs rpcbind, nfs, and nfslock operational, as well as a
correctly configured /etc/exports file.
For example for the scenario as mentioned above, suppose requires the following:
Read-only access to the /data/files directory to all networks
Read/write access to the /home directory from all servers on the xxx.xxx.1.0 /24
network, which is all addresses from xxx.xxx.1.0 to xxx.xxx.1.255
Read/write access to the /data/test directory from servers in the my-site.com DNS
domain
Read/write access to the /data/database directory from a single server xxx.xxx.1.203.
In all cases, use the sync option to ensure that file data cached in memory is
automatically written to the disk after the completion of any disk data copying
operation.
#/etc/exports
/data/files *(ro,sync)
/home xxx.xxx.1.0/24(rw,sync)
/data/test *.my-site.com(rw,sync)
/data/database xxx.xxx.1.203/32(rw,sync)
After configuring /etc/exports file, there is a need to activate the settings, but first
make sure that NFS is running correctly.
The following are examples to use the start option, but by using stop and restart
options one can stop or restart the service as when needed.
60
ion root# service rpcbind start Network Configuration
and Setting
root# service nfs start
root# service nfslock start
Test whether NFS is running correctly with the rpcinfo command or not. The
following I an example to list the running RPC programs.
For example, mount the /data/files directory on server test(IP address xxx.xxx.1.100)
as NFS-type filesystem using the local /mnt/nfs mount point directory.
#/etc/fstab
61
Network Administration This example is used the soft and nfsvers options; The table 1 outlines these and other Netw
With Linux
useful NFS mounting options:
Option Description
rsize=n The amount of data NFS will attempt to access per read operation. The
default is dependent on the kernel. For NFS version 2, set it to 8192 to
assure maximum throughput.
wsize=n The amount of data NFS will attempt to access per write operation. The
default is dependent on the kernel. For NFS version 2, set it to 8192 to
assure maximum throughput.
nfsvers=n The version of NFS the mount command should attempt to use
tcp Attempt to mount the filesystem using TCP packets: the default is UDP.
intr If the filesystem is hard mounted and the mount times out, allow for the
process to be aborted using the usual methods such as CTRL-C and the
kill command.
NFS configuration on the client requires to start the NFS application; create a
directory on which to mount the NFS server's directories that are exported via the
/etc/exports file, and finally to mount the NFS server's directory on local system’s
directory, or mount point.
Test NFS whether is running correctly or not with the rpcinfo command. The
flowing is an examplw:
.
root# rpcinfo -p
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 32768 status
100024 1 tcp 32768 status
100021 1 udp 32769 nlockmgr
100021 3 udp 32769 nlockmgr
100021 4 udp 32769 nlockmgr
100021 1 tcp 32769 nlockmgr
100021 3 tcp 32769 nlockmgr
100021 4 tcp 32769 nlockmgr
391002 2 tcp 32770 sgi_fam
root#
Samba Server
Samba is a software package that comes with Red Hat Linux to share file systems and
printers on a network with computers that use the session massage block (SMS)
protocol. SMB is the protocol that is delivered with windows operating systems for
sharing files and printers. In Red Hat Linux, the Samba software package contains a
variety of daemon processes, administrative tools, user tools, and configuration files.
63
Network Administration The default Samba configuration file is smb.conf, which is in /etc/samba directory ( Netw
With Linux
/etc/samba/smb.conf). If you need to access features that are not available through the
samba server configuration file you can edit /etc/samba/smb.conf file as required.
Daemon processes consist of smbd (the SMB daemon) and nmbd ( the NetBIOS
name server ). The smbd is what makes the file sharing and printing services you add
to your Red Hat Linux computer available to windows client computers. The
following are some of the clients that Samba supports:
Window 9X
Window 2000
Window NT
Window ME
Window XP
Window for workgroups
Ms Client 3.0 for DOS
OS/2
Dave for Macintosh computer
Samba for Linux
As for administrative tools for samba, you have several shell commands at your
disposal. You can check your configuration file using the testparm and testprns
commands. The smbstatus command tells you which computers are currently
connected to your shared
[public]
comment = RAID drive share
inherit acls = Yes
path = /local/public
read only = No
65
Network Administration 4. To check if all rpms required for samba are installed or not. Netw
With Linux
#rpm –qa | grep samba, then it displays the following
Samba-<version-name>
Samba-common-<version-name>
Samba-client-<version- name>
System-config-samba-<version-name>
#vi /etc/samba/smb.conf
[homes]
comment=Home directories
browseable =no
writable=yes
[printers]
comment = All printers
path = /var/spool/samba
browseable = no
[IHNC’s share]
comment = Testing Samba Server
path = /samba
valid users = user1, user2
#testparm
useradd user1
useradd user2
smbpasswd –a user1
smbpasswd –a user2
66
ion 15. Now you stop/start the samba services Network Configuration
and Setting
#service smb stop
#service smb start
16. To see what is shared from your server through samba for a particular user
#smbclient –L mac2
#chkconfig smb on
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
…………………………………………………………………………………
3.7 SUMMARY
In this unit, installation, configuration and setup of various network services such as
Dynamic Host Control Protocol (DHCP), Domain Name System (DNS), Network
File System (NFS) and Samba server are explained in detail with examples. This
knowledge nay help to understand the concepts and install, configure and
commissioning of other network services such as Email, FTP and such related
services also. Student has to practice in real time to have more exposure and built
confidence in configuration of network services. 67
Network Administration
With Linux 3.8 ANSWERS TO CHECK YOUR PROGRESS Netw
1. The following are the activities between DHCP Server and DHCP Client.
• The DHCP server then sends an acknowledgement to the client. The client
is configured to use TCP/IP.
• Lease Renewal: When half of the lease time has expired, the client will
issue a new request to the DHCP server.
Secondary (slave) name server gets all information for the domain from the
primary. As is the case for the primary, DNS considers the secondary
information about the domain that it serves authoritative.
Caching name server simply caches the information it receives about the
locations of hosts and domains. It holds information that it obtains from other
authoritative servers and reuses that information until the information expires.
Daemon process (/usr/sbin/named ) is the daemon process that listens for DNS
requests and responds with information that the named.conf file presents.
68
ion
Network Configuration
and Setting
Debugging tools (named –checkconf, and named-checkzone) are to determine
whetherthe created DNS configuration correctly.
2. Samba is a software package that comes with Red Hat Linux to share file systems
and printers on a network with computers that use the session massage block
(SMS) protocol. SMB is the protocol that is delivered with windows operating
systems for sharing files and printers. In Red Hat Linux, the Samba software
package contains a variety of daemon processes, administrative tools, user tools,
and configuration files.
69