RH253 - Red Hat Enterprise Linux Network Services and Security Administration

RH253 - Red Hat Enterprise Linux Network Services and Security Administration Introduction - RH253: Network Services and Security Administration Copyright Welcome Participant Introductions Red Hat Enterprise Linux Red Hat Enterprise Linux Variants Red Hat Network Other Red Hat Supported Software The Fedora Project Classroom Network Objectives of RH253 Audience and Prerequisites

Unit 1 - System Performance and Security Objectives System Resources as Services Security in Principle Security in Practice Security Policy: the People Security Policy: the System Response Strategies System Faults and Breaches Method of Fault Analysis Fault Analysis: Hypothesis Method of Fault Analysis, continued http://www.way2download.com/linux/RH253/ (1 of 10) [2008/02/06 08:25:50 PM]

RH253 - Red Hat Enterprise Linux Network Services and Security Administration

Fault Analysis: Gathering Data Benefits of System Monitoring Network Monitoring Utilities Networking, a Local view Networking, a Remote view File System Analysis Typical Problematic Permissions Monitoring Processes Process Monitoring Utilities System Activity Reporting Managing Processes by Account System Log Files syslogd and klogd Configuration Log File Analysis End of Unit 1

Unit 2 - System Service Access Controls Objectives System Resources Managed by init System Initialization and Service Management chkconfig Initialization Script Management xinetd Managed Services xinetd Default Controls xinetd Service Configuration xinetd Access Controls Host Pattern Access Controls The /etc/sysconfig/ files Service and Application Access Controls tcp_wrappers Configuration

http://www.way2download.com/linux/RH253/ (2 of 10) [2008/02/06 08:25:50 PM]

RH253 - Red Hat Enterprise Linux Network Services and Security Administration

Daemon Specification Client Specification Macro Definitions Extended Options A tcp_wrappers Example xinetd and tcp_wrappers SELinux SELinux, continued SELinux: Targeted Policy SELinux: Management SELinux: semanage SELinux: File Types End of Unit 2

Unit 3 - Network Resource Access Controls Objectives Routing IPv6 Features Implementing IPv6 IPv6: Dynamic Interface Configuration IPv6: Static Interface Configuration IPv6: Routing Configuration tcp_wrappers and IPv6 New and Modified Utilities Netfilter Overview Netfilter Tables and Chains Netfilter Packet Flow Rule Matching Rule Targets Simple Example

http://www.way2download.com/linux/RH253/ (3 of 10) [2008/02/06 08:25:50 PM]

RH253 - Red Hat Enterprise Linux Network Services and Security Administration

Basic Chain Operations Additional Chain Operations Rules: General Considerations Match Arguments Connection Tracking Connection Tracking, continued Connection Tracking Example Network Address Translation (NAT) DNAT Examples SNAT Examples Rules Persistence Sample /etc/sysconfig/iptables IPv6 and ip6tables End of Unit 3

Unit 4 - Organizing Networked Systems Objectives Host Name Resolution The Stub Resolver DNS-Specific Resolvers Trace a DNS Query with dig Other Observations Forward Lookups Reverse Lookups Mail Exchanger Lookups SOA Lookups SOA rdata Being Authoritative The Everything Lookup Exploring DNS with host Transitioning to the Server http://www.way2download.com/linux/RH253/ (4 of 10) [2008/02/06 08:25:50 PM]

RH253 - Red Hat Enterprise Linux Network Services and Security Administration

Service Profile: DNS Access Control Profile: BIND Getting Started with BIND Essential named Configuration Configure the Stub Resolver bind-chroot Package caching-nameserver Package Address Match List Access Control List (ACL) Built-In ACL's Server Interfaces Allowing Queries Allowing Recursion Allowing Transfers Modifying BIND Behavior Access Controls: Putting it Together Slave Zone Declaration Master Zone Declaration Zone File Creation Tips for Zone Files Testing BIND Syntax Utilities Advanced BIND Topics Remote Name Daemon Control (rndc) Delegating Subdomains DHCP Overview Service Profile: DHCP Configuring an IPv4 DHCP Server End of Unit 4

Unit 5 - Network File Sharing Services http://www.way2download.com/linux/RH253/ (5 of 10) [2008/02/06 08:25:50 PM]

RH253 - Red Hat Enterprise Linux Network Services and Security Administration

Objectives File Transfer Protocol(FTP) Service Profile: FTP Network File Service (NFS) Service Profile: NFS Port options for the Firewall NFS Server NFS utilities Client-side NFS Samba services Service Profile: SMB Configuring Samba Overview of smb.conf Sections Configuring File and Directory Sharing Printing to the Samba Server Authentication Methods Passwords Samba Syntax Utility Samba Client Tools: smbclient Samba Client Tools: nmblookup Samba Clients Tools: mounts Samba Mounts in /etc/fstab End of Unit 5

Unit 6 - Web Services Objectives Apache Overview Service Profile: HTTPD Apache Configuration Apache Server Configuration http://www.way2download.com/linux/RH253/ (6 of 10) [2008/02/06 08:25:50 PM]

RH253 - Red Hat Enterprise Linux Network Services and Security Administration

Apache Namespace Configuration Virtual Hosts Apache Access Configuration Apache Syntax Utilities Using .htaccess Files .htaccess Advanced Example CGI Notable Apache Modules Apache Encrypted Web Server Squid Web Proxy Cache Service Profile: Squid Useful parameters in /etc/squid/squid.conf End of Unit 6

Unit 7 - Electronic Mail Services Objectives Essential Email Operation Simple Mail Transport Protocol SMTP Firewalls Mail Transport Agents Service Profile: Sendmail Intro to Sendmail Configuration Incoming Sendmail Configuration Outgoing Sendmail Configuration Inbound Sendmail Aliases Outbound Address Rewriting Sendmail SMTP Restrictions Sendmail Operation Using alternatives to Switch MTAs Service Profile: Postfix

http://www.way2download.com/linux/RH253/ (7 of 10) [2008/02/06 08:25:50 PM]

RH253 - Red Hat Enterprise Linux Network Services and Security Administration

Intro to Postfix Configuration Incoming Postfix Configuration Outgoing Postfix Configuration Inbound Postfix Aliases Outbound Address Rewriting Postfix SMTP Restrictions Postfix Operation Procmail, A Mail Delivery Agent Procmail and Access Controls Intro to Procmail Configuration Sample Procmail Recipe Mail Retrieval Protocols Service Profile: Dovecot Dovecot Configuration Verifying POP Operation Verifying IMAP Operation End of Unit 7

Unit 8 - Securing Data Objectives The Need For Encryption Cryptographic Building Blocks Random Number Generator One-Way Hashes Symmetric Encryption Asymmetric Encryption I Asymmetric Encryption II Public Key Infrastructures Digital Certificates Generating Digital Certificates OpenSSH Overview http://www.way2download.com/linux/RH253/ (8 of 10) [2008/02/06 08:25:50 PM]

RH253 - Red Hat Enterprise Linux Network Services and Security Administration

OpenSSH Authentication The OpenSSH Server Service Profile: SSH OpenSSH Server Configuration The OpenSSH Client Protecting Your Keys Applications: RPM End of Unit 8

Unit 9 - Account Management Objectives User Accounts Account Information (Name Service) Name Service Switch (NSS) getent Authentication Pluggable Authentication Modules (PAM) PAM Operation /etc/pam.d/ Files: Tests /etc/pam.d/ Files: Control Values Example: /etc/pam.d/login File The system_auth file pam_unix.so Network Authentication auth Modules Password Security Password Policy session Modules Utilities and Authentication PAM Troubleshooting http://www.way2download.com/linux/RH253/ (9 of 10) [2008/02/06 08:25:50 PM]

RH253 - Red Hat Enterprise Linux Network Services and Security Administration

End of Unit 9

Appendix A - Installing Software Software Installation

http://www.way2download.com/linux/RH253/ (10 of 10) [2008/02/06 08:25:50 PM]

Introduction

Introduction

RH253: Network Services and Security Administration

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/introduction/page01.html [2008/02/06 08:25:57 PM]

1

Copyright

Copyright The contents of this course and all its modules and related materials, including handouts to audience members, are Copyright © 2007 Red Hat, Inc. ● No part of this publication may be stored in a retrieval system, transmitted or reproduced in any way, including, but not limited to, photocopy, photograph, magnetic, electronic or other record, without the prior written permission of Red Hat, Inc. ● This instructional program, including all material provided herein, is supplied without any guarantees from Red Hat, Inc. Red Hat, Inc. assumes no liability for damages or legal action arising from the use or misuse of contents or details contained herein. ● If you believe Red Hat training materials are being used, copied, or otherwise improperly distributed please email [email protected] or phone toll-free (USA) +1 866 626 2994 or +1 919 754 3700. ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/introduction/page02.html [2008/02/06 08:25:59 PM]

2

Welcome

Welcome Please let us know if you have any special needs while at our training facility.

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/introduction/page03.html [2008/02/06 08:26:04 PM]

3

Participant Introductions

Participant Introductions Please introduce yourself to the rest of the class!

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/introduction/page04.html [2008/02/06 08:26:10 PM]

4

Red Hat Enterprise Linux

Red Hat Enterprise Linux ● ● ●

Enterprise-targeted operating system Focused on mature open source technology 18-24 month release cycle ❍

Certified with leading OEM and ISV products

Purchased with one year Red Hat Network subscription and support contract



❍ ❍

Support available for seven years after release Up to 24x7 coverage plans available

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/introduction/page05.html [2008/02/06 08:26:13 PM]

5

Red Hat Enterprise Linux Variants

Red Hat Enterprise Linux Variants ● ●

Two Install Sets available Server Spin ❍ ❍



Red Hat Enterprise Linux Red Hat Enterprise Linux Advanced Platform

Client Spin ❍ ❍ ❍

Red Hat Enterprise Linux Desktop Workstation Option Multi-OS Option

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/introduction/page06.html [2008/02/06 08:26:23 PM]

6

Red Hat Network

Red Hat Network A comprehensive software delivery, system management, and monitoring framework











Update Module : Provides software updates ■ Included with all Red Hat Enterprise Linux subscriptions Management Module : Extended capabilities for large deployments Provisioning Module : Bare-metal installation, configuration management, and multi-state configuration rollback capabilities Monitoring Module provides infrastructure health monitoring of networks, systems, applications, etc.

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/introduction/page07.html [2008/02/06 08:26:25 PM]

7

Other Red Hat Supported Software

Other Red Hat Supported Software ● ● ● ● ●

Global Filesystem Directory Server Certificate Server Red Hat Application Stack JBoss Middleware Application Suite

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/introduction/page08.html [2008/02/06 08:26:27 PM]

8

The Fedora Project

The Fedora Project ● ●

Red Hat sponsored open source project Focused on latest open source technology ❍ ❍

Rapid four to six month release cycle Available as free download from the Internet

An open, community-supported proving ground for technologies which may be used in upcoming enterprise products ● Red Hat does not provide formal support ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/introduction/page09.html [2008/02/06 08:26:28 PM]

9

Classroom Network

Classroom Network Names

IP Addresses

Our Network Our Server Our Stations

example.com server1.example.com stationX.example.com

192.168.0.0/24 192.168.0.254 192.168.0.X

Hostile Network Hostile Server Hostile Stations

cracker.org server1.cracker.org stationX.cracker.org

192.168.1.0/24 192.168.1.254 192.168.1.X

Trusted Station

trusted.cracker.org

192.168.1.21

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/introduction/page10.html [2008/02/06 08:26:29 PM]

10

Objectives of RH253

Objectives of RH253 To become a system administrator who can setup a Red Hat Enterprise Linux server and configure common network services and implement a security policy at a basic level.



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/introduction/page11.html [2008/02/06 08:26:36 PM]

11

Audience and Prerequisites

Audience and Prerequisites Audience: System administrators, consultants, and other IT professionals ● Prerequisites: RH033 Red Hat Linux and RH133 Essentials Red Hat Linux System Administration , or equivalent skills and experience. A working knowledge of Internet Protocol(IP) networking. ●

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/introduction/page12.html [2008/02/06 08:26:42 PM]

12

Unit 1

Unit 1

System Performance and Security

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page01.html [2008/02/06 08:26:44 PM]

1-1

Objectives

Objectives Upon completion of this unit, you should be able to: Understand System Performance Security Goals ● Describe Security Domains ● Describe System Faults ● Explain System Fault Analysis Methods ● Explain Benefits of Maintaining System State ● Describe Networking Resource Concerns ● Describe Data Storage Resource Concerns ● Describe Processing Resource Concerns ● Describe Log File Analysis ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page02.html [2008/02/06 08:26:45 PM]

1-2

System Resources as Services

System Resources as Services Computing infrastructure is comprised of roles



❍ ❍



System infrastructure is comprised of roles ❍ ❍



systems that serve systems that request processes that serve processes that request

Processing infrastructure is comprised of roles ❍ ❍

accounts that serve accounts that request

System resources, and their use, must be accounted for as policy of securing the system ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page03.html [2008/02/06 08:26:47 PM]

1-3

Security in Principle

Security in Principle ●

Security Domains ❍ ❍ ❍ ❍

Physical Local Remote Personnel

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page04.html [2008/02/06 08:26:51 PM]

1-4

Security in Practice

Security in Practice By design, the system serves available resources ● By policy, the system preserves available resources ● Host only services you must, and only to those you must ●

❍ ❍ ❍



"Do I need or know to host this?" "Do they need or know to access this?" "Is this consistent with past records of system behavior?" "Have I applied all relevant security updates?"

Monitor system resources for vulnerabilities and poor performance



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page05.html [2008/02/06 08:26:58 PM]

1-5

Security Policy: the People

Security Policy: the People ●

Managing human activities ❍

● ● ●

includes Security Policy maintenance

Who is in charge of what? Who makes final decision about false alarms? When is law-enforcement notified?

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page06.html [2008/02/06 08:27:00 PM]

1-6

Security Policy: the System

Security Policy: the System ● ●

Managing system activities Regular system monitoring ❍ ❍ ❍



Log to an external server in case of compromise Monitor logs with logwatch Monitor bandwidth usage inbound and outbound

Regular backups of system data

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page07.html [2008/02/06 08:27:02 PM]

1-7

Response Strategies

Response Strategies ●

Assume suspected system is untrustworthy ❍ ❍ ❍ ❍

Do not run programs from the suspected system Boot from trusted media to verify breach Analyze logs of remote logger and "local" logs Check file integrity against read-only backup of rpm database

Make an image of the machine for further analysis/evidence-gathering ● Wipe the machine, re-install and restore from backup ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page08.html [2008/02/06 08:27:04 PM]

1-8

System Faults and Breaches

System Faults and Breaches Both effect system performance ● System performance is the concern ●

❍ ❍





security

a system fault yields an infrastructure void an infrastructure void yields opportunity for alternative resource access an opportunity for alternative resource access yields unaccountable resource access an unaccountable resource access is a breach of security policy

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page09.html [2008/02/06 08:27:05 PM]

1-9

Method of Fault Analysis

Method of Fault Analysis ● ● ●

Characterize the problem Reproduce the problem Find further information

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page10.html [2008/02/06 08:27:06 PM]

1-10

Fault Analysis: Hypothesis

Fault Analysis: Hypothesis ● ● ●

Form a series of hypotheses Pick a hypothesis to check Test the hypothesis

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page11.html [2008/02/06 08:27:09 PM]

1-11

Method of Fault Analysis, continued

Method of Fault Analysis, continued Note the results, then reform or test a new hypothesis if needed ● If the easier hypotheses yield no positive result, further characterize the problem ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page12.html [2008/02/06 08:27:12 PM]

1-12

Fault Analysis: Gathering Data

Fault Analysis: Gathering Data



strace command tail -f logfile *.debug in syslog



--debug option in application

● ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page13.html [2008/02/06 08:27:14 PM]

1-13

Benefits of System Monitoring

Benefits of System Monitoring System performance and security may be maintained with regular system monitoring ● System monitoring includes: ●

❍ ❍ ❍ ❍

Network monitoring and analysis File system monitoring Process monitoring Log file analysis

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page14.html [2008/02/06 08:27:16 PM]

1-14

Network Monitoring Utilities

Network Monitoring Utilities ●

Network interfaces (ip) ❍



Port scanners (nmap) ❍



Show what interfaces are available on a system Show what services are available on a system

Packet sniffers (tcpdump, wireshark) ❍

Stores and analyzes all network traffic visible to the "sniffing" system

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page15.html [2008/02/06 08:27:17 PM]

1-15

Networking, a Local view

Networking, a Local view ●

The ip utility ❍ ❍



Called by initialization scripts Greater capability than ifconfig

Use netstat -ntaupe for a list of: ❍ ❍

active network servers established connections

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page16.html [2008/02/06 08:27:20 PM]

1-16

Networking, a Remote view

Networking, a Remote view nmap reports active services on ports open to remote connection attempts



❍ ❍ ❍

Advanced scanning options available Offers remote OS detection Scans on small or large subnets

Do not use without written permission of the scanned system's admin! ● Graphical front-end available (nmapfe) ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page17.html [2008/02/06 08:27:22 PM]

1-17

File System Analysis

File System Analysis ●

Regular file system monitoring can prevent: ❍ ❍



File system monitoring should include: ❍ ❍



Exhausting system resources Security breaches due to poor access controls Data integrity scans Investigating suspect files

Utilities: df, du

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page18.html [2008/02/06 08:27:24 PM]

1-18

Typical Problematic Permissions

Typical Problematic Permissions Files without known owners may indicate unauthorized access:





Locate files and directories with no user or group entries in the /etc/passwd file: find / \( -nouser -o -nogroup \)

Files/Directories with "other" write permission (o+w) may indicate a problem





Locate other-writable files with: find / -type f -perm -002



Locate other-writable directories with: find / -type d -perm -2

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page19.html [2008/02/06 08:27:26 PM]

1-19

Monitoring Processes

Monitoring Processes ●

Monitor processes to determine: ❍ ❍



Cause of decreased performance If suspicious processes are executing

Monitoring utilities ❍ ❍ ❍

top gnome-system-monitor sar

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page20.html [2008/02/06 08:27:29 PM]

1-20

Process Monitoring Utilities

Process Monitoring Utilities ●

top ❍ ❍ ❍



view processor activity in real-time interactively kill or renice processes watch system statistics update through time, either in units or cumulatively

GUI system monitoring tools: ❍



gnome-system-monitor: GNOME process, CPU, and memory monitor kpm: KDE version of top

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page21.html [2008/02/06 08:27:30 PM]

1-21

System Activity Reporting

System Activity Reporting ●

Frequent reports, over time ❍ ❍



cron spawns sa1 and sa2 sar reads and generates "human friendly" logs

Commonly used for performance tuning ❍



more accurate statistics ■ binary "database" collection method ■ regular intervals Evidence of pattern establishes "normal" activity

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page22.html [2008/02/06 08:27:32 PM]

1-22

Managing Processes by Account

Managing Processes by Account Use PAM to set controls on account resource limits:









pam_access.so can be used to limit access by account and location pam_time.so can be used to limit access by day and time pam_limits.so can be used to limit resources available to process

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page23.html [2008/02/06 08:27:34 PM]

1-23

System Log Files

System Log Files ● ● ●

Why monitor log files? Which logs to monitor? Logging Services: ❍ ❍

Many daemons send messages to syslogd Kernel messages are handled by klogd

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page24.html [2008/02/06 08:27:36 PM]

1-24

syslogd and klogd Configuration

syslogd and klogd Configuration syslogd and klogd are configured in /etc/ syslog.conf



Syntax: facility.priority log_location



Example: mail.info /dev/tty8



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page25.html [2008/02/06 08:27:38 PM]

1-25

Log File Analysis

Log File Analysis Should be performed on a regular basis ● logwatch can be installed to run by crond every hour to report possible issues ● When looking for anomalies, logwatch uses negative lists ●

❍ ❍

Discard everything normal Analyze the rest

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page26.html [2008/02/06 08:27:39 PM]

1-26

End of Unit 1

End of Unit 1 ● ●

Questions and Answers Summary ❍ ❍ ❍ ❍ ❍ ❍

Address questions Preparation for Lab Goals Sequences Deliverables Please ask the instructor for assistance when needed

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-1/page27.html [2008/02/06 08:27:41 PM]

1-27

Unit 2

Unit 2

System Service Access Controls

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page01.html [2008/02/06 08:27:42 PM]

2-1

Objectives

Objectives Upon completion of this unit, you should be able to: ● ● ● ● ● ●

Understand how services are managed Learn common traits among services Describe Service Configuration Resources Implement Access Controls SELinux Overview SELinux Management

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page02.html [2008/02/06 08:27:44 PM]

2-2

System Resources Managed by init

System Resources Managed by init Services listening protocol connections

for serial



❍ ❍

● ● ● ●

a serial console a modem

Configured in /etc/inittab Calls the command rc to spawn initialization scripts Calls a script to start the X11 Display Manager Provides respawn capability

co:23:respawn:/sbin/agetty -f /etc/issue.serial 19200 ttyS1

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page03.html [2008/02/06 08:27:48 PM]

2-3

System Initialization and Service Management

System Initialization and Service Management Commonly referred to as "System V" or "SysV"







Many scripts organized by file system directory semantics Resource services are either enabled or disabled

Several configuration files are often used ● Most services start one or more processes ● Commands are "wrapped" by scripts ● Services are managed by these scripts, found in /etc/init.d/ ●



Examples: ❍ ❍

/etc/init.d/network status service network status

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page04.html [2008/02/06 08:27:50 PM]

2-4

chkconfig

chkconfig Manages service definitions in run levels ● To start the cups service on boot: chkconfig cups on ● Does not modify current run state of System V services ● Used for standalone and transient services ● Called by other applications, including system-config-services ● To list run level assignments, run chkconfig --list ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page05.html [2008/02/06 08:27:51 PM]

2-5

Initialization Script Management

Initialization Script Management Determine which services are configured to run a system boot





chkconfig --list

Shows which services should run ● Only reports the status of the symbolic links it manages ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page06.html [2008/02/06 08:27:54 PM]

2-6

xinetd Managed Services

xinetd Managed Services Transient services are managed by the xinetd service ● Incoming requests are brokered by xinetd ● Configuration files: /etc/xinetd.conf, / etc/xinetd.d/service ●



Linked with libwrap.so



Services controlled with chkconfig: chkconfig tftp on

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page07.html [2008/02/06 08:27:56 PM]

2-7

xinetd Default Controls

xinetd Default Controls ●

Top-level configuration file

# /etc/xinetd.conf defaults { instances log_type log_on_success log_on_failure cps } includedir /etc/xinetd.d

RH253-RH253-RHEL5-en-120070325

= = = = =

60 SYSLOG authpriv HOST PID HOST 25 30

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page08.html [2008/02/06 08:27:58 PM]

2-8

xinetd Service Configuration

xinetd Service Configuration ●

Service specific configuration ❍

/etc/xinetd.d/service

/etc/xinetd.d/tftp: # default: off service tftp { disable = yes socket_type protocol wait user server server_args per_source cps flags }

RH253-RH253-RHEL5-en-120070325

= = = = = = = = =

dgram udp yes root /usr/sbin/in.tftpd -c -s /tftpboot 11 100 2 IPv4

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page09.html [2008/02/06 08:28:00 PM]

2-9

xinetd Access Controls

xinetd Access Controls ●



Syntax ❍

Allow with only_from = host_pattern



Deny with no_access = host_pattern



The most exact specification is authoritative

Example ❍ ❍

only_from = 192.168.0.0/24 no_access = 192.168.0.1

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page10.html [2008/02/06 08:28:01 PM]

2-10

Host Pattern Access Controls

Host Pattern Access Controls ●



Host masks for xinetd may be: ❍

numeric address (192.168.1.0)



network name (from /etc/networks)



hostname or domain (.domain.com)



IP address/netmask range (192.168.0.0/24)

Number of simultaneous connections ❍

Syntax: per_source = 2



Cannot exceed maximum instances

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page11.html [2008/02/06 08:28:03 PM]

2-11

The /etc/sysconfig/ files

The /etc/sysconfig/ files Some services are configured for how they run



❍ ❍ ❍ ❍ ❍ ❍

named sendmail dhcpd samba init syslog

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page12.html [2008/02/06 08:28:04 PM]

2-12

Service and Application Access Controls

Service and Application Access Controls ●

Service-specific configuration ❍



Daemons like httpd, smbd, squid, etc. provide service-specific security mechanisms

General configuration ❍





All programs linked with libwrap.so use common configuration files Because xinetd is linked with libwrap.so, its services are effected Checks for host and/or remote user name

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page13.html [2008/02/06 08:28:06 PM]

2-13

tcp_wrappers Configuration

tcp_wrappers Configuration ●

Three stages of access checking ❍ ❍ ❍





Is access explicitly permitted? Otherwise, is access explicitly denied? Otherwise, by default, permit access!

Configuration stored in two files: ❍

Permissions in /etc/hosts.allow



Denials in /etc/hosts.deny

Basic syntax:

daemon_list: client_list [:options]

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page14.html [2008/02/06 08:28:07 PM]

2-14

Daemon Specification

Daemon Specification ●

Daemon name:



Applications pass name of their executable Multiple services can be specified Use wildcard ALL to match all daemons



Limitations exist for certain daemons

❍ ❍



Advanced Syntax:

daemon@host: client_list ...

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page15.html [2008/02/06 08:28:09 PM]

2-15

Client Specification

Client Specification ●

Host specification ❍

by IP address (192.168.0.1,10.0.0.)



by name (www.redhat.com, .example.com)



by netmask (192.168.0.0/255.255.255.0)



by network name

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page16.html [2008/02/06 08:28:11 PM]

2-16

Macro Definitions

Macro Definitions ●



Host name macros ❍

LOCAL



KNOWN, UNKNOWN, PARANOID

Host and service macro ❍



ALL

EXCEPT ❍ ❍

Can be used for client and service list Can be nested

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page17.html [2008/02/06 08:28:12 PM]

2-17

Extended Options

Extended Options ●

Syntax:

daemon_list: client_list [:opt1 :opt2...] ●

spawn ❍ ❍



Can be used to start additional programs Special expansions are available (%c, %s)

Example:

in.telnetd: ALL : spawn echo "login attempt from %c to %s" \ | mail -s warning root ●

DENY ❍



Can be used as an option in hosts.allow

Example:

ALL: ALL: DENY

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page18.html [2008/02/06 08:28:14 PM]

2-18

A tcp_wrappers Example

A tcp_wrappers Example # /etc/hosts.allow vsftpd : 192.168.0. in.telnetd, sshd : .example.com 192.168.2.5 # /etc/hosts.deny ALL : ALL

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page19.html [2008/02/06 08:28:15 PM]

2-19

xinetd and tcp_wrappers

xinetd and tcp_wrappers xinetd provides its own set of access control functions



❍ ❍



host-based time-based

tcp_wrappers is still used ❍ ❍

xinetd is compiled with libwrap support If libwrap.so allows the connection, then xinetd security configuration is evaluated

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page20.html [2008/02/06 08:28:16 PM]

2-20

SELinux

SELinux Mandatory Access Control (MAC) -vsDiscretionary Access Control (DAC) ● A rule set called the policy determines how strict the control ● Processes are either restricted or unconfined ● The policy defines what resources restricted processes are allowed to access ● Any action that is not explicitly allowed is, by default, denied ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page21.html [2008/02/06 08:28:17 PM]

2-21

SELinux, continued

SELinux, continued All files and processes have a security context ● The context has several elements, depending on the security needs ●



user:role:type:sensitivity:category user_u:object_r:tmp_t:s0:c0



Not all systems will display s0:c0



● ●

ls -Z ps -Z ❍

Usually paired with other options, such as -e

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page22.html [2008/02/06 08:28:19 PM]

2-22

SELinux: Targeted Policy

SELinux: Targeted Policy The targeted policy is loaded at install time ● Most local processes are unconfined ● Principally uses the type element for type enforcement ● The security context can be changed with chcon ●





chcon -t tmp_t /etc/hosts

Safer to use restorecon ❍

restorecon /etc/hosts

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page23.html [2008/02/06 08:28:20 PM]

2-23

SELinux: Management

SELinux: Management ●

Modes: Enforcing, Permissive, Disabled ❍

❍ ❍ ❍



Changing enforcement is allowed in the Targeted policy getenforce setenforce 0 | 1 Disable from GRUB with selinux=0

system-config-selinux ❍



Changes mode, and targeted policy controls. Mode change requires system reboot Booleans



/etc/sysconfig/selinux



setroubleshootd ❍

Advises on how to avoid errors, not ensure security!

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page24.html [2008/02/06 08:28:21 PM]

2-24

SELinux: semanage

SELinux: semanage ● ● ● ●

Some features controlled by semanage Recompiles small portions of the policy semanage function -l Most useful in high security environments

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page25.html [2008/02/06 08:28:23 PM]

2-25

SELinux: File Types

SELinux: File Types A managed service type is called its domain ● Allow rules in the policy define what file types a domain may access ● The policy is stored in a binary format, obscuring the rules from casual viewing ● Types can be viewed with semanage ●





semanage fcontext -l

public_content_t

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page26.html [2008/02/06 08:28:25 PM]

2-26

End of Unit 2

End of Unit 2 ● ●

Questions and Answers Summary ❍ ❍ ❍ ❍ ❍ ❍ ❍

Address questions Preparation for Lab Goals Sequences Deliverables Please ask the instructor for assistance when needed SELinux Management

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-2/page27.html [2008/02/06 08:28:26 PM]

2-27

Unit 3

Unit 3

Network Resource Access Controls

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page01.html [2008/02/06 08:28:27 PM]

3-1

Objectives

Objectives Upon completion of this unit, you should be able to: Describe IP and Routing ● Compare IPv4 and IPv6 ● Describe IPv6 Features ● Understand Netfilter Architecture ● Learn to use the iptables command ● Understand Network Address Translation (NAT) ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page02.html [2008/02/06 08:28:29 PM]

3-2

Routing

Routing Routers transport packets between different networks ● Each machine needs a default gateway to reach machines outside the local network ● Additional routes can be set using the route command ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page03.html [2008/02/06 08:28:30 PM]

3-3

IPv6 Features

IPv6 Features IP version 6



Larger Addresses ❍ ❍



Flexible Header Format ❍ ❍



128-bit Addressing Extended Address Hierarchy Base header - 40 octets Next Header field supports Optional Headers for current and future extensions

More Support for Autoconfiguration ❍ ❍ ❍

Link-Local Addressing Router Advertisement Daemon Dynamic Host Configuration Protocol version 6

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page04.html [2008/02/06 08:28:32 PM]

3-4

Implementing IPv6

Implementing IPv6 Kernel ipv6 module enables stateless autoconfiguration ● Additional configuration implemented by / etc/rc.d/init.d/network initialization script ●





NETWORKING_IPV6=yes in /etc/sysconfig/ network IPV6INIT=yes in /etc/sysconfig/networkscripts/ifcfg-ethX

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page05.html [2008/02/06 08:28:33 PM]

3-5

IPv6: Dynamic Interface Configuration

IPv6: Dynamic Interface Configuration Two ways to dynamically configure IPv6 addresses:





Router Advertisement Daemon ■ Runs on (Linux) Default Gateway - radvd ■ Only specifies prefix and default gateway ■ Enabled with IPV6_AUTOCONF=yes Interface ID automatically generated based on the MAC address of the system DHCP version 6 ■ dhcp6s supports more configuration options ■ Enabled with DHCPV6C=yes ■



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page06.html [2008/02/06 08:28:34 PM]

3-6

IPv6: Static Interface Configuration

IPv6: Static Interface Configuration /etc/sysconfig/network-scripts/ ifcfg-ethX



❍ ❍ ❍

IPV6ADDR=[/prefix_length] Device aliases unnecessary... IPV6ADDR_SECONDARIES=[/ prefix_length] [...]

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page07.html [2008/02/06 08:28:35 PM]

3-7

IPv6: Routing Configuration

IPv6: Routing Configuration ●

Default Gateway ❍ ❍

Dynamically from radvd or dhcpv6s Manually specified in /etc/sysconfig/network ■ IPV6_DEFAULTGW=



IPV6_DEFAULTDEV= - only valid on point-to-point interfaces

Static Routes ❍

Defined per interface in /etc/sysconfig/ network-scripts/route6-ethX ■ ■

Uses ip -6 route add syntax via

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page08.html [2008/02/06 08:28:37 PM]

3-8

tcp_wrappers and IPv6

tcp_wrappers and IPv6 ●

tcp_wrappers is IPv6 aware ❍

When IPv6 is fully implemented throughout the domain, ensure tcp_wrappers rules include IPv6 addresses

Example: preserving localhost connectivity, add to /etc/hosts.allow





ALL: [::1]

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page09.html [2008/02/06 08:28:38 PM]

3-9

New and Modified Utilities

New and Modified Utilities ● ● ● ● ●

ping6 traceroute6 tracepath6 ip -6 host -t AAAA hostname6.domain6

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page10.html [2008/02/06 08:28:39 PM]

3-10

Netfilter Overview

Netfilter Overview Filtering in the kernel: no daemon ● Asserts policies at layers 2, 3 & 4 of the OSI Reference Model ● Only inspects packet headers ● Consists of netfilter modules in kernel, and the iptables user-space software ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page11.html [2008/02/06 08:28:40 PM]

3-11

Netfilter Tables and Chains

Netfilter Tables and Chains

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page12.html [2008/02/06 08:28:44 PM]

3-12

Netfilter Packet Flow

Netfilter Packet Flow

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page13.html [2008/02/06 08:28:48 PM]

3-13

Rule Matching

Rule Matching Rules in ordered list ● Packets tested against each rule in turn ● On first match, the target is evaluated: usually exits the chain ● Rule may specify multiple criteria for match ● Every criterion in a specification must be met for the rule to match (logical AND) ● Chain policy applies if no match ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page14.html [2008/02/06 08:28:50 PM]

3-14

Rule Targets

Rule Targets ●

Built-in targets: DROP, ACCEPT

Extension targets: LOG, REJECT, custom chain





REJECT sends a notice returned to sender



LOG connects to system log kernel facility



LOG match does not exit the chain

Target is optional, but no more than one per rule and defaults to the chain policy if absent



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page15.html [2008/02/06 08:28:51 PM]

3-15

Simple Example

Simple Example ●

An INPUT rule for the filter table:

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page16.html [2008/02/06 08:28:55 PM]

3-16

Basic Chain Operations

Basic Chain Operations ●

List rules in a chain or table (-L or -vL)



Append a rule to the chain (-A)



Insert a rule to the chain (-I)





-I CHAIN (inserts as the first rule)



-I CHAIN 3 (inserts as rule 3)

Delete an individual rule (-D) ❍

-D CHAIN 3 (deletes rule 3 of the chain)



-D CHAIN RULE (deletes rule explicitly)

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page17.html [2008/02/06 08:28:56 PM]

3-17

Additional Chain Operations

Additional Chain Operations ●



Assign chain policy (-P CHAIN TARGET) ❍

ACCEPT (default, a built-in target)



DROP (a built-in target)



REJECT (not permitted, an extension target)

Flush all rules of a chain (-F) ❍

Does not flush the policy

Zero byte and packet counters (-Z [CHAIN])







Useful for monitoring chain statistics

Manage custom chains (-N, -X) ❍

-N Your_Chain-Name (adds chain)



-X Your_Chain-Name (deletes chain)

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page18.html [2008/02/06 08:28:57 PM]

3-18

Rules: General Considerations

Rules: General Considerations ●

Mostly closed is appropriate ❍ ❍ ❍



iptables -P INPUT DROP or iptables -A INPUT -j DROP iptables -A INPUT -j REJECT

Criteria also apply to loopback interface ❍

The example rules above will have the side effect of blocking localhost!

Rules, like routes, are loaded in memory and must be saved to a file for persistence across reboots



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page19.html [2008/02/06 08:28:59 PM]

3-19

Match Arguments

Match Arguments ●

Matches may be made by: ❍

❍ ❍

IP address, or host name ■ Warning: host names are resolved at the time of rule insertion Port number, or service name Arguments may be negated with `!'

Inclusive port range may be specified '0:1023'





Masks may use VLSN or CIDR notation

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page20.html [2008/02/06 08:28:59 PM]

3-20

Connection Tracking

Connection Tracking ●

Provides inspection of packet's "state" ❍



a packet can be tested in a specific context

Simplifies rule design ❍

without connection tracking, rules are usually in pairs (inbound & outbound)

Implemented in "state" match extension ● Recognized states: NEW, ESTABLISHED, RELATED, INVALID ● Requires more memory ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page21.html [2008/02/06 08:29:01 PM]

3-21

Connection Tracking, continued

Connection Tracking, continued ●

Connection tracking modules ❍ ❍ ❍ ❍



ip_conntrack_ftp ip_conntrack_tftp ip_nat_ftp ip_nat_tftp (and others)

/etc/sysconfig/iptables-config

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page22.html [2008/02/06 08:29:02 PM]

3-22

Connection Tracking Example

Connection Tracking Example ●

One rule to permit established connections:

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT ●

Many rules; one for each permitted service:

iptables -A INPUT -m state --state NEW -p tcp --dport 25 \ -j ACCEPT ●

Lastly, one rule to block all others inbound:

iptables -A INPUT -m state --state NEW -j DROP

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page23.html [2008/02/06 08:29:04 PM]

3-23

Network Address Translation (NAT)

Network Address Translation (NAT) Translates one IP address into another (inbound and/or outbound) ● Allows "hiding" internal IP addresses behind a single public IP ● Rules set within the nat table ●



Network Address Translation types: ❍



Destination NAT (DNAT) - Set in the PREROUTING chain where filtering uses translated address Source NAT (SNAT, MASQUERADE) - Set in the POSTROUTING chain where filtering never uses translated address

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page24.html [2008/02/06 08:29:06 PM]

3-24

DNAT Examples

DNAT Examples ●

INBOUND

iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT \ --to-dest 192.168.0.20 ●

OUTBOUND (with port redirection)

iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT \ --to-dest 192.168.0.200:3128

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page25.html [2008/02/06 08:29:07 PM]

3-25

SNAT Examples

SNAT Examples ●

MASQUERADE

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE ●

SNAT

iptables -t nat -A POSTROUTING -j SNAT --to-source 1.2.3.45

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page26.html [2008/02/06 08:29:08 PM]

3-26

Rules Persistence

Rules Persistence iptables is not a daemon, but loads rules into memory and exits ● Rules are not persistent across reboot ●





service iptables save will store rules to /etc/ sysconfig/iptables(Ensure this file has proper SELinux context!) System V management may be used, and is run before networking is configured

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page27.html [2008/02/06 08:29:10 PM]

3-27

Sample /etc/sysconfig/iptables

Sample /etc/sysconfig/iptables *filter :INPUT DROP [573:46163] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [641:68532] -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m tcp --dport -A INPUT -p tcp -m tcp --dport -A INPUT -p tcp -m tcp --dport -A INPUT -p tcp -m tcp --dport -A INPUT -p udp -m udp --dport -A INPUT -p udp -m udp --dport -A INPUT -p icmp -j ACCEPT -A INPUT -p tcp -m tcp --dport tcp-reset COMMIT

RH253-RH253-RHEL5-en-1-20070325

143 -j ACCEPT 22 -j ACCEPT 25 -s 123.123.123.1 -j ACCEPT 53 -j ACCEPT 53 -j ACCEPT 123 -s 123.123.123.1 -j ACCEPT 113 -j REJECT --reject-with \

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page28.html [2008/02/06 08:29:11 PM]

3-28

IPv6 and ip6tables

IPv6 and ip6tables ● ●

Packet filtering for IPv6 traffic Provided by the iptables-ipv6 package

Rules stored in /etc/sysconfig/ ip6tables





Does not yet support: ❍ ❍ ❍

REJECT target nat table connection tracking with the state module

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page29.html [2008/02/06 08:29:12 PM]

3-29

End of Unit 3

End of Unit 3 ● ●

Questions and Answers Summary ❍ ❍ ❍ ❍ ❍ ❍

Address questions Preparation for Lab Goals Scenario Deliverables Please ask the instructor for assistance when needed

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-3/page30.html [2008/02/06 08:29:13 PM]

3-30

Unit 4

Unit 4

Organizing Networked Systems

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page01.html [2008/02/06 08:29:14 PM]

4-1

Objectives

Objectives Upon completion of this unit, you should be able to: Understand host name resolution and its impact on networked systems organization ● Use common utilities to explore and verify DNS server operation ● Describe the Domain Name System (DNS) ● Perform essential BIND DNS configuration ● DHCP Overview ● DHCP Configuration ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page02.html [2008/02/06 08:29:15 PM]

4-2

Host Name Resolution

Host Name Resolution Some name services provide mechanisms to translate host names into lower-layer addresses so that computers can communicate



❍ ❍



Common Host Name Services ❍ ❍ ❍



Example: Name --> MAC address (link layer) Example: Name --> IP address (network layer) --> MAC address (link layer) Files (/etc/hosts and /etc/networks) DNS NIS

Multiple client-side resolvers: ❍ ❍ ❍ ❍

"stub" dig host nslookup

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page03.html [2008/02/06 08:29:17 PM]

4-3

The Stub Resolver

The Stub Resolver Generic resolver library available to all applications







Provided through gethostbyname() and other glibc functions Not capable of sophisticated access controls, such as packet signing or encryption

Can query any name service supported by glibc ● Reads /etc/nsswitch.conf to determine the order in which to query name services, as shown here for the default configuration: hosts: files dns ●

The NIS domain name and the DNS domain name should usually be different to simplify troubleshooting and avoid name collisions



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page04.html [2008/02/06 08:29:18 PM]

4-4

DNS-Specific Resolvers

DNS-Specific Resolvers ●

host ❍ ❍





Never reads /etc/nsswitch.conf By default, looks at both the nameserver and search lines in /etc/resolv.conf Minimal output by default

dig ❍ ❍



Never reads /etc/nsswitch.conf By default, looks only at the nameserver line in / etc/resolv.conf Output is in RFC-standard zone file format, the format used by DNS servers, which makes dig particularly useful for exploring DNS resolution

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page05.html [2008/02/06 08:29:20 PM]

4-5

Trace a DNS Query with dig

Trace a DNS Query with dig ●

dig +trace redhat.com ❍

❍ ❍ ❍

Reads /etc/resolv.conf to determine nameserver Queries for root name servers Chases referrals to find name records (answers) See notes for sample output in case the training center's firewall restricts outbound DNS

This is known as an iterative ● Initial Observations: ●







query

Names are organized in an inverted tree with root (.) at top The name hierarchy allows DNS to cross organizational boundaries Names in records end with a dot when fully-qualified

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page06.html [2008/02/06 08:29:22 PM]

4-6

Other Observations

Other Observations Answers in the previous trace are in the form of resource records ● Each resource record has five fields: ●





❍ ❍ ❍

domain - the domain or subdomain being queried ttl - how long the record should be cached, expressed in seconds class - record classification (usually IN) type - record type, such as A or NS rdata - resource data to which the domain maps

Conceptually, one queries against the domain (name), which is mapped to the rdata for an answer ● In the trace example, ●

❍ ❍

The NS (name server) records are referrals The A (address) record is the final answer and is the default query type for dig

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page07.html [2008/02/06 08:29:23 PM]

4-7

Forward Lookups

Forward Lookups ●

dig redhat.com ❍





Attempts recursion first, as indicated by rd (recursion section of the output: desired) in the flags if the nameserver allows recursion, then the server finds the answer and returns the requested records to the client If the nameserver does not allow recursion, then the server returns a referral to a top-level domain, which dig chases

Observations ❍

❍ ❍

dig's default query type is A; the rdata for an A record is an IPv4 address Use -t AAAA to request IPv6 rdata When successful, dig returns a status of NOERROR, an answer count, and also indicates which nameservers are authoritative for the name

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page08.html [2008/02/06 08:29:24 PM]

4-8

Reverse Lookups

Reverse Lookups ● ●

dig -x 209.132.177.50 Observations ❍





The question section in the output shows that DNS reverses the octets of an address and appends inaddr.arpa. to fully qualify the domain part of the record The answer section shows that DNS uses PTR (pointer) records for reverse lookups Additionally, the rdata for a PTR record is a fullyqualified domain name

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page09.html [2008/02/06 08:29:26 PM]

4-9

Mail Exchanger Lookups

Mail Exchanger Lookups An MX record maps a domain to the fullyqualified domain name of a mail server ● dig -t mx redhat.com ● Observations ●









The rdata field is extended to include an additional piece of data called the priority The priority can be thought of as a distance: networks prefer shorter distances To avoid additional lookups, nameservers typically provide A records as additional responses to correspond with the FQDN's provided in the MX records Together, an MX record and its associated A record resolve a domain's mail server

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page10.html [2008/02/06 08:29:27 PM]

4-10

SOA Lookups

SOA Lookups An SOA record marks a server as a master authority ● dig -t soa redhat.com ● Initial Observations ●

❍ ❍





The domain field is called the origin The rdata field is extended to support additional data, explained on the next slide There is typically only one master nameserver for a domain; it stores the master copy of its data Other authoritative nameservers for the domain or zone are referred to as slaves; they synchronize their data from the master

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page11.html [2008/02/06 08:29:28 PM]

4-11

SOA rdata

SOA rdata Master nameserver's FQDN ● Contact email ● Serial number ● Refresh delay before checking serial number ● Retry interval for slave servers ● Expiration for records when the slave cannot contact its master(s) ● Minimum TTL for negative answers ("no such host") ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page12.html [2008/02/06 08:29:29 PM]

4-12

Being Authoritative

Being Authoritative The SOA record merely indicates the master server for the origin (domain) ● A server is authoritative if it has: ●





Delegation from the parent domain: NS record plus A record A local copy of the domain data, including the SOA record

A nameserver that has the proper delegation but lacks domain data is called a lame server ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page13.html [2008/02/06 08:29:31 PM]

4-13

The Everything Lookup

The Everything Lookup dig -t axfr example.com. @192.168.0.254 ● Observations ●

❍ ❍



All records for the zone are transferred Records reveal much inside knowledge of the network Response is too big for UDP, so transfers use TCP

Most servers restrict zone transfers to a select few hosts (usually the slave nameservers) ● Use this command from a slave to test permissions on the master ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page14.html [2008/02/06 08:29:33 PM]

4-14

Exploring DNS with host

Exploring DNS with host For any of the following queries, add a -v option to see output in zone file format ● Trace: not available ● Delegation: host -rt ns redhat.com ● Force iterative: host -r redhat.com ● Reverse lookup: host 209.132.177.50 ● MX lookup: host -t mx redhat.com ● SOA lookup: host -t soa redhat.com ● Zone transfer: host -t axfr redhat.com 192.168.0.254 or host -t ixfr=serial example.com. 192.168.0.254 ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page15.html [2008/02/06 08:29:34 PM]

4-15

Transitioning to the Server

Transitioning to the Server Red Hat Enterprise Linux uses BIND, the Berkely Internet Name Daemon ● BIND is the most widely used DNS server on the Internet ●



❍ ❍

A stable and reliable infrastructure on which to base a domain's name and IP address associations The reference implementation for DNS RFC's Runs in a chrooted environment

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page16.html [2008/02/06 08:29:36 PM]

4-16

Service Profile: DNS

Service Profile: DNS Type: System V-managed service ● Packages: bind, bind-utils, bind-chroot ● Daemons: /usr/sbin/named, /usr/sbin/ rndc ● Script: /etc/init.d/named ●

Ports: 53 (domain), 953(rndc) ● Configuration: (Under /var/named/ chroot/) /etc/named.conf, /var/named/ *, /etc/rndc.key ●



Related: caching-nameserver, openssl

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page17.html [2008/02/06 08:29:37 PM]

4-17

Access Control Profile: BIND

Access Control Profile: BIND Netfilter: tcp/udp ports 53 and 953 incoming; tcp/udp ephemeral ports outgoing ● TCP Wrappers: N/A ●

ldd `which named` | grep libwrap strings `which named` | grep hosts

Xinetd: N/A (named is a standalone daemon) ● PAM: N/A (no configuration in /etc/pam. d/) ●

SELinux: yes - see notes ● App-specific controls: yes, discussed in later slides and in the ARM ●

/usr/share/doc/bind-*/arm/Bv9ARM.{html,pdf}

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page18.html [2008/02/06 08:29:38 PM]

4-18

Getting Started with BIND

Getting Started with BIND ●

Install packages ❍ ❍ ❍



Configure startup ❍ ❍ ❍



bind for core binaries bind-chroot for security caching-nameserver for an initial configuration service named configtest service named start chkconfig named on

Proceed with essential named configuration

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page19.html [2008/02/06 08:29:40 PM]

4-19

Essential named Configuration

Essential named Configuration ● ●

Configure the stub resolver Define access controls in /etc/named.conf ❍ ❍ ❍

Declare client match lists Server interfaces: listen-on and listen-on-v6 What queries should be allowed? ■ Iterative: allow-query { match-list; }; ■



● ●

Recursive: allow-recursion { matchlist; }; Transfers: allow-transfer { matchlist; };

Add data via zone files Test!

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page20.html [2008/02/06 08:29:40 PM]

4-20

Configure the Stub Resolver

Configure the Stub Resolver ●

On the nameserver: ❍





Edit /etc/resolv.conf to specify nameserver 127.0.0.1 Edit /etc/sysconfig/network-scripts/ ifcfg-* to specify PEERDNS=no

Advantages: ❍ ❍

Ensures consistent lookups for all applications Simplifies access controls and troubleshooting

Besides /etc/resolv.conf, where can an unprivileged user see what nameservers DHCP provides?



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page21.html [2008/02/06 08:29:42 PM]

4-21

bind-chroot Package

bind-chroot Package Installs a chroot environment under /var/ named/chroot



Moves existing config files into the chroot environment, replacing the original files with symlinks ● Updates /etc/sysconfig/named with a named option: ROOTDIR=/var/named/chroot ●



Tips ❍



Inspect /etc/sysconfig/named after installing bind-chroot Run ps -ef | grep named after starting named to verify startup options

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page22.html [2008/02/06 08:29:43 PM]

4-22

caching-nameserver Package

caching-nameserver Package ●

Provides ❍

named.caching-nameserver.conf



named.ca containing root server 'hints'





Forward and reverse lookup zone files for machinelocal names and IP addresses (e.g., localhost. localdomain)

Tips ❍

Copy named.caching-nameserver.conf to named.conf



Change ownership to root:named



Edit named.conf

The following slides describe essential access directives



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page23.html [2008/02/06 08:29:45 PM]

4-23

Address Match List

Address Match List A semicolon-separated list of IP addresses or subnets used with security directives for hostbased access control ● Format ●

❍ ❍ ❍ ❍

IP address: 192.168.0.1 Trailing dot: 192.168.0. CIDR: 192.168.0/24 Use a bang (!) to denote inversion

A match list is checked in order, stopping on first match ● Example: ●

{ 192.168.0.1; 192.168.0.; !192.168.1.0/24; };

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page24.html [2008/02/06 08:29:47 PM]

4-24

Access Control List (ACL)

Access Control List (ACL) In its simplest form, an ACL assigns a name to an address match list ● Can generally be used in place of a match list (nesting is allowed!) ● Best practice is to define ACL's at the top of / etc/named.conf ●



Example declarations

acl acl acl acl acl

"trusted" "classroom" "cracker" "mymasters" "myaddresses"

RH253-RH253-RHEL5-en-120070325

{ { { { {

192.168.1.21; }; 192.168.0.0/24; trusted; }; 192.168.1.0/24; }; 192.168.0.254; }; 127.0.0.1; 192.168.0.1; };

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page25.html [2008/02/06 08:29:48 PM]

4-25

Built-In ACL's

Built-In ACL's ●

BIND pre-defines four ACL's

none any localhost localnets

-

No IP address matches All IP addresses match Any IP address of the name server matches Directly-connected networks match

What is the difference between the localhost builtin ACL and the myaddresses example on the previous page (assuming the server is multi-homed)?



RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page26.html [2008/02/06 08:29:49 PM]

4-26

Server Interfaces

Server Interfaces Option: listen-on port 53 { matchlist; };



● ●

Binds named to specific interfaces Example

listen-on port 53 { myaddresses; }; listen-on-v6 port 53 { ::1; };

Restart and verify: netstat -tulpn | grep named ● Questions: ●





What if listen-on does not 127.0.0.1?

include

How might changing listen-on-v6 to :: (all IPv6 addresses) affect IPv4?

Default: if listen-on is missing, named listens on all interfaces



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page27.html [2008/02/06 08:29:50 PM]

4-27

Allowing Queries

Allowing Queries Option: allow-query { matchlist; };



Server provides both authoritative and cached answers to clients in match list ● Example: ●

allow-query { classroom; cracker; };

Default: if allow-query is missing, named allows all



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page28.html [2008/02/06 08:29:52 PM]

4-28

Allowing Recursion

Allowing Recursion Option: allow-recursion { matchlist; };



Server chases referrals on behalf of clients in the match-list ● Example: ●

allow-recursion { classroom; !cracker; }; ●

Questions ❍



What happens if 192.168.1.21 tries a recursive query? What happens if 127.0.0.1 tries a recursive query?

Default: if allow-recursion is missing, named allows all



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page29.html [2008/02/06 08:29:53 PM]

4-29

Allowing Transfers

Allowing Transfers Option: allow-transfer { matchlist; };



Clients in the match-list are allowed to act as slave servers ● Example: ●

allow-transfer { !cracker; classroom; }; ●

Questions ❍ ❍

What happens if 192.168.1.21 tries a slave transfer? What happens if 127.0.0.1 tries a slave transfer?

Default: if allow-transfer is missing, named allows all



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page30.html [2008/02/06 08:29:54 PM]

4-30

Modifying BIND Behavior

Modifying BIND Behavior ●

Option: forwarders { match-list; };



Modifier: forward first | only;

Directs named to recursively query specified servers before or instead of chasing referrals ● Example: ●

forwarders { mymasters; }; forward only;

How can you determine if forwarders is required ? ● If the forward modifier is missing, named assumes first ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page31.html [2008/02/06 08:29:56 PM]

4-31

Access Controls: Putting it Together

Access Controls: Putting it Together ●

Sample /etc/named.conf with essential access control options:

// acl's make security directives easier to read acl "myaddresses" { 127.0.0.1; 192.168.0.1; }; acl "trusted" { 192.168.1.21; }; acl "classroom" { 192.168.0.0/24; trusted; }; acl "cracker" { 192.168.1.254; }; options { # bind to specific interfaces listen-on port 53 { myaddresses; }; listen-on-v6 port 53 { ::1; }; # make sure I can always query myself for troubleshooting allow-query { localhost; classroom; cracker; }; allow-recursion { localhost; classroom; !cracker; }; /* don't let cracker (even trusted) do zone transfers */ allow-transfer { localhost; !cracker; classroom; }; # use a recursive, upstream nameserver forwarders { 192.168.0.254; }; forward only; };

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page32.html [2008/02/06 08:29:58 PM]

4-32

Slave Zone Declaration

Slave Zone Declaration zone "example.com" { type slave; masters { mymasters; }; file "slaves/example.com.zone"; }; ●

Sample zone declaration directs the server to: ❍

❍ ❍



Act as an authoritative nameserver for example. com, where example.com is the origin as specified field in the SOA record's domain Be a slave for this zone Perform zone transfers (AXFR and IXFR) against the hosts in the masters option Store the transferred data in /var/named/chroot/ var/named/slaves/example.com.zone

Reload named to automatically create the file



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page33.html [2008/02/06 08:29:59 PM]

4-33

Master Zone Declaration

Master Zone Declaration zone "example.com" { type master; file "example.com.zone"; }; ●

Sample zone declaration directs the server to: ❍

❍ ❍

Act as an authoritative nameserver for example. com, where example.com is the origin as specified field in the SOA record's domain Be a master for this zone Read the master data from /var/named/chroot/ var/named/example.com.zone

Manually create the master file before reloading named



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page34.html [2008/02/06 08:30:00 PM]

4-34

Zone File Creation

Zone File Creation ●

Content of a zone file: ❍

A collection of records, beginning with the SOA record The @ symbol is a variable representing the zone's origin as specified in the zone declaration from /etc/ named.conf



Comments are assembly-style (;)





Precautions: ❍





BIND appends the domain's origin to any name that is not properly dot-terminated If the domain field is missing from a record, BIND uses the value from the previous record (Danger! What if another admin changes the record order?) Remember to increment the serial number and reload named after modifying a zone file

What DNS-specific resolver puts its output in zone file format?



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page35.html [2008/02/06 08:30:02 PM]

4-35

Tips for Zone Files

Tips for Zone Files ●

Shortcuts: ❍





Do not start from scratch - copy an existing zone file installed by the caching-nameserver package To save typing, put $TTL 86400 as the first line of a zone file, then omit the TTL from individual records BIND allows you to split multi-valued rdata across lines when enclosed within parentheses ()

Choose a filename for your zone file that reflects the origin in some way



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page36.html [2008/02/06 08:30:03 PM]

4-36

Testing

Testing ●

Operation ❍





Select one of dig, host, or nslookup, and use it expertly to verify the operation of your DNS server Run tail -f /var/log/messages in a separate shell when restarting services

Configuration ❍



BIND will fail to start for syntax errors, so always run service named configtest after editing config files configtest runs two syntax utilities against files specified in your configuration, but the utilities may be run separately against files outside your configuration

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page37.html [2008/02/06 08:30:05 PM]

4-37

BIND Syntax Utilities

BIND Syntax Utilities named-checkconf -t ROOTDIR /path/to/ named.conf







Inspects /etc/named.conf by default (which will be the wrong file if the -t option is missing) Example: named-checkconf -t /var/named/chroot

named-checkzone origin /path/to/ zonefile



❍ ❍

Inspects a specific zone configuration Example: named-checkzone redhat.com \ /var/named/chroot/var/named/redhat.com.zone

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page38.html [2008/02/06 08:30:06 PM]

4-38

Advanced BIND Topics

Advanced BIND Topics ● ●

Remote Name Daemon Control (rndc) Delegating Subdomains

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page39.html [2008/02/06 08:30:07 PM]

4-39

Remote Name Daemon Control (rndc)

Remote Name Daemon Control (rndc) Provides local and remote management of named ● The bind-chroot package configures rndc ●

❍ ❍ ❍



Listens on the IPv4 and IPv6 loopbacks only Reads key from /etc/rndc.key If the key does not match, cannot start or stop the named service No additional configuration is needed for a default, local install

Example - flush the server's cache: rndc flush



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page40.html [2008/02/06 08:30:09 PM]

4-40

Delegating Subdomains

Delegating Subdomains ●

Steps ❍

❍ ❍



On the child, create a zone file to hold the subdomain's data On the parent, add an NS record On the parent, add an A record to complete the delegation

Glue Records ❍

If the child's canonical name is in the subdomain it manages, the A record is called a glue record

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page41.html [2008/02/06 08:30:10 PM]

4-41

DHCP Overview

DHCP Overview DHCP: Dynamic Host Configuration Protocol, implemented via dhcpd ● dhcpd provides services to both DHCP and BOOTP IPv4 clients ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page42.html [2008/02/06 08:30:11 PM]

4-42

Service Profile: DHCP

Service Profile: DHCP ● ● ● ●

Type: SystemV-managed service Package: dhcp Daemon: /usr/sbin/dhcpd Script: /etc/init.d/dhcpd

Ports: 67 (bootps), 68 (bootpc) ● Configuration: /etc/dhcpd.conf, /var/ lib/dhcpd/dhcpd.leases ●



Related: dhclient, dhcpv6_client, dhcpv6

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page43.html [2008/02/06 08:30:13 PM]

4-43

Configuring an IPv4 DHCP Server

Configuring an IPv4 DHCP Server ●

Configure the server in /etc/dhcpd.conf

Sample configuration provided in /usr/ share/doc/dhcp-version/dhcpd.conf. sample



There must be at least one subnet block, and it must correspond with configured interfaces. ● Run service dhcpd configtest to check syntax ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page44.html [2008/02/06 08:30:14 PM]

4-44

End of Unit 4

End of Unit 4 ● ●

Questions and Answers Summary ❍ ❍ ❍ ❍ ❍ ❍

Address questions Preparation for Lab Goals Scenario Deliverables Please ask the instructor for assistance when needed

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-4/page45.html [2008/02/06 08:30:16 PM]

4-45

Unit 5

Unit 5

Network File Sharing Services

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page01.html [2008/02/06 08:30:17 PM]

5-1

Objectives

Objectives Upon completion of this unit, you should be able to: ● ● ● ● ●

Describe the FTP service Explain Network File Sharing Describe the NFS service Describe the Samba service Use client tools with each service

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page02.html [2008/02/06 08:30:18 PM]

5-2

File Transfer Protocol(FTP)

File Transfer Protocol(FTP) vsftpd - the default Red Hat Enterprise Linux ftp server ● No longer managed by xinetd ● Allows system, anonymous or virtual (FTPonly) user access ● The anonymous directory hierarchy is provided by the vsftpd RPM ●

/etc/vsftpd/vsftpd.conf is the main configuration file



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page03.html [2008/02/06 08:30:19 PM]

5-3

Service Profile: FTP

Service Profile: FTP ● ● ● ●

Type: SystemV-managed service Package: vsftpd Daemon: /usr/sbin/vsftpd Script: /etc/init.d/vsftpd

Ports: 21 (ftp), 20 (ftp-data) ● Configuration: /etc/vsftpd/vsftpd. conf /etc/vsftpd.ftpusers /etc/pam. d/vsftpd ●



Log: /var/log/xferlog

Related: tcp_wrappers, ip_conntrack_ftp, ip_nat_ftp



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page04.html [2008/02/06 08:30:21 PM]

5-4

Network File Service (NFS)

Network File Service (NFS) The Red Hat Enterprise Linux NFS service is similar to other BSD and UNIX variants



❍ ❍





Exports are listed in /etc/exports Server notified of changes to exports list with exportfs -r or service nfs reload Shared directories are accessed through the mount command The NFS server is an RPC service and thus requires portmap

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page05.html [2008/02/06 08:30:22 PM]

5-5

Service Profile: NFS

Service Profile: NFS ● ●

Type: System V-managed service Package: nfs-utils

Daemons: rpc.nfsd, rpc.lockd, rpciod, rpc. mountd, rpc.rquotad, rpc.statd ● Scripts: /etc/init.d/nfs, /etc/init. d/nfslock ●

Ports: 2049(nfsd), Others assigned by portmap (111) ● Configuration: /etc/exports ●

Related: portmap (mandatory), tcp_wrappers



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page06.html [2008/02/06 08:30:23 PM]

5-6

Port options for the Firewall

Port options for the Firewall mountd, statd and lockd can be forced to use a static port ● Set the MOUNTD_PORT, STATD_PORT, LOCKD_TCPPORT and LOCKD_UDPPORT variables in /etc/sysconfig/nfs ●

MOUNTD_PORT="4002" STATD_PORT="4003" LOCKD_TCPPORT="4004" LOCKD_UDPPORT="4004"

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page07.html [2008/02/06 08:30:25 PM]

5-7

NFS Server

NFS Server Exported directories are defined in /etc/ exports



Each entry specifies the hosts to which the filesystem is exported plus associated permissions and options



❍ ❍ ❍

options should be specified default options: (ro,sync,root_squash) root mapped to UID 4294967294

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page08.html [2008/02/06 08:30:26 PM]

5-8

NFS utilities

NFS utilities ● ● ●

exportfs -v showmount -e hostname rpcinfo -p hostname

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page09.html [2008/02/06 08:30:27 PM]

5-9

Client-side NFS

Client-side NFS implemented as a kernel module ● /etc/fstab can be used to specify network mounts ● NFS shares are mounted at boot time by / etc/init.d/netfs ● autofs mounts NFS shares on demand and unmount them when idle ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page10.html [2008/02/06 08:30:28 PM]

5-10

Samba services

Samba services ●

Four main services are provided: ❍ ❍ ❍ ❍



authentication and authorization of users file and printer sharing name resolution browsing (service announcements)

Related ❍ ❍

smbclient command-line access Linux can mount a Samba share using the cifs or smbfs file system

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page11.html [2008/02/06 08:30:29 PM]

5-11

Service Profile: SMB

Service Profile: SMB Type: System V-managed service ● Packages: samba, samba-common, sambaclient ●

Daemons: /usr/sbin/nmbd, /usr/sbin/ smbd ● Script: /etc/init.d/smb ●

Ports: [NetBIOS] 137(-ns), 138(-dgm), 139(ssn), [SMB over TCP] 445(-ds) ● Configuration: /etc/samba/* ●



Related: system-config-samba, testparm

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page12.html [2008/02/06 08:30:31 PM]

5-12

Configuring Samba

Configuring Samba ●

Configuration in /etc/samba/smb.conf ❍



Red Hat provides a well-commented default configuration, suitable for most situations

Configuration tools are available ❍

system-config-samba samba-swat (http://localhost:901)



Hand-editing smb.conf is recommended



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page13.html [2008/02/06 08:30:33 PM]

5-13

Overview of smb.conf Sections

Overview of smb.conf Sections smb.conf is styled after the .ini file format and is split into different [ ] sections









[global] : section for server generic or global settings [homes] : used to grant some or all users access to their home directories [printers] : defines printer resources and services

Use testparm to check the syntax of /etc/ samba/smb.conf



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page14.html [2008/02/06 08:30:34 PM]

5-14

Configuring File and Directory Sharing

Configuring File and Directory Sharing ●

Shares should have their own [ ] section ❍

Some options to use: ■ public - share can be accessed by guest ■

browsable - share is visible in browse lists



writable - resource is read and write enabled



printable - resource is a printer, not a disk



group - all connections to the share use the specified group as their primary group

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page15.html [2008/02/06 08:30:35 PM]

5-15

Printing to the Samba Server

Printing to the Samba Server All printers defined in /etc/cups/ printers.conf are shared as resources by default ● Can be changed to allow only explicitly publicized printers ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page16.html [2008/02/06 08:30:37 PM]

5-16

Authentication Methods

Authentication Methods ●

Specified with security = method



Valid methods are: ❍







user : validation by user and password (this is the default) domain/server : a workgroup with a collection of authentication data is used ads : acts as an Active Directory member with Kerberos authentication share : user validation on per-share basis

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page17.html [2008/02/06 08:30:38 PM]

5-17

Passwords

Passwords ●

Encrypted password considerations ❍

Stored in /etc/samba/smbpasswd



Users added with smbpasswd -a user



Users modified with smbpasswd user



Users must have local accounts (or be translated to a local account through /etc/samba/smbusers), or implement winbindd, a separate service

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page18.html [2008/02/06 08:30:39 PM]

5-18

Samba Syntax Utility

Samba Syntax Utility testparm is used to check the syntax of /etc/samba/ smb.conf



Can check the allow/deny statements to verify that a host could access the server:



testparm /etc/samba/smb.conf station1.example.com 192.168.0.1

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page19.html [2008/02/06 08:30:41 PM]

5-19

Samba Client Tools: smbclient

Samba Client Tools: smbclient ●

Allows for simple view of shared services

smbclient -L hostname ●

Can be used as an ftp-style file retrieval tool

[student@stationX]$ smbclient //machine/service > cd directory > get file

user%password may be specified with -U or by setting and exporting the USER and PASSWD environment variables



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page20.html [2008/02/06 08:30:42 PM]

5-20

Samba Client Tools: nmblookup

Samba Client Tools: nmblookup ●

List specific machine nmblookup -U WINS_server -R name



List all machines nmblookup \*

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page21.html [2008/02/06 08:30:43 PM]

5-21

Samba Clients Tools: mounts

Samba Clients Tools: mounts The SMB and CIFS file systems are supported by the Linux kernel ● Use mount to mount a Samba-shared resource: ●

mount -t cifs service mountpoint -o option1,option2

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page22.html [2008/02/06 08:30:44 PM]

5-22

Samba Mounts in /etc/fstab

Samba Mounts in /etc/fstab Samba mounts can be performed automatically upon system boot by placing an entry in /etc/fstab



Specify the UNC path to the samba server, local mount point, cifs as the file system type, and a user name.



//stationX/homes

RH253-RH253-RHEL5-en-1-20070325

/mnt/homes

cifs

username=bob,uid=bob

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page23.html [2008/02/06 08:30:46 PM]

0 0

5-23

End of Unit 5

End of Unit 5 ● ●

Questions and Answers Summary ❍ ❍ ❍ ❍ ❍ ❍

Questions and Answers Preparation for Lab Goals Scenario Deliverables Please ask the instructor for assistance when needed

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-5/page24.html [2008/02/06 08:30:47 PM]

5-24

Unit 6

Unit 6

Web Services

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page01.html [2008/02/06 08:30:48 PM]

6-1

Objectives

Objectives Upon completion of this unit, you should be able to: Learn the major features of the Apache HTTP server ● Be able to configure important Apache parameters ● Learn per-directory configuration ● Learn how to use CGI with Apache ● Identify key modules ● Understand proxy web servers ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page02.html [2008/02/06 08:30:50 PM]

6-2

Apache Overview

Apache Overview ●

Process control: ❍ ❍



Dynamic module loading: ❍



spawn processes before needed adapt number of processes to demand run-time extensibility without recompiling

Virtual hosts: ❍

Multiple web sites may share the same web server

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page03.html [2008/02/06 08:30:51 PM]

6-3

Service Profile: HTTPD

Service Profile: HTTPD Type: SystemV-managed service ● Packages: httpd, httpd-devel, httpdmanual ●

● ● ● ●

Daemon: /usr/sbin/httpd Script: /etc/init.d/httpd Ports: 80(http), 443(https) Configuration: /etc/httpd/*, /var/www/

* ●

Related: system-config-httpd, mod_ssl

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page04.html [2008/02/06 08:30:52 PM]

6-4

Apache Configuration

Apache Configuration Main server configuration stored in /etc/ httpd/conf/httpd.conf







controls general web server parameters, regular virtual hosts, and access defines filenames and mime-types

Module configuration files stored in /etc/ httpd/conf.d/*





DocumentRoot default /var/www/html/

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page05.html [2008/02/06 08:30:54 PM]

6-5

Apache Server Configuration

Apache Server Configuration ● ● ● ● ● ●

Min and Max Spare Servers Log file configuration Host name lookup Modules Virtual Hosts user and group

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page06.html [2008/02/06 08:30:55 PM]

6-6

Apache Namespace Configuration

Apache Namespace Configuration ●

Specifying a directory for users' pages:

UserDir public_html ●

MIME types configuration:

AddType application/x-httpd-php .phtml AddType text/html .htm ●

Declaring index files for directories:

DirectoryIndex index.html default.htm

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page07.html [2008/02/06 08:30:56 PM]

6-7

Virtual Hosts

Virtual Hosts NameVirtualHost 192.168.0.100:80 ServerName virt1.com DocumentRoot /virt1 ServerName virt2.com DocumentRoot /virt2

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page08.html [2008/02/06 08:30:57 PM]

6-8

Apache Access Configuration

Apache Access Configuration Apache provides directory- and file-level hostbased access control ● Host specifications may include dot notation numerics, network/netmask, and dot notation hostnames and domains ● The Order statement provides control over "order", but not always in the way one might expect ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page09.html [2008/02/06 08:30:59 PM]

6-9

Apache Syntax Utilities

Apache Syntax Utilities ● ● ● ●

service httpd configtest apachectl configtest httpd -t Checks both httpd.conf and ssl.conf

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page10.html [2008/02/06 08:30:59 PM]

6-10

Using .htaccess Files

Using .htaccess Files ●

Change a directory's configuration: ❍ ❍



add mime-type definitions allow or deny certain hosts

Setup user and password databases: ❍

AuthUserFile directive



htpasswd command:

htpasswd -cm /etc/httpd/.htpasswd bob htpasswd -m /etc/httpd/.htpasswd alice

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page11.html [2008/02/06 08:31:01 PM]

6-11

.htaccess Advanced Example

.htaccess Advanced Example AuthName AuthType AuthUserFile AuthGroupFile

"Bob's Secret Stuff" basic /var/www/html/.htpasswd /var/www/html/.htgroup

require group staff require user bob

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page12.html [2008/02/06 08:31:02 PM]

6-12

CGI

CGI CGI programs are restricted to separate directories by ScriptAlias directive:



ScriptAlias /cgi-bin/ /path/cgi-bin/

Apache can greatly speed up CGI programs with loaded modules such as mod_perl



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page13.html [2008/02/06 08:31:04 PM]

6-13

Notable Apache Modules

Notable Apache Modules ● ● ●

mod_perl mod_php mod_speling

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page14.html [2008/02/06 08:31:05 PM]

6-14

Apache Encrypted Web Server

Apache Encrypted Web Server Apache and SSL: https 443)



❍ ❍



mod_ssl /etc/httpd/conf.d/ssl.conf

Encryption Configuration: ❍





(port

certificate: /etc/pki/tls/certs/your_host. crt private key: /etc/pki/tls/private/ your_host.key

Certificate/key generation: ❍ ❍ ❍

/etc/pki/tls/certs/Makefile self-signed cert: make testcert certificate signature request: make certreq

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page15.html [2008/02/06 08:31:06 PM]

6-15

Squid Web Proxy Cache

Squid Web Proxy Cache Squid supports caching of FTP, HTTP, and other data streams ● Squid will forward SSL requests directly to origin servers or to one other proxy ● Squid includes advanced features including access control lists, cache hierarchies, and HTTP server acceleration ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page16.html [2008/02/06 08:31:08 PM]

6-16

Service Profile: Squid

Service Profile: Squid ● ● ● ● ● ●

Type: SystemV-managed service Package: squid Daemon: /usr/sbin/squid Script: /etc/init.d/squid Port: 3128(squid), (configurable) Configuration: /etc/squid/*

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page17.html [2008/02/06 08:31:09 PM]

6-17

Useful parameters in /etc/squid/squid.conf

Useful parameters in /etc/squid/ squid.conf ● ● ● ● ● ● ●

http_port 3128 cache_mem 8 MB cache_dir ufs /var/spool/squid 100 16 256 acl all src 0.0.0.0/0.0.0.0 acl localhost src 127.0.0.1/255.255.255.255 http_access allow localhost http_access deny all

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page18.html [2008/02/06 08:31:11 PM]

6-18

End of Unit 6

End of Unit 6 ● ●

Questions and Answers Summary ❍ ❍ ❍ ❍ ❍ ❍

Address questions Preparation for Lab Goals Scenario Deliverables Please ask the instructor for assistance when needed

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-6/page19.html [2008/02/06 08:31:13 PM]

6-19

Unit 7

Unit 7

Electronic Mail Services

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page01.html [2008/02/06 08:31:13 PM]

7-1

Objectives

Objectives Upon completion of this unit, you should be able to: Understand electronic mail operation ● Use the alternatives system to select a mail server ● Perform basic configuration of a mail server ● Configure Procmail ● Configure Dovecot for encrypted and unencrypted protocols ● Debug email services ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page02.html [2008/02/06 08:31:15 PM]

7-2

Essential Email Operation

Essential Email Operation

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page03.html [2008/02/06 08:31:18 PM]

7-3

Simple Mail Transport Protocol

Simple Mail Transport Protocol ●

RFC-standard protocol for talking to MTA's ❍ ❍ ❍



Almost always uses TCP port 25 Extended SMTP (ESMTP) provides enhanced features for MTA's An MTA often uses Local Mail Transport Protocol (LMTP) to talk to itself

Example MSP:

mail -vs 'Some Subject' [email protected]

Use telnet to troubleshoot SMTP connections

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page04.html [2008/02/06 08:31:20 PM]

7-4

SMTP Firewalls

SMTP Firewalls Network layer with Netfilter stateful inspection







Inbound and outbound to

TCP port 25

Application layer for relay protection ❍







Internal MTA to which users connect for sending and receiving DMZ-based outgoing smart host which relays mail from the internal MTA DMZ-based inbound mail hub which relays mail to the internal MTA Filtering rules within the DMZ MTA's or integrated applications (e.g., Spamassassin)

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page05.html [2008/02/06 08:31:21 PM]

7-5

Mail Transport Agents

Mail Transport Agents Red Hat Enterprise Linux includes three MTA's







Common features ❍ ❍





Sendmail (default MTA), Postfix, and Exim Support virtual hosting Provide automatic retry for failed delivery and other error conditions Interoperable with Spamassassin

Default access control ❍ ❍ ❍

Sendmail and Postfix have no setuid components Listen on loopback only Relaying is disabled

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page06.html [2008/02/06 08:31:22 PM]

7-6

Service Profile: Sendmail

Service Profile: Sendmail Type: System V-managed service ● Packages: sendmail, sendmail-cf, sendmail-doc ●

● ●

Daemon: /usr/sbin/sendmail Script: /etc/init.d/sendmail

Port: 25 (smtp) ● Configuration: /etc/mail/sendmail. mc, /etc/aliases, and others ●

Related: procmail (MDA), spamassassin, tcp_wrappers, sendmail-doc



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page07.html [2008/02/06 08:31:24 PM]

7-7

Intro to Sendmail Configuration

Intro to Sendmail Configuration Red Hat uses and recommends the m4 macro language





Use dnlspace to comment a line within an m4 macro file

service sendmail restart uses /etc/ mail/Makefile





❍ ❍

Converts /etc/mail/sendmail.mc into /etc/ mail/sendmail.cf Rehashes various flat-file databases make compares timestamps; touch a file to force a rebuild/rehash

sendmail-cf is not installed by default ● The init script will not rebuild files unless sendmail-cf has been installed ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page08.html [2008/02/06 08:31:25 PM]

7-8

Incoming Sendmail Configuration

Incoming Sendmail Configuration ●

Modify /etc/mail/sendmail.mc to listen on all interfaces

dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

Add to /etc/mail/local-host-names each hostname by which the server may be referred ● Modify access control ●





Update /etc/hosts.{allow,deny}



Add an Netfilter rule to allow SMTP traffic

Restart sendmail

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page09.html [2008/02/06 08:31:26 PM]

7-9

Outgoing Sendmail Configuration

Outgoing Sendmail Configuration Red Hat provides a default /etc/mail/ submit.cf



❍ ❍

rarely needs modification enables sendmail to act as a client MSP

To masquerade as a domain instead of a single host





Uncomment the following lines in /etc/mail/ sendmail.mc EXPOSED_USER(`root')dnl FEATURE(masquerade_envelope)dnl MASQUERADE_AS(`example.com')dnl FEATURE(masquerade_entire_domain)dnl



These options work in conjunction with outbound address rewriting

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page10.html [2008/02/06 08:31:27 PM]

7-10

Inbound Sendmail Aliases

Inbound Sendmail Aliases ●

Local aliases: /etc/aliases ❍

Programs must be linked under /etc/smrsh for the Sendmail Restricted Shell

fakename: realname a-list: fakename, otheruser helpdesk: | mail2ticket

Virtual aliases: /etc/mail/ virtusertable



[email protected] [email protected] [email protected] @cba.com @dom1.org

RH253-RH253-RHEL5-en-120070325

shopper jdj [email protected] [email protected] %[email protected]

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page11.html [2008/02/06 08:31:29 PM]

7-11

Outbound Address Rewriting

Outbound Address Rewriting ●

Add the following lines to /etc/mail/sendmail.mc

FEATURE(genericstable)dnl FEATURE(`always_add_domain')dnl GENERICS_DOMAIN_FILE(`/etc/mail/local-host-names')dnl ●

Create and populate /etc/mail/genericstable

[email protected] [email protected]

[email protected] [email protected]

Domains must be listed in /etc/mail/local-hostnames





Address rewriting occurs for SMTP and not LMTP

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page12.html [2008/02/06 08:31:30 PM]

7-12

Sendmail SMTP Restrictions

Sendmail SMTP Restrictions 1. Enable in /etc/mail/sendmail.mc using FEATURE(`blacklist_recipients')dnl

2. Add restrictions in /etc/mail/access From:[email protected] Connect:spamRus.net Connect:204.168.23 Connect:10.3 From:virtualdomain1.com To:[email protected] To:nobody@

REJECT REJECT REJECT OK RELAY ERROR:550 mail discarded ERROR:550 bad name

Use tags to indicate whether blacklisting affects sender, recipient, or MTA ● Untagged entries are deprecated in Sendmail ●

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page13.html [2008/02/06 08:31:31 PM]

7-13

Sendmail Operation

Sendmail Operation ●

/etc/mail/local-host-names ❍



mail -v user ❍



view messages queued for future delivery

sendmail -q ❍



view SMTP exchange with local relay

mailq and mailq -Ac ❍



must contain server's name and aliases

reprocess the email queue

tail -f /var/log/maillog ❍

View log in real-time

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page14.html [2008/02/06 08:31:33 PM]

7-14

Using alternatives to Switch MTAs

Using alternatives to Switch MTAs ●

Overview of the alternatives system ❍







displays or configures the preferred MTA and associated man pages based on a generic name generic name is a link to a link in /etc/ alternatives/ only the links in /etc/alternatives/ are modified

Switching between MTA's ❍ ❍ ❍

Stop the current MTA and disable boot-time startup alternatives --config mta and make a selection Start the new MTA and enable boot-time startup

Graphical interface: system-switch-mailgnome package



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page15.html [2008/02/06 08:31:34 PM]

7-15

Service Profile: Postfix

Service Profile: Postfix ● ●

Type: SystemV-managed service Package: postfix

Daemons: /usr/libexec/postfix/ master and others





Script: /etc/init.d/postfix

Port: 25 (smtp) ● Configuration: /etc/postfix/main.cf and others ● Related: procmail ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page16.html [2008/02/06 08:31:36 PM]

7-16

Intro to Postfix Configuration

Intro to Postfix Configuration ●

/etc/postfix/main.cf ❍





Well-commented key=value pairs, evaluated in the order in which they appear White space at beginning of line is continuation character Keys may be used as variables for subsequent key=value pairs key1=value1 key2=$key1, value2



postconf



Display defaults: postconf -d Display current non-default settings: postconf -n Modify main.cf: postconf -e key=value



Show supported map types: postconf -m

❍ ❍

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page17.html [2008/02/06 08:31:37 PM]

7-17

Incoming Postfix Configuration

Incoming Postfix Configuration ●

Modify /etc/postfix/main.cf ❍

Listen on all interfaces inet_interfaces = all



Specify each name and alias by which the server may be referred mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

● ●

Add Netfilter rules to allow SMTP traffic Restart postfix

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page18.html [2008/02/06 08:31:39 PM]

7-18

Outgoing Postfix Configuration

Outgoing Postfix Configuration Red Hat provides a default /etc/postfix/ main.cf



❍ ❍ ❍



Enables Postfix to act as a client MSP No further configuration needed for single host Postfix automatically resolves local hostname and domain

To masquerade as a domain

myorigin = $mydomain masquerade_exceptions = root

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page19.html [2008/02/06 08:31:41 PM]

7-19

Inbound Postfix Aliases

Inbound Postfix Aliases ●

Local aliases: /etc/aliases as in Sendmail



Virtual aliases

1. Enable in main.cf virtual_alias_maps = hash:/etc/postfix/virtual

2. Define in /etc/postfix/virtual using the same format as Sendmail 3. Rehash the file: postmap /etc/postfix/virtual

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page20.html [2008/02/06 08:31:42 PM]

7-20

Outbound Address Rewriting

Outbound Address Rewriting 1. Enable in /etc/postfix/main.cf ●

smtp in the key name indicates SMTP only (not LMTP)

smtp_generic_maps = hash:/etc/postfix/generic

2. Define in /etc/postfix/generic [email protected] [email protected]

[email protected] [email protected]

3. Rehash the file: postmap /etc/postfix/ generic RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page21.html [2008/02/06 08:31:44 PM]

7-21

Postfix SMTP Restrictions

Postfix SMTP Restrictions 1. Create /etc/postfix/access ●

untagged version of Sendmail access file



rehash using postmap /etc/postfix/access

2. Edit main.cf smtpd_TAG_restrictions = check_TAG_access hash:/etc/postfix/access, ... ●

TAG is one of sender, recipient, or client



Example:

smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/access, permit_mynetworks, reject_unauth_destination

RH253-RH253-RHEL5-en-1-20070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page22.html [2008/02/06 08:31:47 PM]

7-22

Postfix Operation

Postfix Operation ●

main.cf settings



Server names: mydestination must contain server's name and aliases Listening interfaces: inet_interfaces = all



Archive all messages: always_bcc = address



View SMTP exchange: mail -v [email protected] ● View deferred messages: postqueue -p ● Flush deferred messages: postqueue -f ● Follow log: tail -f /var/log/maillog ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page23.html [2008/02/06 08:31:49 PM]

7-23

Procmail, A Mail Delivery Agent

Procmail, A Mail Delivery Agent ●

Different uses include: ❍ ❍ ❍ ❍



sorting incoming email into different folders or files preprocessing email starting an event or program when email is received automatically forwarding email to others

Enabling Procmail ❍ ❍

Sendmail: enabled by default Postfix: modify /etc/postfix/main.cf mailbox_command = /usr/bin/procmail

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page24.html [2008/02/06 08:31:50 PM]

7-24

Procmail and Access Controls

Procmail and Access Controls ●

Initial controls ❍

❍ ❍ ❍

SELinux policy restricts mail utilies to certain directories Procmail runs as nobody Procmail is owned by the mail group /var/spool/mail is writable only by root and the mail group

Required: change the procmail binary to run setgid



chmod g+s $(which procmail)

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page25.html [2008/02/06 08:31:51 PM]

7-25

Intro to Procmail Configuration

Intro to Procmail Configuration Configuration files are processed in order if they exist



1. /etc/procmailrc 2. ~/.procmailrc ●

Elements within a configuration file ❍ ❍



Directives: VERBOSE=yes Variables: LOGFILE=/var/spool/mail/ procmail.log Recipes ■ Begin with a ":0" line and flags ■



Zero or more match lines using regular expressions One or more action lines

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page26.html [2008/02/06 08:31:53 PM]

7-26

Sample Procmail Recipe

Sample Procmail Recipe :0* ^From.*joshua* ^Subject:.*ADSL { :0 c ! [email protected] :0: ADSL }

man pages: procmailex, procmailrc, procmail



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page27.html [2008/02/06 08:31:54 PM]

7-27

Mail Retrieval Protocols

Mail Retrieval Protocols ●

Post Office Protocol ❍





All data, including passwords, is passed in cleartext over TCP port 110 Use POP3s to provide SSL encryption of data over TCP port 995

Internet Mail Access Protocol ❍



All data, including passwords, is passed in cleartext over TCP port 143 Use IMAPs to provide SSL encryption of data over TCP port 993

Dovecot supports POP3, POP3s, IMAP, and IMAPs



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page28.html [2008/02/06 08:31:56 PM]

7-28

Service Profile: Dovecot

Service Profile: Dovecot ● ● ● ●

Type: SystemV-managed service Package: dovecot Daemon: /usr/sbin/dovecot Script: /etc/init.d/dovecot

Ports: 110 (pop), 995 (pop3s), 143 (imap), 993 (imaps) ● Configuration: /etc/dovecot.conf ●



Related: procmail, fetchmail, openssl

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page29.html [2008/02/06 08:31:58 PM]

7-29

Dovecot Configuration

Dovecot Configuration Listens on all IPv6 and IPv4 interfaces by default ● Specify protocols in /etc/dovecot.conf ●



protocols = imap imaps pop3 pop3s

Make a private key and self-signed certificate before using SSL



1. Confirm system time to avoid date issues 2. Review /etc/dovecot.conf for key and cert locations 3. Run make -C /etc/pki/tls/certs dovecot.pem ❍

Creates a single PEM file containing both the key and the cert

4. Copy the new PEM file to both locations RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page30.html [2008/02/06 08:31:58 PM]

7-30

Verifying POP Operation

Verifying POP Operation ●

Verify server operation ❍ ❍

Graphical: Thunderbird and Evolution Text-mode: Mutt and Fetchmail mutt -f pop://user@server[:port] mutt -f pops://user@server[:port]



Can also use telnet (POP3) or openssl s_client (POP3s) ■ Identify problems with certificate date or permissions

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page31.html [2008/02/06 08:32:00 PM]

7-31

Verifying IMAP Operation

Verifying IMAP Operation ●

Verifying server operation ❍ ❍

Graphical: Thunderbird and Evolution Text-mode: Mutt and Fetchmail mutt -f imap://user@server[:port] mutt -f imaps://user@server[:port]



Can also use telnet (IMAP) or openssl s_client (IMAPs) ■ Identify problems with certificate date or permissions

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page32.html [2008/02/06 08:32:01 PM]

7-32

End of Unit 7

End of Unit 7 ● ●

Questions and Answers Summary ❍ ❍ ❍ ❍ ❍ ❍

Inbound and outbound server configuration Mail-related protocols: SMTP, IMAP, POP3 Preparation for Lab Scenario Deliverables Please ask the instructor for assistance when needed

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-7/page33.html [2008/02/06 08:32:02 PM]

7-33

Unit 8

Unit 8

Securing Data

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page01.html [2008/02/06 08:32:04 PM]

8-1

Objectives

Objectives Upon completion of this unit, you should be able to: Understand fundamental encryption protocols ● Describe encryption implementations in Red Hat Enterprise Linux ● Configure encryption services for common networking protocols ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page02.html [2008/02/06 08:32:05 PM]

8-2

The Need For Encryption

The Need For Encryption ●

Susceptibility of unencrypted traffic ❍ ❍ ❍ ❍



password/data sniffing data manipulation authentication manipulation equivalent to mailing on postcards

Insecure traditional protocols ❍

telnet, FTP, POP3, etc. : insecure passwords



sendmail, NFS, NIS, etc.: insecure information



rsh, rcp, etc.: insecure authentication

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page03.html [2008/02/06 08:32:07 PM]

8-3

Cryptographic Building Blocks

Cryptographic Building Blocks ● ● ● ● ● ● ●

Random Number Generator One Way Hashes Symmetric Algorithms Asymmetric (Public Key) Algorithms Public Key Infrastructures Digital Certificates Implementations: ❍

openssl, gpg

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page04.html [2008/02/06 08:32:08 PM]

8-4

Random Number Generator

Random Number Generator Pseudo-Random Numbers and Entropy Sources



❍ ❍



keyboard and mouse events block device interrupts

Kernel provides sources ❍

/dev/random:



best source ■ blocks when entropy pool exhausted /dev/urandom: ■

■ ■



draws from entropy pool until depleted falls back to pseudo-random generators

openssl rand [ -base64 ] num

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page05.html [2008/02/06 08:32:09 PM]

8-5

One-Way Hashes

One-Way Hashes ●

Arbitrary data reduced to small "fingerprint" ❍ ❍ ❍ ❍



Common Algorithms ❍



arbitrary length input fixed length output If data changed, fingerprint changes ("collision free") data cannot be regenerated from fingerprint ("one way") md2, md5, mdc2, rmd160, sha, sha1

Common Utilities ❍

sha1sum [ --check ] file



md5sum [ --check ] file

❍ ❍

openssl, gpg rpm -V

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page06.html [2008/02/06 08:32:11 PM]

8-6

Symmetric Encryption

Symmetric Encryption ●

Based upon a single Key ❍



Common Algorithms ❍



used to both encrypt and decrypt DES, 3DES, Blowfish, RC2, RC4, RC5, IDEA, CAST5

Common Utilities ❍ ❍ ❍

passwd (modified DES) gpg (3DES, CAST5, Blowfish) openssl

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page07.html [2008/02/06 08:32:12 PM]

8-7

Asymmetric Encryption I

Asymmetric Encryption I ●

Based upon public/private key pair ❍

What one key encrypts, the other decrypts

Protocol I: Encryption without key synchronization









Recipient ■ generate public/private key pair: P and S ■ publish public key P, guard private key S Sender ■ encrypts message M with recipient public key ■ send P(M) to recipient Recipient ■ decrypts with secret key to recover: M = S(P (M))

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page08.html [2008/02/06 08:32:13 PM]

8-8

Asymmetric Encryption II

Asymmetric Encryption II ●

Protocol II: Digital Signatures ❍



● ●

Sender ■ generate public/private key pair: P and S ■ publish public key P, guard private key S ■ encrypt message M with private key S ■ send recipient S(M) Recipient ■ decrypt with sender's public key to recover M = P(S(M))

Combined Signature and Encryption Detached Signatures

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page09.html [2008/02/06 08:32:15 PM]

8-9

Public Key Infrastructures

Public Key Infrastructures Asymmetric encryption depends on public key integrity ● Two approaches discourage rogue public keys: ●

❍ ❍

Publishing Key fingerprints Public Key Infrastructure (PKI) ■ Distributed web of trust ■ Hierarchical Certificate Authorities ● Digital Certificates

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page10.html [2008/02/06 08:32:16 PM]

8-10

Digital Certificates

Digital Certificates ● ●

Certificate Authorities Digital Certificate ❍ ❍ ❍



Types ❍ ❍



Owner: Public Key and Identity Issuer: Detached Signature and Identity Period of Validity Certificate Authority Certificates Server Certificates

Self-Signed certificates

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page11.html [2008/02/06 08:32:17 PM]

8-11

Generating Digital Certificates

Generating Digital Certificates X.509 Certificate Format ● Generate a public/private key pair and define identity ● Two Options: ●





Use a Certificate Authority ■ generate signature request (csr ■ send csr to CA ■ receive signature from CA Self Signed Certificates ■ sign your own public key

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page12.html [2008/02/06 08:32:19 PM]

)

8-12

OpenSSH Overview

OpenSSH Overview OpenSSH replaces common, insecure network communication applications ● Provides user and token-based authentication ● Capable of tunneling insecure protocols through port forwarding ● System default configuration (client and server) resides in /etc/ssh/ ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page13.html [2008/02/06 08:32:20 PM]

8-13

OpenSSH Authentication

OpenSSH Authentication The sshd daemon can utilize several different authentication methods



❍ ❍ ❍ ❍ ❍

password (sent securely) RSA and DSA keys Kerberos s/key and SecureID host authentication using system key pairs

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page14.html [2008/02/06 08:32:21 PM]

8-14

The OpenSSH Server

The OpenSSH Server Provides greater data security between networked systems



❍ ❍

private/public key cryptography compatible with earlier restricted-use commercial versions of SSH

Implements host-based security through libwrap.so



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page15.html [2008/02/06 08:32:23 PM]

8-15

Service Profile: SSH

Service Profile: SSH Type: System V-managed service ● Packages: openssh, openssh-clients, openssh-server ●

● ● ● ●

Daemon: /usr/sbin/sshd Script: /etc/init.d/sshd Port: 22 Configuration: /etc/ssh/*, $HOME/.ssh/

Related: openssl, openssh-askpass, openssh-askpass-gnome, tcp_wrappers



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page16.html [2008/02/06 08:32:24 PM]

8-16

OpenSSH Server Configuration

OpenSSH Server Configuration ●

SSHD configuration file ❍



/etc/ssh/sshd_config

Options to consider ❍ ❍ ❍ ❍

Protocol ListenAddress PermitRootLogin Banner

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page17.html [2008/02/06 08:32:25 PM]

8-17

The OpenSSH Client

The OpenSSH Client ●





Secure shell sessions ❍

ssh hostname



ssh user@hostname



ssh hostname remote-command

Secure remote copy files and directories ❍

scp file user@host:remote-dir



scp -r user@host:remote-dir localdir

Secure ftp provided by sshd ❍

sftp host



sftp -C user@host

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page18.html [2008/02/06 08:32:27 PM]

8-18

Protecting Your Keys

Protecting Your Keys ●

ssh-add -- collects key passphrases



ssh-agent -- manages key passphrases

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page19.html [2008/02/06 08:32:28 PM]

8-19

Applications: RPM

Applications: RPM ● ●

Two implementations of file integrity Installed Files ❍ ❍



MD5 One-way hash rpm --verify package_name (or -V)

Distributed Package Files ❍ ❍



GPG Public Key Signature rpm --import /etc/pki/rpm-gpg/RPM-GPGKEY-redhat* rpm --checksig package_file_name (or -K)

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page20.html [2008/02/06 08:32:29 PM]

8-20

End of Unit 8

End of Unit 8 ● ●

Questions and Answers Summary ❍ ❍ ❍ ❍ ❍ ❍

Address questions Preparation for Lab Goals Scenario Deliverables Please ask the instructor for assistance when needed

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-8/page21.html [2008/02/06 08:32:31 PM]

8-21

Unit 9

Unit 9

Account Management

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page01.html [2008/02/06 08:32:32 PM]

9-1

Objectives

Objectives Upon completion of this unit, you should be able to: ● ●

Understand the basics of authentication Understand the roles of NSS and PAM

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page02.html [2008/02/06 08:32:32 PM]

9-2

User Accounts

User Accounts Two types of information must always be provided for each user account







Account information : UID number, default shell, home directory, group memberships, and so on Authentication: a way to tell that the password provided on login for an account is correct

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page03.html [2008/02/06 08:32:34 PM]

9-3

Account Information (Name Service)

Account Information (Name Service) Name services accessed through library functions map names to information ● Originally, name service was provided only by local files like /etc/passwd ●

Adding support for new name services (such as NIS) required rewriting libc



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page04.html [2008/02/06 08:32:35 PM]

9-4

Name Service Switch (NSS)

Name Service Switch (NSS) NSS allows new name services to be added without rewriting libc





Uses /lib/libnss_service.so files

/etc/nsswitch.conf controls which name services to check in what order





passwd: files nis ldap

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page05.html [2008/02/06 08:32:37 PM]

9-5

getent

getent ●

getent database ❍ ❍



Lists all objects stored in the specified database getent services

getent database name ❍



Looks up the information stored in the specified database for a particular name getent passwd smith

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page06.html [2008/02/06 08:32:38 PM]

9-6

Authentication

Authentication Applications traditionally authenticated passwords by using libc functions



❍ ❍ ❍

Hashes password provided on login Compare to hashed password in NSS If the hashes match, authentication passes

Applications had to be rewritten to change how they authenticated users



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page07.html [2008/02/06 08:32:39 PM]

9-7

Pluggable Authentication Modules (PAM)

Pluggable Authentication Modules (PAM) Pluggable Authentication Modules ● Application calls libpam functions to authenticate and authorize users ● libpam handles checks based on the application's PAM configuration file ●



May include NSS checks through libc

Shared, dynamically configurable code ● Documentation: /usr/share/doc/pam/ ●

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page08.html [2008/02/06 08:32:41 PM]

9-8

PAM Operation

PAM Operation ●

/lib/security/ PAM modules ❍ ❍



Each module performs a pass or fail test Files in /etc/security/ may affect how some modules perform their tests

/etc/pam.d/ PAM configuration ❍

Service files determine how and when modules are used by particular programs

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page09.html [2008/02/06 08:32:43 PM]

9-9

/etc/pam.d/ Files: Tests

/etc/pam.d/ Files: Tests ●

Tests are organized into four groups: ❍

auth authenticates that the user is



account authorizes the account may be used



password controls password changes



session opens, closes, and logs the session

the user

Each group is called as needed and provides a separate result to the service



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page10.html [2008/02/06 08:32:43 PM]

9-10

/etc/pam.d/ Files: Control Values

/etc/pam.d/ Files: Control Values Control values determine how each test affects group's overall result



❍ ❍



❍ ❍

required must pass, keep testing even if fails requisite as required, except stop testing on fail sufficient if passing so far, return success now; if fails, ignore test and keep checking optional whether test passes or fails is irrelevant includereturns the overall control value from tests configured in the file called

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page11.html [2008/02/06 08:32:45 PM]

9-11

Example: /etc/pam.d/login File

Example: /etc/pam.d/login File auth auth account account password session session session session session session

required include required include include required optional include required optional required

RH253-RH253-RHEL5-en-120070325

pam_securetty.so system_auth pam_nologin.so system_auth system_auth pam_selinux.so close pam_keyinit.so force revoke system_auth pam_loginuid.so pam_console.so pam_selinux.so open

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page12.html [2008/02/06 08:32:46 PM]

9-12

The system_auth file

The system_auth file ●

system-auth is widely used ❍

❍ ❍ ❍

Called by the include not a module(i.e. pam_stack.so)

control-flag,

Contains standard authentication tests Shared by many applications on the system Allows easy, consistent management of standard system authentication

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page13.html [2008/02/06 08:32:48 PM]

9-13

pam_unix.so

pam_unix.so ●

Module for NSS-based authentication ❍

❍ ❍



auth gets hashed password from NSS and compares it to hash of entered password account checks for password expiration password handles password changes to local files or NIS session records login and logout to logs

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page14.html [2008/02/06 08:32:49 PM]

9-14

Network Authentication

Network Authentication ●



Central password management ❍

pam_krb5.so (Kerberos V tickets)



pam_ldap.so (LDAP binds)



pam_smb_auth.so (old SMB authentication)



pam_winbind.so (SMB through winbindd)

Some services use NSS/pam_unix.so ❍

NIS, Hesiod, some LDAP configurations

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page15.html [2008/02/06 08:32:50 PM]

9-15

auth Modules

auth Modules pam_securetty.so fails if logging in as root from a terminal not in /etc/securetty



pam_nologin.so fails if the user is not root and the file /etc/nologin exists



pam_listfile.so checks a characteristic of the authentication against a list in a file





A list of accounts can be allowed or denied

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page16.html [2008/02/06 08:32:52 PM]

9-16

Password Security

Password Security ●

pam_unix.so MD5 password hashes ❍



Makes password hashes harder to crack

pam_unix.so shadow passwords ❍

Makes password hashes visible only to root



Makes password aging available

Other modules may support password aging mechanisms



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page17.html [2008/02/06 08:32:53 PM]

9-17

Password Policy

Password Policy ●

Password history ❍



Password strength ❍ ❍



pam_unix.so with remember=N argument pam_cracklib.so pam_passwdqc.so

Failed login monitoring ❍

pam_tally.so

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page18.html [2008/02/06 08:32:54 PM]

9-18

session Modules

session Modules ●

pam_limits.so enforces resource limits ❍

Uses /etc/security/limits.conf

pam_console.so sets permissions on local devices for console users







Can be used as an auth module as well

pam_selinux.so helps set SELinux context

pam_mkhomedir.so creates a home directory if it does not exist



RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page19.html [2008/02/06 08:32:56 PM]

9-19

Utilities and Authentication

Utilities and Authentication ●

Local admin tools need authentication ❍

su, reboot, system-config-*, etc.



pam_rootok.so passes if running as root



pam_timestamp.so for sudo-like behavior



pam_xauth.so forwards xauth cookies

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page20.html [2008/02/06 08:32:56 PM]

9-20

PAM Troubleshooting

PAM Troubleshooting ●

Check the system logs ❍ ❍



/var/log/messages /var/log/secure

PAM mistakes can lock out the root user ❍ ❍ ❍

Keep a root shell open when testing PAM Single-user mode bypasses PAM Boot the system using a rescue disc

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page21.html [2008/02/06 08:32:58 PM]

9-21

End of Unit 9

End of Unit 9 ● ●

Questions and Answers Summary ❍ ❍ ❍ ❍ ❍ ❍

Address questions Preparation for Lab Goals Scenario Deliverables Please ask the instructor for assistance when needed

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/unit-9/page22.html [2008/02/06 08:32:59 PM]

9-22

Appendix A

Appendix A

Installing Software

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/appendix-A/page01.html [2008/02/06 08:33:00 PM]

A-1

Software Installation

Software Installation

RH253-RH253-RHEL5-en-120070325

Copyright © 2007 Red Hat, Inc. All rights reserved

http://www.way2download.com/linux/RH253/appendix-A/page02.html [2008/02/06 08:33:01 PM]

A-2

RH253 - Red Hat Enterprise Linux Network Services and Security ...

RH253 - Red Hat Enterprise Linux Network Services and Security Administration.pdf. RH253 - Red Hat Enterprise Linux Network Services and Security ...

1MB Sizes 21 Downloads 216 Views

Recommend Documents

red hat enterprise linux atomic host - Media16
New container capabilities in the world's leading enterprise Linux platform. • A certification ... maintaining a stable platform for production deployment. You can ...

red hat enterprise linux atomic host - Media16
has been working on Linux container technologies for more than 10 years. ... Enterprise Linux Atomic Host couples the flexible, modular capabilities of Linux containers with the ... OpenStack Platform, and Amazon Web Services and Google Compute Platf

Red Hat Enterprise Linux 7 (EX200 and EX300 ...
advanced Apache services, DNS, MariaDB, NFS, Samba, SMTP, SSH, and time ... Linux 7: Training and Exam Preparation Guide (EX200 and EX300), Third.

Red Hat Enterprise Linux 7 (EX200 and EX300 ...
Hat Enterprise Linux Version 7, including: Part 1: RHCSA * Basic System Management: ... files, server connections; user, group, and permissions management; ...

Red Hat Enterprise Linux 7 (EX200 and EX300 ...
Hat Enterprise Linux Version 7, including: Part 1: RHCSA * Basic System ... configuring firewalls, remote mounts, FTP, and time services Part 2: RHCE * System.