chapter 12: configuring networks the complete guide to linux system administration

49
Chapter 12: Configuring Networks The Complete Guide to Linux System Administration

Upload: maryann-hood

Post on 24-Dec-2015

229 views

Category:

Documents


3 download

TRANSCRIPT

Chapter 12:Configuring Networks

The Complete Guide to Linux System Administration

The Complete Guide to Linux System Administration 2

Objectives

• Configure network interfaces using command-line and graphical utilities

• Set up a simple DHCP server

• Manage networked printing services

The Complete Guide to Linux System Administration 3

Configuring Linux Networking

• Learn more about – Networking protocols – Network configuration

The Complete Guide to Linux System Administration 4

Understanding Network Devices in Linux

• Linux networking devices– Not shown in /dev directory– Do not “exist” on system until appropriate device

driver installed in kernel

• Networking device– Named channel over which network traffic can

pass

• Device drivers for networking are kernel modules

The Complete Guide to Linux System Administration 5

Understanding Network Devices in Linux (continued)

• Kernel modules can be loaded or unloaded while Linux is running

• /dev/eth0– First Ethernet card installed on system

• Media Access Control (MAC) address– Unique address assigned by Ethernet card

manufacturer

The Complete Guide to Linux System Administration 6

Understanding Network Devices in Linux (continued)

• To obtain MAC address– Host broadcasts message to entire network

segment using Address Resolution Protocol (ARP)– Host with IP address responds directly to

computer that sent ARP request with MAC address

– Source host stores MAC address and IP address

The Complete Guide to Linux System Administration 7

Understanding Network Devices in Linux (continued)

• arp command– Display ARP cache

• Mapping of IP addresses to hardware addresses

– Used mainly for troubleshooting network connectivity

– Refreshed frequently

The Complete Guide to Linux System Administration 8

Configuring Networking with Command-line Utilities

• ifconfig command– Set up network configuration in Linux kernel– Parameters include:

• Network interface

• IP address assigned to interface

• Network mask

– Syntax• ifconfig device ip_address netmask address

broadcast address

The Complete Guide to Linux System Administration 9

Configuring Networking with Command-line Utilities (continued)

• Packet – Unit of data that network card transmits

• Broadcast address sends packet to all computers on same part of network

• Maximum transmission unit (MTU)– Maximum size of packet interface supports

The Complete Guide to Linux System Administration 10

Configuring Networking with Command-line Utilities (continued)

• View status of interface: ifconfig eth0

• Stop Ethernet interface: ifconfig eth0 down

• Start Ethernet interface: ifconfig eth0 up

• Routing table tells networking software where to send packets that are not part of local network

The Complete Guide to Linux System Administration 11

Configuring Networking with Command-line Utilities (continued)

• route command– View or configure routing table within kernel– Executed at boot time when networking initialized– Output information for addresses

• 192.168.100.0 (eth0 IP address)

• 127.0.0.0

• Other

The Complete Guide to Linux System Administration 12

Configuring Networking with Command-line Utilities (continued)

• Route command output– Destination – Ref– Gateway – Use– Genmask – Iface– Flags

• Add route example:– route add -net 192.168.100.0 netmask

255.255.255.0 dev eth0

The Complete Guide to Linux System Administration 13

Configuring Networking with Command-line Utilities (continued)

• service command – Start or stop networking– Relies on script /etc/rc.d/init.d/network

• /etc/sysconfig/networking/devices configuration directory– Contains file for each network device– ifcfg-eth0 file

• Used by /etc/rc.d/init.d/network script

• As it executes ifconfig and route commands

The Complete Guide to Linux System Administration 14

Configuring Networking with Command-line Utilities (continued)

• ifup and ifdown scripts manage single interface, rather than all network interfaces– Better than using ifconfig command directly

• Looks at parameters and associated functionality needed to cleanly manage interface

– Example: ./ifdown eth0

• Some systems have two or more physical network devices

The Complete Guide to Linux System Administration 15

Configuring Networking with Command-line Utilities (continued)

• IP forwarding – Allows packets to be passed between network

interfaces– Required for any router– To enable: echo 1 > /proc/sys/net/ipv4/ip_forward

• Linux includes graphical utilities that set up and manage networking

The Complete Guide to Linux System Administration 16

Configuring Networking Using Graphical Tools

• system-config-network program– Included with Red Hat Linux and Fedora– Devices tab

• List of each Linux networking device

• Name and type of hardware driver

The Complete Guide to Linux System Administration 17

Configuring Networking Using Graphical Tools (continued)

The Complete Guide to Linux System Administration 18

Configuring the DNS Resolver

• DNS– Used to convert host and domain names into IP

addresses– Implemented by server that supports DNS

• Reverse DNS converts IP address to domain name

• Resolving – Process of converting domain name to IP address

or vice versa

The Complete Guide to Linux System Administration 19

Configuring the DNS Resolver (continued)

• Resolver – Client part of DNS– Makes requests to DNS server– Test by pinging another system using host name

instead of IP address– Configured by file /etc/resolv.conf– Contains IP address of one or more DNS servers

preceded by keyword nameserver– Can include up to three DNS servers

The Complete Guide to Linux System Administration 20

Configuring the DNS Resolver (continued)

• Keyword– Word to which program reading configuration file

attaches special meaning

• Utilities for researching DNS problems:– dnsquery – whois– nslookup – host– dig

• /etc/hosts file stores IP addresses and corresponding domain names in text file on host

The Complete Guide to Linux System Administration 21

Configuring the DNS Resolver (continued)

• /etc/hosts file– By default contains only host name localhost and

own host’s name– On small network:

• Create hosts file that contains each host and IP address of host

• Avoid need for DNS server• Can have nonlocal domain names resolved by

request to DNS server

• Configuring DNS resolver graphically uses system-config-network to set up resolver

The Complete Guide to Linux System Administration 22

Configuring the DNS Resolver (continued)

The Complete Guide to Linux System Administration 23

Dynamic Routing with Routing Protocols

• Static routing– Uses preconfigured routing table– Not good choice for:

• Larger networks

• Unreliable connections

• Dynamic routing uses specialized routing protocol to build and modify routing tables automatically

The Complete Guide to Linux System Administration 24

Dynamic Routing with Routing Protocols (continued)

The Complete Guide to Linux System Administration 25

Dynamic Routing with Routing Protocols (continued)

• Routing protocols divided into two categories – Interior: designed for routing packets among

networks under your control– Exterior: designed for routing packets between

networks controlled by different organizations

• All routing protocols designed to exchange information among routers

The Complete Guide to Linux System Administration 26

Dynamic Routing with Routing Protocols (continued)

• Routing Information Protocol (RIP)– Interior routing protocol – Oldest routing protocol still in common use– Implemented in Linux using routed daemon– Easy to configure and run– Choice of most network administrators

The Complete Guide to Linux System Administration 27

Dynamic Routing with Routing Protocols (continued)

• Open Shortest Path First (OSPF) protocol– Interior routing protocol– Designed to work effectively even in very large

networks– Uses technique called flooding– Few Linux network administrators use it– Implemented using gated daemon

The Complete Guide to Linux System Administration 28

Dynamic Routing with Routing Protocols (continued)

• Border Gateway Protocol (BGP)– Designed for routing between major national

networks– Supported by gated daemon

The Complete Guide to Linux System Administration 29

Configuring a DHCP Server

• DHCP server installed by default on many Linux systems

• /etc/dhcpd.conf file– Configuration for DHCP– Instructs DHCP server which IP address ranges

are available for DHCP clients

The Complete Guide to Linux System Administration 30

Configuring a DHCP Server (continued)

• When client requests IP address :– DHCP server leases address to client for specified

time– At end of lease client must request new IP

address– Whole arrangement transparent to user on client

host

• DHCP client can run on any operating system

The Complete Guide to Linux System Administration 31

Networked Printing Services

• Linux includes network printing capabilities

The Complete Guide to Linux System Administration 32

Using Traditional Linux Printing: LPRng

• Traditional Linux printing system • Based on BSD version of UNIX• Allows multiple users to print files at same

time to:– Local printer– Networked printers

• Print queues– System administrator must define printers – Printer definitions describe type of printer and

features to be used

The Complete Guide to Linux System Administration 33

Using Traditional Linux Printing: LPRng (continued)

• Printing file in LPRng system– Application submits file to be printed (print job)– Print job processed by print filter converts

information from Linux application into formatting codes to produce desired output

– Printing utility stores print job in print spool directory

• Default directory /var/spool/lpd

– Lpd print server program keeps track of all print jobs in all print queues on system

The Complete Guide to Linux System Administration 34

Using Traditional Linux Printing: LPRng (continued)

• Correlation between print queue and physical printer not always one to one

• Linux print filter– Same as printer driver in other operating systems– Converts documents or images into format that

printer can use

The Complete Guide to Linux System Administration 35

Using Traditional Linux Printing: LPRng (continued)

The Complete Guide to Linux System Administration 36

Using Traditional Linux Printing: LPRng (continued)

• Page description language – Special set of codes – Determine graphic elements, text font, and

everything else about what appears on printed page

– Most widely used:• PostScript

• Printer Control Language (PCL)

The Complete Guide to Linux System Administration 37

Using Traditional Linux Printing: LPRng (continued)

• Magic filter– Can convert documents for many different printers– Convenient to support hundreds of printers – Doesn’t allow Linux to use specialized features of

each printer– Script /usr/share/printconf/util/mf_wrapper

• Main print filter in Red Hat Linux and Fedora

• Starts magicfilter-t program

• Uses several other programs in conversion process

The Complete Guide to Linux System Administration 38

Using Traditional Linux Printing: LPRng (continued)

• Configuring local printer definitions– Each LPRng printer definition created as print

queue entry in /etc/printcap configuration file• Uses complex format

– Must provide appropriate Linux device name• Parallel ports use device name lp followed by

device number

• Serial ports use name ttyS followed by device number

The Complete Guide to Linux System Administration 39

Printing Remotely Using LPRng

• Define printer on system that refers to remote computer and print queue on remote system– Key options in configuration file

• rm remote system specified

• rp remote print queue specified

• Once print job has been sent to remote system using lpd, user has no direct control over it

The Complete Guide to Linux System Administration 40

Printing Remotely Using LPRng (continued)

The Complete Guide to Linux System Administration 41

Understanding the Common UNIX Printing System (CUPS)

• Provides new architecture for Linux printing

• Users browse network to find and print to networked printers and other devices

• System administrators manage printer definitions and print jobs across network

• Installed by default in Red Hat Linux and Fedora

• cupsd– Main print server daemon

The Complete Guide to Linux System Administration 42

Understanding the Common UNIX Printing System (CUPS) (continued)

• cupsd print server daemon– Uses HTTP protocol– Manages printers using web browser interface

• CUPS architecture uses network port 631– Start CUPS user interface

• http//localhost:631/

• /etc/cups/cupsd.conf file specifies setting for each active server option

The Complete Guide to Linux System Administration 43

Understanding the Common UNIX Printing System (CUPS) (continued)

The Complete Guide to Linux System Administration 44

Understanding the Common UNIX Printing System (CUPS) (continued)

• Many printers are configured using PostScript Printer Description (PPD) file– Manufacturers can easily create text-based

configuration file – Permits printer to be graphically configured using

standard utilities• CUPS class

– Group of printers to which user can submit print job

– First available printer within used to print job

The Complete Guide to Linux System Administration 45

Managing Printing

• Printing policy– Brief statement of rules describing:

• How printing resources can be used

• How printers should be managed

• lpc utility controls LPRng or CUPS printing

• Alternatives printing system– Maps print command to different programs – Based on which printing system in use

The Complete Guide to Linux System Administration 46

Managing Printing (continued)

• Alternatives command

• lpr command and lpc command – Symbolic links

• Using lpc– Prevent new print jobs from being accepted by

print queue– Prevent print jobs from being sent to printer– Cancel print job currently being printed– See status of any printer

The Complete Guide to Linux System Administration 47

Managing Printing (continued)

• lpq utility lists each print job in print queue with status information

• lprm command deletes print job from queue

• Graphical print management utilities– Print Manager

The Complete Guide to Linux System Administration 48

Summary

• Ethernet card includes unique MAC address– Used by address resolution protocol

• ifconfig command used to configure networking interface in kernel

• route command modifies internal routing table

• system-config-network utility graphically configures network devices

The Complete Guide to Linux System Administration 49

Summary (continued)

• DHCP server on Linux requires configuring /etc/dhcpd.conf file

• Linux printing relies on printer definitions

• Red Hat Linux and Fedora support both LPRng and CUPS printing using alternatives printing system

• Print jobs can be managed using command line utilities or graphical interface