d74508gc10_sg2

280
Oracle Linux System Administration Student Guide – Volume II D74508GC10 Edition 1.0 August 2012 D78745 Oracle University and (Oracle Corporation) use only. These eKit materials are to be used ONLY by you for the express purpose SELF STUDY. SHARING THE FILE IS STRICTLY PROHIBITED.

Upload: nik20132013

Post on 27-Dec-2015

611 views

Category:

Documents


10 download

TRANSCRIPT

Page 1: D74508GC10_sg2

Oracle Linux System

Administration

Student Guide – Volume II

D74508GC10

Edition 1.0

August 2012

D78745 O

racl

e U

nive

rsity

and

(Ora

cle

Cor

pora

tion)

use

onl

y.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 2: D74508GC10_sg2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Disclaimer This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way. Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display, perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization of Oracle. The information contained in this document is subject to change without notice. If you find any problems in the document, please report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not warranted to be error-free. Restricted Rights Notice

If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United States Government, the following notice is applicable: U.S. GOVERNMENT RIGHTS The U.S. Government’s rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract.

Trademark Notice

Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

Author

Craig McBride

Technical Contributors and Reviewers

Avi Miller

Elena Zannoni

Lenz Grimmer

Sergio Leunissen

Waseem Daher

Wim Coekaerts

Al Flournoy

Harald Van Breederode

Joel Goodman

Manish Kapur

Soeren Binner

Jeremy Smyth

Yasar Akthar

Javier Saiz

Ozgur Yuksel

Antoinette O’Sullivan

Frank Allan

Gavin Bowe

Gino Kawalski

Jeff Suchomel

Rob Swank

Ron Hardin

Michele Dady

Matt Taylor

Graphic Designer

Maheshwari Krishnamurthy

Editors

Richard Wallis

Raj Kumar

Daniel Milne

Smita Kommini

Publishers

Giri Venugopal

Michael Sebastian Almeida

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 3: D74508GC10_sg2

iii

Contents

1 Course Introduction

Course Objectives 1-2

Course Schedule 1-3

Lesson Objectives 1-6

Virtualization with Oracle VM Server 1-7

Oracle VM Server in the Classroom 1-8

Summary 1-10

Practices Overview 1-11

2 Introduction to Oracle Linux

Objectives 2-2

Linux Kernel 2-3

The GNU Project 2-5

GNU General Public License (GPL) 2-6

Linux Kernel Development Model 2-8

Mainline Kernel Development Continues 2-10

Linux Distributions 2-11

Oracle Linux 2-13

Oracle’s Technical Contributions to Linux 2-14

Oracle Linux: Compatible with Red Hat Enterprise Linux (RHEL) 2-16

Unbreakable Enterprise Kernel 2-18

Unbreakable Enterprise Kernel Release 1 2-19

Unbreakable Enterprise Kernel Release 2 2-22

Tracking Mainline 2-25

DTrace 2-26

Btrfs Filesystem 2-27

Oracle Linux Release Notes 2-28

Summary 2-29

Quiz 2-30

Practice 2: Overview 2-32

3 Installing Oracle Linux

Objectives 3-2

Obtaining Oracle Linux 3-3

Oracle Software Delivery Cloud 3-4

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 4: D74508GC10_sg2

iv

The Anaconda Installer 3-5

The Boot Menu 3-6

Boot Options 3-7

Media Test 3-8

Language Selection 3-9

Keyboard Selection 3-10

Storage Devices Selection 3-11

Setting the Host Name 3-12

Configuring Network 3-13

IPv4 Settings 3-14

Time Zone Selection 3-15

Setting Root Password 3-16

Disk Partitioning Setup 3-17

Storage Devices 3-18

Default Partition Layout 3-19

Create Custom Layout 3-20

Standard Partition 3-21

Confirming Partitions 3-23

Boot Loader Selection 3-24

Quiz 3-25

Software Package Selection 3-26

Customize the Package Selection 3-28

Software Installation 3-29

FirstBoot Tool 3-30

Unattended Installation with Kickstart 3-31

Quiz 3-33

Summary 3-34

Practice 3: Overview 3-35

4 Linux Boot Process

Objectives 4-2

Linux Boot Process 4-3

Master Boot Record (MBR) 4-4

GRUB Bootloader 4-5

GRUB Configuration File 4-7

GRUB Menu 4-10

Editing a GRUB Menu Option 4-11

Kernel Boot Parameters 4-12

GRUB Command Line 4-14

The /sbin/init Process 4-15

SysV init Runlevels 4-16

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 5: D74508GC10_sg2

v

Working with Runlevels 4-17

The /etc/inittab File 4-19

The /etc/rc.d Directory 4-22

Stopping and Starting Services 4-24

Configuring Services 4-25

The ntsysv Utility 4-27

Summary 4-28

Quiz 4-29

Practice 4: Overview 4-32

5 System Configuration

Objectives 5-2

The /etc/sysconfig Directory 5-3

The /proc File System 5-5

Top-Level Files Within /proc 5-7

Process Directories in /proc 5-9

Other Directories in /proc 5-10

sysfs File System 5-12

sysctl Utility 5-14

Quiz 5-16

Summary 5-19

Practice 5: Overview 5-20

6 Package Management

Objectives 6-2

Introduction to Package Management 6-3

The rpm Utility 6-4

Oracle Public yum Server 6-6

yum Configuration 6-8

The yum Utility 6-10

yum Groups 6-12

Unbreakable Linux Network (ULN) 6-13

ULN Channels 6-14

Kernel RPM Packages 6-16

Switching from RHN to ULN 6-17

Quiz 6-19

Summary 6-21

Practice 6: Overview 6-22

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 6: D74508GC10_sg2

vi

7 Ksplice

Objectives 7-2

Introduction to Ksplice 7-3

How Ksplice Works 7-4

Ksplice Implementation 7-5

Generating an Access Key Through ULN 7-6

Creating Your Oracle Ksplice Uptrack Account 7-7

Setting Up Your Server with the Uptrack Tools 7-8

Installation Instructions 7-10

Manual Installation Instructions for Oracle Linux 7-11

Using Ksplice Uptrack 7-12

Ksplice Uptrack Command Summary 7-13

System Status 7-14

System Updated 7-15

Quiz 7-16

Summary 7-17

8 Automating Tasks

Objectives 8-2

Automating System Tasks 8-3

Configuring cron Jobs 8-4

Other cron Directories and Files 8-6

crontab Utility 8-8

Configuring anacron Jobs 8-9

at and batch 8-11

Quiz 8-13

Summary 8-14

Practice 8: Overview 8-15

9 System Logging

Objectives 9-2

System Log File Configuration 9-3

Facility/Priority-Based Filters 9-5

rsyslog Actions 9-7

rsyslog Templates 9-9

Configuring Log Rotation (logrotate) 9-11

logwatch 9-13

Quiz 9-14

Summary 9-15

Practice 9: Overview 9-16

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 7: D74508GC10_sg2

vii

10 Kernel Module Configuration

Objectives 10-2

Loadable Kernel Modules (LKM) 10-3

Loading and Unloading Kernel Modules 10-5

Kernel Module Parameters 10-8

Quiz 10-10

Summary 10-11

Practice 10: Overview 10-12

11 User and Group Administration

Objectives 11-2

Introduction to Users and Groups 11-3

User and Group Configuration Files 11-4

Adding a User Account 11-6

Modifying or Deleting User Accounts 11-9

Group Account Administration 11-10

User Private Groups 11-12

Password Configuration 11-14

The /etc/login.defs File 11-16

User Manager Tool 11-17

User/Group Administration in the Enterprise 11-18

Quiz 11-19

Summary 11-21

Practice 11: Overview 11-22

12 Oracle Linux File Systems

Objectives 12-2

Disk Partitions 12-3

Partition Table Manipulation Utilities 12-5

The fdisk Utility 12-6

Using the fdisk Utility 12-8

cfdisk Utility 12-11

parted Utility 12-12

File System Types 12-14

Making File Systems 12-16

Mounting File Systems 12-18

/etc/fstab File 12-21

Maintaining File Systems 12-22

Access Control Lists (ACLs) 12-24

Quiz 12-26

Swap Space 12-27

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 8: D74508GC10_sg2

viii

Disk Quotas 12-29

Configuring Disk Quotas 12-30

Quiz 12-33

Summary 12-34

Practice 12: Overview 12-35

13 Storage Administration

Objectives 13-2

Logical Volume Manager (LVM) 13-3

LVM Configuration: Example 13-4

Physical Volume Utilities 13-5

Volume Group Utilities 13-7

Logical Volume Utilities 13-9

Making Logical Volumes Usable 13-11

Redundant Array of Independent Disks (RAID) 13-13

mdadm Utility 13-15

Making RAID Devices Usable 13-17

Encrypted Block Devices 13-18

cryptsetup Utility 13-19

Making an Encrypted Device Usable 13-21

The kpartx Utility 13-22

Quiz 13-24

Summary 13-25

Practice 13: Overview 13-26

14 Network Configuration

Objectives 14-2

Network Interfaces 14-3

Additional Network Configuration Files 14-5

Command-Line Network Interface Utilities 14-7

Network Interface Bonding 14-9

VLANs 14-11

route Utility 14-13

NetworkManager 14-15

Network Connections Window 14-18

system-config-network Utility 14-19

Device Configuration 14-20

DNS Client Configuration 14-21

Quiz 14-22

Summary 14-23

Practice 14: Overview 14-24

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 9: D74508GC10_sg2

ix

15 Network Addressing and Name Services

Objectives 15-2

Introduction to DHCP 15-3

Configuring a DHCP Server 15-4

Configuring a DHCP Client 15-7

Introduction to DNS 15-9

Nameserver Types 15-10

BIND 15-11

DNS Cache-Only Nameserver 15-12

Starting a DNS Cache-Only Nameserver 15-15

Zone Files 15-16

Reverse Name Resolution 15-18

rndc Utility 15-20

host and dig Utilities 15-22

Quiz 15-23

Summary 15-24

Practice 15: Overview 15-25

16 File Sharing

Objectives 16-2

Introduction to NFS 16-3

NFS Server Configuration 16-6

Starting the NFS Service 16-8

The exportfs Utility 16-9

NFS Client Configuration 16-10

Auto-Mounting File Systems 16-12

Introduction to Samba 16-15

Samba Daemons and Services 16-16

Samba Server Configuration 16-17

Samba Server Types 16-19

Access Linux Shares from Windows 16-22

Access Windows Shares from Linux 16-24

Samba Utilities 16-25

Introduction to vsftpd 16-27

vsftpd Configuration Options 16-28

Quiz 16-30

Summary 16-31

Practice 16: Overview 16-32

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 10: D74508GC10_sg2

x

17 OpenSSH

Objectives 17-2

Introduction to OpenSSH 17-3

OpenSSH Configuration Files 17-4

OpenSSH Configuration 17-6

Using OpenSSH Utilities 17-7

Using the ssh Command 17-9

Using the scp Command 17-10

Using the sftp Command 17-11

Using the ssh-keygen Command 17-12

Quiz 17-14

Summary 17-15

Practice 17: Overview 17-16

18 Authentication and Directory Services

Objectives 18-2

Authentication Options 18-3

Authentication Configuration Tool 18-4

NIS Authentication 18-5

NIS Maps 18-6

NIS Server Configuration 18-8

NIS Client Configuration 18-10

Implementing NIS Authentication 18-11

Lightweight Directory Access Protocol (LDAP) 18-13

OpenLDAP 18-15

OpenLDAP Server Utilities 18-17

OpenLDAP Client Utilities 18-18

Configuring LDAP Authentication 18-19

Configuring Winbind Authentication 18-21

Configuring Kerberos Authentication 18-23

Configuring Advanced Options 18-24

SSSD 18-26

Configuring SSSD Services 18-27

Configuring SSSD Domains 18-29

Quiz 18-31

Summary 18-32

Practice 18: Overview 18-33

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 11: D74508GC10_sg2

xi

19 Pluggable Authentication Modules (PAM)

Objectives 19-2

Introduction to PAM 19-3

PAM Module Types 19-5

PAM Control Flags 19-6

PAM: Example #1 19-8

PAM: Example #2 19-10

Quiz 19-12

Summary 19-13

Practice 19: Overview 19-14

20 Security Administration

Objectives 20-2

Introduction to SELinux 20-3

SELinux Packages 20-4

SELinux Administration GUI 20-6

SELinux Modes 20-7

Setting a Mode 20-8

SELinux Policies 20-9

SELinux Booleans 20-11

SELinux File Labeling 20-13

SELinux Context 20-14

Confined SELinux Users 20-16

SELinux Utilities: Summary 20-18

Quiz 20-20

chroot Jail 20-21

chroot Utility 20-22

Implementing a chroot Jail 20-23

Running Services in a chroot Jail 20-25

Introduction to iptables 20-27

Firewall Configuration Tool 20-28

iptables Terminology 20-29

Beginning iptables Maintenance 20-31

Adding a Rule by Using the iptables Utility 20-33

iptables Rule Specs 20-35

More iptables Options 20-36

NAT Table 20-37

TCP Wrappers 20-39

TCP Wrappers Configuration 20-40

TCP Wrapper Command Options 20-42

Quiz 20-44

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 12: D74508GC10_sg2

xii

Summary 20-45

Practice 20: Overview 20-46

21 Web and Email Services

Objectives 21-2

Apache HTTP Server 21-3

Configuring Apache 21-4

Testing Apache 21-6

Apache Containers 21-7

Apache Virtual Hosts 21-9

Quiz 21-11

Email Program Classifications 21-12

Email Protocols 21-13

Postfix SMTP Server 21-15

Sendmail SMTP Server 21-16

Configuring Sendmail on a Client 21-18

Quiz 21-19

Summary 21-20

Practice 21: Overview 21-21

22 System Monitoring and Troubleshooting

Objectives 22-2

sosreport Utility 22-3

Kdump Setup Configuration GUI 22-5

Kdump Setup Using the Command Line 22-7

netdump Utility 22-9

iostat Utility 22-11

mpstat Utility 22-13

vmstat Utility 22-15

sar Utility 22-17

top Utility 22-19

iotop Utility 22-21

strace Utility 22-22

netstat Utility 22-23

tcpdump Utility 22-25

OSWatcher Black Box (OSWbb) 22-27

OSWbb Diagnostic Data Output 22-29

Enterprise Manager Ops Center 22-33

Enterprise Manager Ops Center GUI 22-35

PCL and perf Tool 22-36

Quiz 22-38

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 13: D74508GC10_sg2

xiii

Summary 22-39

Practice 22: Overview 22-40

23 Oracle on Oracle

Objectives 23-2

Oracle Software User Accounts 23-3

Oracle Software Group Accounts 23-4

System Resource Tuning 23-5

Linux Shared Memory 23-6

Semaphores 23-7

Network Tuning 23-9

Setting the File Handles Parameter 23-10

Asynchronous IO (AIO) 23-11

Oracle-Related Shell Limits 23-12

HugePages 23-14

Configuring HugePages 23-16

Oracle Database Smart Flash Cache (DBSFC) 23-18

Oracle Pre-Install RPM 23-19

Oracle ASM 23-21

ASM Library Driver (ASMLib) 23-23

Using ASMLib Commands 23-25

Oracle Cluster File System Version 2 (OCFS2) 23-27

Using OCFS2 23-28

Kernel Configuration 23-29

Using OCFS2 23-30

OCFS2 Heartbeat 23-32

Quiz 23-33

Summary 23-34

Practice 23: Overview 23-35

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 14: D74508GC10_sg2

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 15: D74508GC10_sg2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Network Addressing and Name Services

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 16: D74508GC10_sg2

Oracle Linux System Administration 15 - 2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Objectives

After completing this lesson, you should be able to:• Describe DHCP

• Configure a DHCP server

• Configure a DHCP client and request a lease

• Describe DNS

• Describe nameserver types

• Describe BIND

• Configure a cache-only nameserver

• Describe and configure Zone Files

• Describe and configure Reverse Name Resolution• Use the rndc utility

• Use the host and dig utilities

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 17: D74508GC10_sg2

Dynamic Host Configuration Protocol (DHCP) allows client machines to automatically obtain network configuration information from a DHCP server each time they connect to the network. The DHCP server is configured with a range of IP addresses and other network configuration parameters.

When the client machine is configured to use DHCP, the client daemon, dhclient, contacts the server daemon, dhcpd, to obtain the networking parameters. DHCP is broadcast-based so both the client and the server must be on the same subnet.

The server provides a lease on the IP address to the client. The client can request specific terms of the lease, such as its duration. The server can also be configured to limit the terms of the lease. While connected to the network, the dhclient automatically renews the lease before it expires. You can configure the DHCP server to provide the same IP address each time to specific clients.

The advantages of using DHCP include ease of adding a new client machine to the network, and centralized management of IP addresses. In addition, the number of total IP addresses needed is reduced, because IP addresses can be reused. DHCP is also useful if you want to change the IP addresses of a large number of systems. Instead of reconfiguring each system individually, edit the DHCP configuration file on the server and enter the new set of IP addresses.

Oracle Linux System Administration 15 - 3

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Introduction to DHCP

• Client machines automatically obtain network configuration information from a DHCP server.

• Client “leases” the network information.– The terms of the lease are configurable.

– The lease is renewed automatically by the client while the network is in use.

• The DHCP server can provide static IP addresses.

• DHCP is broadcast-based.– This requires the client and the server to be on same subnet.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 18: D74508GC10_sg2

To configure a system as a DHCP server, install the dhcp package:

# yum install dhcp

DHCP Configuration FileThe main configuration file for DHCP is /etc/dhcp/dhcpd.conf. Use this file to store network information for the clients. The following is a sample dhcpd.conf configuration file:

default-lease-time 21600;

max-lease-time 43200;

option subnet-mask 255.255.255.0;

option broadcast-address 192.168.1.255;

option routers 192.168.1.1;

option domain-name-servers 192.168.1.1;

subnet 192.168.1.0 netmask 255.255.255.0 {

range 192.168.1.200 192.168.1.254;

}

A sample file exists in /usr/share/doc/dhcp-<version>/dhcpd.conf.sample.

Oracle Linux System Administration 15 - 4

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Configuring a DHCP Server

1. Install the dhcp package.The /etc/dhcp/dhcpd.conf configuration file specifies:

– Lease times

– Options

– Subnet declarations with range of IP addresses

– Host declarations for static IP address assignment

– Shared network declarations for multiple subnets

– Group declarations to apply global parameters

2. Start the service after changing the configuration:# service dhcpd start

3. Specify command line arguments and options in: /etc/sysconfig/dhcpd

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 19: D74508GC10_sg2

The configuration entries in the sample are described here. Note that each entry, with exception of the subnet declaration, is terminated with a semicolon (;).

• default-lease-time: Specifies the number of seconds the IP lease remains valid if the client requesting the lease does not specify a duration

• max-lease-time: Specifies the maximum number of seconds allowed for a lease

OptionsInformation in the option lines is sent to each client when it requests a lease. In this example, the subnet-mask, broadcast-address, routers (default gateway IP address), and DNS server IP are sent to the client. The default gateway and DNS server are the same system in this example. Run the man 5 dhcp-options command for a description of available options.

Subnet DeclarationThe subnet declaration includes a range of IP address that the DHCP server can assign to clients. This example defines a range between 192.168.1.200 and 192.168.1.254.

You can declare multiple subnets and specify parameters within the braces ({ }). Parameters specified within the braces apply to the clients on the subnet. Parameters configured outside of a subnet declaration are global and apply to all client systems.

Host DeclarationTo provide a static IP address to a specific client system, use a host declaration and include the MAC address of the client and the static IP address to be assigned to the client. Example:

host host01 {

hardware ethernet 00:16:3E:00:01:01;

fixed-address 192.168.1.101;

max-lease-time 84600;

}

In this example, IP address of 192.168.1.101 is always assigned to the system with the MAC address of 00:16:3E:00:01:01. The max-lease-time included within the declaration is specific to this host and overrides the global parameter defined outside the curly brackets.

Shared-Network DeclarationDeclare all subnets that share the same physical network within a shared-networkdeclaration. Parameters within the shared network, but outside the enclosed subnet declarations, are considered to be global parameters. The following is an example of a shared-network declaration with two subnets. The routers parameter applies to both subnets:

shared-network name {

option routers 192.168.0.254;

subnet 192.168.1.0 netmask 255.255.252.0 {

range 192.168.1.200 192.168.1.254;

}

subnet 192.168.2.0 netmask 255.255.252.0 {

range 192.168.2.200 192.168.2.254;

}

}

Oracle Linux System Administration 15 - 5

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 20: D74508GC10_sg2

Group DeclarationUse the group declaration to apply global parameters to a group of declarations. Shared networks, subnets, and hosts can be grouped. The following is an example of a groupdeclaration with two host declarations:

group {

option routers 192.168.0.254;

host host01 {

hardware ethernet 00:16:3E:00:01:01;

fixed-address 192.168.1.101;

}

host host02 {

hardware ethernet 00:16:3E:00:01:02;

fixed-address 192.168.1.102;

}

}

Start the DHCP ServiceYou can specify command-line options and arguments by placing them in /etc/sysconfig/dhcpd. For example, to configure the server to only start the service on a specific interface, edit /etc/sysconfig/dhcpd file and add the name of the interface to the DHCPDARGS directive. The following example starts the service on eth1 only:

DHCPDARGS=eth1

Start the service as follows. After making any changes to the configuration, restart the DHCP service.

# service dhcpd start

The server fails to start if the /var/lib/dhcpd/dhcpd.leases file does not exist. If the service fails to start, you can use the touch command to create the file:

# touch /var/lib/dhcpd/dhcpd.leases

This file stores the client lease information. Do not edit this file.

To ensure that the dhchd service starts at boot time, enter the following command to enable the service for runlevels 2, 3, 4, and 5:

# chkconfig dhcpd on

Oracle Linux System Administration 15 - 6

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 21: D74508GC10_sg2

To configure a system as a DHCP client, install the dhclient package:

# yum install dhclient

Change the BOOTPROTO directive in the /etc/sysconfig/network-scripts/ifcfg-<interface> file for the device to dhcp. For example, to use DHCP on eth1, perform the following:• Edit /etc/sysconfig/network-scripts/ifcfg-eth1

• Set BOOTPROTO=dhcp

You also need to set NETWORKING=yes in the /etc/sysconfig/network file.

The next time the client system connects to the network, dhclient requests a lease from the DHCP server and configures the client’s network interface. You can also run dhclient from the command line to request a lease and make a connection:

$ dhclient

To request on a specific interface, include the interface as an argument. The following example only request a lease for eth1:

$ dhclient eth1

Oracle Linux System Administration 15 - 7

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Configuring a DHCP Client

1. Install the dhclient package.

2. Set NETWORKING=yes in /etc/sysconfig/network.

3. Set BOOTPROTO=dhcp in the /etc/sysconfig/network-scripts/ifcfg-<device> file.

4. Optionally, enter any custom configuration information in the DHCP client configuration file, /etc/dhclient.conf.

5. Run the dhclient command to request a lease from the server.– After being configured to use DHCP, this command runs at

boot time.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 22: D74508GC10_sg2

The DHCP client configuration file, /etc/dhclient.conf, is only required for custom configurations. A sample file exists in /usr/share/doc/dhclient-<version>/dhclient.conf.sample. The following example specifies the use of DHCP on a single interface, eth1, which has a MAC address of 00:16:3e:00:02:02:

# cat /etc/dhclient.conf

interface “eth1” {

send dhcp-client-identifier 1:00:16:3e:00:02:02;

}

When the client has requested and established a lease, information about the lease is stored in /var/lib/dhclient/dhclient.leases. Example:

# cat /var/lib/dhclient/dhclient.leases

lease {

interface “eth1”;

fixed-address 192.168.1.200;

option subnet-mask 255.255.255.0;

option routers 192.168.1.1;

option dhcp-lease-time 21600;

option dhcp-message-type 5;

option domain-name-servers 192.168.1.1;

option dhcp-server-identifier 192.168.1.103;

option broadcast-address 192.168.1.255;

option domain-name “example.com”;

renew 1 2012/02/20 20:18:58;

rebind 1 2012/02/20 23:15:26;

expire 2 2012/02/20 00:00:26;

}

Oracle Linux System Administration 15 - 8

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 23: D74508GC10_sg2

DNS (Domain Name System) is a network service that maps, or resolves, domain names to their respective IP addresses. It reduces the need for users to remember IP addresses as they can refer to machines on the network by name. The mapping done by /etc/hosts on a small LAN (local area network) is handled by DNS on large networks, including the Internet.

The DNS database is hierarchical and distributed. Each level of the hierarchy is divided by a period (.). Consider the following example of a fully qualified domain name (FQDN):

wiki.us.oracle.com.

The root domain is represented by a period (.) and is frequently omitted except in zone files. The top-level domain in this example is com, oracle is a sub-domain of com, us is a sub-domain of oracle, and wiki is the host name. For administrative purposes, each of these domains are grouped into zones. A DNS server, called a nameserver holds all the information to resolve all domains within a zone. The DNS server for a zone also holds pointers to DNS servers responsible for resolving a domain’s subdomains.

When a client requests resolution of wiki.us.oracle.com from a nameserver, if the nameserver cannot resolve the FQDN, it queries a root nameserver, which returns the nameserver which can resolve com. This nameserver is queried and returns the nameserver to resolve oracle.com. This nameserver is queried and returns the nameserver to resolve us.oracle.com, which is queried and returns the IP address for the FQDN to the client.

Oracle Linux System Administration 15 - 9

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Introduction to DNS

• DNS is a network service that maps, or resolves, domain names to their respective IP addresses.– wiki.us.oracle.com > 139.185.51.248

• DNS performs the function of /etc/hosts file, but on the Internet.

• The DNS database is hierarchical and distributed.– Each level of hierarchy is divided by a period (.).

• Resolution occurs from right to left:1. com is resolved.2. oracle.com is resolved.3. us.oracle.com is resolved.4. The IP address of wiki.us.oracle.com is returned to the

client.

• DNS servers are called nameservers.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 24: D74508GC10_sg2

An authoritative nameserver responds to queries about names that are part of their zones only. Authoritative nameservers can be either primary (master) nameservers or secondary (slave) nameservers. Each zone has at least one authoritative DNS server. A DNS query returns information about a domain and specifies which DNS server is authoritative for that domain.

A primary, or master nameserver, is the authoritative server that holds the master copy of zone data. Secondary, or slave nameservers, are also authoritative but copy zone information from the master nameserver or from another slave nameserver. A nameserver can also serve as a primary or secondary server for multiple zones at the same time.

Caching-only, or recursive nameservers, offer resolution services but they are not authoritative for any zone. These DNS cache nameservers store answers to previous queries in cache (memory) for a fixed period of time. When a caching-only nameserver receives a query, it answers from cache if it can. If it does not have the answer in cache, if forwards the query to an authoritative server.

Although it is not recommended for reasons of security, nameservers can also be configured to give authoritative answers to queries in some zones, while acting as a caching-only nameserver for all other zones.

Oracle Linux System Administration 15 - 10

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Nameserver Types

• Authoritative nameservers:– Answer queries about names that are part of their zones only

– Can be either primary (master) or secondary (slave)

• The primary nameserver holds the master copy of zone data.

• Secondary nameservers copy zone data from master nameserver or another slave nameserver.

• Caching-only, or recursive, nameservers:– Offer resolution services, but are not authoritative

– Cache the answers from previous queries

– Respond to queries from the cache if possible

– Otherwise, they forward the query to an authoritative server.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 25: D74508GC10_sg2

The DNS server included in Oracle Linux is called BIND (Berkeley Internet Name Domain). BIND includes the DNS server daemon, named, tools for working with DNS such as the rndcadministration utility, and several configuration files. To install the bind package type:

# yum install bind

The primary BIND configuration files and directories are:• /etc/named.conf: The main configuration file that lists the location and

characteristics of all your domain’s zone files

• /var/named: The default directory in which zone files are stored

• /etc/named.rfc1912.zones: The base configuration file for implementing a caching-only nameserver.

• /var/named/named.ca: A file that contains a list of the 13 root authoritative DNS servers

Use the following commands to ensure that the named service starts at boot time and to start the service. Restart named after making any configuration changes:

# chkconfig named on

# service named start

BIND named options are set in the /etc/sysconfig/named file.

Oracle Linux System Administration 15 - 11

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

BIND

• The DNS server included in Oracle Linux is called BIND.• The BIND server daemon is named.

• The remote administration utility is rndc.

• Configuration files and directories include:– /etc/named.conf: The main configuration file

– /var/named: The default directory for storing zone files

– /etc/named.rfc1912.zones: The base configuration file for implementing a caching-only nameserver

– /var/named/named.ca: Contains a list of the 13 root authoritative DNS servers

• BIND named options are set in /etc/sysconfig/named.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 26: D74508GC10_sg2

A caching-only nameserver is installed by default with the bind package. This DNS cache nameserver is not authoritative, it only stores the results of queries in memory. The default BIND configuration files provide this caching-only nameserver service.

The following is the default /etc/named.conf:

options {

listen-on port 53 { 127.0.0.1; };

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

directory “/var/named”;

dump-file “/var/named/data/cache_dump.db”;

statistics-file “/var/named/data/named_stats.txt”;

memstatistics-file“/var/named/data/named_mem_stats.txt”;

allow-query { localhost; };

recursion yes;

Oracle Linux System Administration 15 - 12

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

DNS Cache-Only Nameserver

• The default BIND configuration files provide a caching-only nameserver service.

• /etc/named.conf defines:– options: Global server configuration options

– logging: Enables logging

– zone: Specifies authoritative servers for the root domain (/var/named/named.ca)

– include: Includes /etc/named.rfc1912.zones

• /etc/named.rfc1912.zones

– Specifies five predefined zones

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 27: D74508GC10_sg2

Default /etc/named.conf, file continued:

dnssec-enable yes;

dnssec-validation yes;

dnssec-lookaside auto;

/* Path to ISC DLV key */

bindkeys-file “/etc/named.iscdlv.key”;

};

logging {

channel default_debug {

file “data/named.run”;

severity dynamic;

};

};

zone “.” IN {

type hint;

file “named.ca”;

};

include “/etc/named.rfc1912.zones”;

/etc/named.conf

The options statement defines global server configuration options and sets defaults for other statements. The following options are defined in the default /etc/named.conf file:

• listen-on: Instructs named to listen on port 53 on the local system for both IPv4 and IPv6 queries

• directory: Specifies the default working directory for the named service

• dump-file: Specifies the location where BIND dumps the database (cache) in the event of a crash

• statistics-file: Specifies the location to which data is written when the command rndc stats is issued

• memstatistics-file: Specifies the location to which BIND memory usage statistics are written

• allow-query: Specifies which IP addresses (only localhost in this example) are allowed to query the server

• recursion: Instructs the nameserver to perform recursive queries. Recursive queries cause a nameserver to query another nameserver if necessary to respond with an answer.

• dnssec-enable: Specifies that a secure DNS service is being used

Oracle Linux System Administration 15 - 13

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 28: D74508GC10_sg2

• dnssec-validation: Instructs the nameserver to validate replies from DNSSEC-enabled (signed) zones

• dnssec-lookaside: Enables DNSSEC Lookaside Validation (DLV) using the /etc/named.iscdlv.key

The logging statement turns on logging and causes messages to be written to the data/named.run file. The severity parameter controls the logging level. The value dynamic means assume the global level defined by either the command-line parameter -d or by running the rndc trace command.

The zone section specifies the initial set of root servers using a hint zone, whose name is a period (.). This zone specifies that the nameserver look in /var/named/named.ca for IP addresses of authoritative servers for the root domain when the nameserver starts or does not know which nameserver to query.

The include statement allows files to be included. This can be done for readability, ease of maintenance, or so that potentially sensitive data can be placed in a separate file with restricted permissions. This include statement includes the /etc/named.rfc1912.zones file as though it were present in this file.

/etc/named.rfc1912.zones

The /etc/named.rfc1912.zones file contains five zone sections. Domains are grouped into zones and zones are configured through the use of zone files. The zone statement defines the characteristics of a zone, the location of its zone file, and zone-specific options, which override the global options statements. The following zones are defined in this file:

• localhost.localdomain: Specifies that localhost.localdomain points to 127.0.0.1, preventing the local server from looking upstream for this information

• localhost: Sets up the normal server on the local system

• 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa: Sets up IPv6 reverse name resolution

• 1.0.0.127.in-addr.arpa: Sets up IPv4 reverse name resolution

• 0.in-addr.arpa: Specifies that IP addresses that start with 0 have their reverse lookup handled by the local server, preventing the local server from looking upstream

Zone options are included for each of these five zones:

• type: Specifies the zone type, such as master, delegation-only, forward, hint, or slave. Type master designates the nameserver as authoritative for this zone. A zone is set as master if the zone file resides on this system.

• file: Specifies the name of the zone file, which is stored in the working directory defined by the directory option (/var/named in this example)

• allow-update: Specifies which hosts are allowed to dynamically update information in their zone. Dynamic updates are set to none for these zones, meaning they are not allowed.

Oracle Linux System Administration 15 - 14

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 29: D74508GC10_sg2

To configure a system as a DNS cache-only nameserver, perform the following steps (as the root user):

1. nstall the bind, package:# yum install bind

2. Shut down the active network interfaces:

# service network stop

3. Add the following line to the /etc/sysconfig/network-scripts/ifcfg-<interface> file. This line prevents dhclient from overwriting /etc/resolv.conf when starting the network service while using DHCP:PEERDNS=no

4. Add the following line to the beginning of the /etc/resolv.conf file. This line indicates use of the local system as the primary nameserver.

nameserver 127.0.0.1

5. Start the network service and the named service:# service network start

# service named start

Oracle Linux System Administration 15 - 15

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Starting a DNS Cache-Only Nameserver

1. Install BIND:# yum install bind

2. Stop the network service:# service network stop

3. Add to ifcfg-<interface>:PEERDNS=no

4. Add to the beginning of /etc/resolv.conf:nameserver 127.0.0.1

5. Start the network service and the named service:# service network start

# service named start

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 30: D74508GC10_sg2

Information about domains in the DNS database is stored zone files. A zone file consists of directives and resource records. Directives tell the nameserver to perform tasks or apply special settings to the zone. Resource records define the parameters of the zone and store host information. Directives are optional, but resource records are required.

A resource record has the following fields (some fields are optional, depending on the Type):

• Name: The domain name or IP address

• TTL: Time to live, maximum time a record is cached before checking for a newer one

• Class: Always IN for Internet

• Type: Record type

• Data: Varies with record type

More than 30 types of resource records exist. The more common ones are:

• A: IPv4 address

• CNAME: Canonical Name or alias

• MX: Mail Exchange, specifies the destination for mail addressed to the domain

• NS: Nameserver, specifies the system that provides DNS records for the domain

• PTR: Maps an IP address to a domain name for reverse name resolution

• SOA: Start of Authority, designates the start of a zone

Oracle Linux System Administration 15 - 16

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Zone Files

• Zone files:– Store information about domains in the DNS database

– Contain directives, (which are optional) and resource records

• Resource records contain (not all fields are required):– Name: The domain name or IP address

– TTL: Time to live

– Class: Always IN for Internet

– Type: Record type

– Data: Varies with record type

• Common types of resource records include:– A, CNAME, MX, NS, PTR, SOA

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 31: D74508GC10_sg2

The following is an example of a zone file:

$TTL 86400 ; 1 day

example.com IN SOA dns.example.com. [email protected]. (

57 ; serial

28800 ; refresh (8 hours)

7200 ; retry (2 hours)

2419200 ; expire (4 weeks)

86400 ; minimum (1 day)

)

IN NS dns.example.com.

dns IN A 192.0.2.1

example.com IN A 192.0.2.1

host01 IN A 192.0.2.101

host02 IN A 192.0.2.102

host03 IN A 192.0.2.103

The $TTL entry is a directive that defines the default time to live for all resource records in the zone. Each resource record can have a TTL value, which overrides this global directive.

The next line in the example is the SOA record. All zone files must have one SOA record. The following information is included in the SOA record:

• example.com: The name of the domain

• dns.example.com.: The FQDN of the nameserver

[email protected].: The email address of the user who is responsible for the zone

• serial: A numerical value that is incremented each time the zone file is altered to indicate when it is time for the named service to reload the zone

• refresh: The elapsed time after which the primary nameserver notifies secondary nameservers to refresh their database

• retry: The time to wait after which a refresh fails before trying to refresh again

• expire: The time after which the zone is no longer authoritative and the root nameservers must be queried

• minimum: The amount of that time that other nameservers cache the zone’s information

The NS (Nameserver) record announces authoritative nameservers for a particular zone using the format: IN NS dns.example.com.

The A (Address) records specify the IP address to be assigned to a name using the format: hostname IN A IP-address

Oracle Linux System Administration 15 - 17

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 32: D74508GC10_sg2

Normal, or forward, resolution returns an IP address when the domain name is known. The zone characteristics are defined in /etc/named.conf. For example:

zone “example.com” {

type master;

file “data/master-example.com”;

allow-update { key “rndckey”; };

notify yes;

};

Zone options included in this example are:

• type: Specifies the master zone type, meaning the nameserver is authoritative for this zone, and the zone file resides on this system

• file: Specifies master-example.com as the name of the zone file and its location

• allow-update: This example uses a Transaction SIGnatures (TSIG) key, which ensures that a shared secret key exists on both primary and secondary nameserver before allowing a transfer.

• notify: Specifies whether to notify the secondary nameservers when a zone is updated

Oracle Linux System Administration 15 - 18

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Reverse Name Resolution

• Normal, or forward, resolution returns an IP address when the domain name is known.

• Reverse name resolution returns the domain name when an IP address is known.

• DNS implements reverse name resolution by use of the following special domains:– in-addr.arpa: For IPv4

– ip6.arpa: For IPv6

• Zone names reverse the network portion of the IP address and append the special domain name:– 2.0.192.in-addr.arpa

• Resource records use type PTR.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 33: D74508GC10_sg2

The following is an example of the A (address) records in master-example.com zone file:

# cat /var/named/data/master-example.com

...

dns IN A 192.0.2.1

example.com IN A 192.0.2.1

host01 IN A 192.0.2.101

host02 IN A 192.0.2.102

host03 IN A 192.0.2.103

DNS also provides reverse name resolution, which returns a domain name for a given IP address. DNS implements reverse name resolution by use of the following special domains:• in-addr.arpa: For IPv4

• ip6.arpa: For IPv6

The zone characteristics are defined in /etc/named.conf, for example:

zone “2.0.192.in-addr.arpa” IN {

type master;

file “data/reverse-192.0.2”;

allow-update { key “rndckey”; };

notify yes;

};

The zone name consists of in-addr.arpa proceeded with the network portion of the IP address for the domain. In this example, the network is 192.0.2, which in reverse is 2.0.192.

Resource records in these domains have Name fields that contain IP addresses and Type fields of PTR. The following is an example of the 2.0.192.in-addr.arpa zone file:

$TTL 86400 ; 1 day

2.0.192.in-addr.arpa IN SOA dns.example.com. [email protected]. (

57 ; serial

28800 ; refresh (8 hours)

7200 ; retry (2 hours)

2419200 ; expire (4 weeks)

86400 ; minimum (1 day)

)

IN NS dns.example.com.

1 IN PTR dns

1 IN PTR example.com

101 IN PTR host01

102 IN PTR host02

103 IN PTR host03

Oracle Linux System Administration 15 - 19

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 34: D74508GC10_sg2

The rndc utility is a command line tool to administer the named service, both locally and from a remote machine. To prevent unauthorized access to the service, rndc must be configured to listen on the selected port (port 953 by default), and an identical key must be used by both the service and the rndc utility. The rndc key is generated by using the following command:

# rndc-confgen –a

wrote key file “/etc/rndc.key”

This command creates the /etc/rndc.key file, which contains the key. To configure namedto use the key, include the following entries in /etc/named.conf:

include “/etc/rndc.key”;

controls {

inet 127.0.0.1 allow { localhost; } keys { “rndckey”; }

};

The include statement allows files to be included so that potentially sensitive data can be placed in a separate file with restricted permissions. To ensure that only root can read the file enter the following:

# chmod o-rwx /etc/rndc.key

Oracle Linux System Administration 15 - 20

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

rndc Utility

• rndc is a command-line administration tool for named.

• Use rndc key to prevent unauthorized access.

• The rndc key is generated by using the following command:– # rndc-confgen –a

• Configure named to use the key in /etc/named.conf.

• Type rndc to display usage of the utility and a list of available commands.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 35: D74508GC10_sg2

The controls statement defines access information and the various security requirements necessary to use the rndc command.

• inet: The example allows you to control rndc from a console on the localhost (127.0.0.1).

• keys: Keys are used to authenticate various actions and are the primary access control method for remote administration. The example specifies using the rndckey, which is defined in the /etc/rndc.key include file.

Type rndc to display usage of the utility and a list of available commands:

# rndc

Usage: rndc [-c config] [-s server] [-p port] [-key fey-file] [-y key] [-V] command

Command is one of the following:

reload Reload configuration file and zones

...

reconfig Reload configuration file and new zones only.

stats Write server statistics to the statistics file.

querylog Toggle query logging.

dumpdb Dump cache(s) to the dump file (named_dump.db)

stop Save pending updates to master files and stop the server.

halt Stop the server without saving pending updates.

...

status Display status of the server

...

The following is an example of some of the rndc commands:

Use the rndc status command to check the current status of the named service:

# rndc status

number of zones: 3

debug level: 0

xfers running: 0

xfers deferred: 0

soa queries in progress: 0

query logging is OFF

recursive clients: 0/1000

tcp clients: 0/100

server is up and running

Use the rndc reload command to reload both the configuration file and zones:

# rndc reload

server reload successful

Oracle Linux System Administration 15 - 21

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 36: D74508GC10_sg2

The dig utility is deprecated and replaced by the host utility for performing DNS lookups. The host utility returns the same information as dig and has more options. When no arguments are given, host displays a summary of its command-line arguments and options. Include the –a option to host for more verbose output.

To look up the IP address for host01:

# host host01

# dig host01.example.com

To perform a reverse lookup, that is to query DNS for the domain name that corresponds to an IP address:

# host 192.0.2.101

# dig –x 192.0.2.101

To query DNS for the IP address that corresponds to a domain:

# host dns.example.com

# dig dns.example.com

Oracle Linux System Administration 15 - 22

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

host and dig Utilities

• host and dig are command-line tools to perform DNS lookups.

• The host command has more options.

• Examples of queries using host:– # host

– # host –a dns.example.com

– # host –a host01

– # host –a 192.0.2.101

• Examples of queries using dig:– # dig dns.example.com

– # dig –x 192.0.2.101

– # dig example.com NS

– # dig example.com A

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 37: D74508GC10_sg2

Oracle Linux System Administration 15 - 23

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Quiz

Which of the following is the main configuration file for BIND?a. /var/bind.conf

b. /var/named.conf

c. /etc/named.conf

d. /etc/bind.conf

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 38: D74508GC10_sg2

Oracle Linux System Administration 15 - 24

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Summary

In this lesson, should have you learned how to:

• Describe DHCP

• Configure a DHCP server

• Configure a DHCP client and request a lease

• Describe DNS

• Describe Nameserver Types

• Describe BIND

• Configure a Cache-Only Nameserver

• Describe and Configure Zone Files

• Describe and Configure Reverse Name Resolution• Use the rndc utility

• Use the host and dig utilities

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 39: D74508GC10_sg2

Oracle Linux System Administration 15 - 25

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Practice 15: Overview

The practices for this lesson cover the following:

• Configuring a DHCP server

• Configuring a DHCP client

• DNS configuration

• Accessing the Public Yum Server

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 40: D74508GC10_sg2

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 41: D74508GC10_sg2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

File Sharing

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 42: D74508GC10_sg2

Oracle Linux System Administration 16 - 2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Objectives

After completing this lesson, you should be able to:• Describe NFS

• Configure NFS server and client• Describe the exportfs utility

• Describe and configure automounter

• Describe and configure Samba

• Access Samba shares• Describe and configure vsftpd

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 43: D74508GC10_sg2

A Network File system (NFS) allows a server to share directory hierarchies (file systems) with remote systems over a network. NFS servers export the directory and NFS clients mount the exported directory. The server directory then appears to the client systems as if they were local directories. NFS reduces storage needs and improves data consistency and reliability, because users are accessing files that are stored on a centralized server.

The Linux 2.6 (and later) kernel supports three versions of the NFS protocol:

• NFS version 2 (NFSv2), specification is RFC 1094

• NFS version 3 (NFSv3), specification is RFC 1813

• NFS version 4 (NFSv4), specification is RFC 3530

NFS relies on Remote Procedure Calls (RPC) between clients and servers. RPC services are controlled by the rpcbind service. The rpcbind service replaces portmap, which was used in previous versions of Linux to map RPC program numbers to IP address port number combinations. rpcbind responds to requests for RPC services and sets up connections to the requested RPC service.

rpcbind is not used with NFSv4, because the server listens on well-known TCP port 2049. The mounting and locking protocols have also been incorporated into the NFSv4 protocol, so NFSv4 does not interact with the lockd and rpc.statd daemons either.

Oracle Linux System Administration 16 - 3

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Introduction to NFS

• NFS allows a Linux server to share directory hierarchies with Linux clients over a network.

• NFS servers export the directory, and NFS clients mount the exported directory.

• Oracle Linux supports three versions:– NFSv2

– NFSv3

– NFSv4

• NFS relies on Remote Procedure Calls (RPC) between clients and servers.

• Several nfs and rpc services work together, depending on which version of NFS is implemented.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 44: D74508GC10_sg2

The following are descriptions of other services used by various versions of NFS:nfs

Starting this service starts the NFS server and other RPC processes needed to service requests for shared NFS file systems. Example:

# service nfs start

Starting NFS services: [ OK ]

Starting NFS quotas: [ OK ]

Starting NFS daemon: [ OK ]

Starting NFS mountd: [ OK ]

To display the names of the services (process IDs are examples only):

# service nfs status

rpc.svcgssd is stopped

rpc.mountd (pid 9874) is running...

nfsd (pid 9871 9870 9869 9868 9867 9866 9865 9864) is running...

rpc.rquotad (pid 9859) is running...

rpc.nfsd

This is the NFS server process that implements the user level part of the NFS service. The main functionality is handled by the nfsd kernel module. The user space program merely specifies what sort of sockets the kernel server should listen on, what NFS versions it should support, and how many kernel threads it should use.

Notice that multiple (8) nfsd threads are running in the service nfs status output example. Reading the /proc/fs/nfsd/threads file also shows the number of threads. Writing a number to this file causes the number of threads to be changed to that number. Example:

# cat /proc/fs/nfsd/threads

8

# echo 7 > /proc/fs/nfsd/threads

# service nfs status | grep nfsd

nfsd (pid 9870 9869 9868 9867 9866 9865 9864) is running...

rpc.mountd

This is the NFS mount daemon that implements the server side of the mount requests from NFSv2 and NFSv3 clients. It checks that the requested NFS share is currently exported by the NFS server, and that the client is allowed to access it. For NFSv4, the rpc.mountd daemon is required only on the NFS server to set up the exports.rpc.rquotad

This process provides user quota information for remote users. It is started automatically by the nfs service and does not require user configuration. The results are used by the quotacommand to display user quotas for remote file systems and by the edquota command to set quotas on remote file systems.

Oracle Linux System Administration 16 - 4

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 45: D74508GC10_sg2

nfslock

Starting this service starts the RPC processes that allow NFS clients to lock files on the server. nfslock is only needed for NFSv2 and NFSv3.

rpc.statd

This process implements the Network Status Monitor (NSM) RPC protocol, which notifies NFS clients when an NFS server is restarted without being gracefully brought down. This is not used with NFSv4. rpc.statd does not require user configuration and is started automatically by the nfslock service:

# service nfslock start

Starting NFS statd: [ OK ]

lockd

This is a kernel thread that runs on both clients and servers. It implements the Network Lock Manager (NLM) protocol, which allows NFSv2 and NFSv3 clients to lock files on the server. It is started automatically whenever the NFS server is run and whenever an NFS file system is mounted. This process, along with rpc.statd, is stopped when stopping the nfslockservice:

# service nfslock stop

Stopping NFS locking: [ OK ]

Stopping NFS statd: [ OK ]

rpc.svcgssd/rpc.gssd

These are the rpcsec_gss daemons. The rpcsec_gss protocol gives a means of using the gss-api generic security API to provide security for protocols using RPC. Before exchanging any RPC requests using rpcsec_gss, the RPC client must first establish a security context with the RPC server. Refer to man exports for description of implementing RPCSEC_GSS security.rpc.idmapd

This provides NFSv4 client and server upcalls, which map between on-the-wire NFSv4 names (which are strings in the form of user@domain) and local UIDs and GIDs. For idmapd to function with NFSv4, the /etc/idmapd.conf must be configured. This service is required for use with NFSv4, although not when all hosts share the same DNS domain name.

Oracle Linux System Administration 16 - 5

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 46: D74508GC10_sg2

To begin configuring a system as an NFS server, install the nfs-utils package:

# yum install nfs-utils

The main configuration file for the NFS server is /etc/exports. The /etc/exports file stores a list of exported directory hierarchies that remote systems can mount. The format for entries is:

export-point client1(options) [client2(options) … ]

The export-point is the absolute path name of the directory hierarchy to be exported. One or more client systems, each with specific options, can mount the export-point. There are no spaces between the client attribute and the open bracket. When no client options are specified, the following default settings apply:• ro: Read-only. Client hosts cannot change the data shared on the file system. To allow

client hosts to make changes to the file system, specify the rw (read/write) option.

• sync: The NFS server replies to requests only after changes made by previous requests are written to disk. async specifies that the server does not have to wait.

• wdelay: The NFS server delays committing write requests when it suspects another write request is imminent. To disable the delay, use the no_wdelay option. no_wdelayis only available if the default sync option is also specified.

Oracle Linux System Administration 16 - 6

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

NFS Server Configuration

• Install the nfs-utils package.

• The main configuration file for the NFS server is /etc/exports.– It contains a list of exported directory hierarchies that remote

systems can mount.

• The format of /etc/exports entries is:– dir client1(options) [client2(options)...]

• Client options include (defaults are listed first):– ro / rw

– sync / async

– wdelay / no_wdelay

– no_all_squash / all_squash

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 47: D74508GC10_sg2

• root_squash: Prevents root users connected remotely from having root privileges, effectively “squashing” the power of the remote root user. Requests appear to come from the user nfsnobody, an unprivileged user on the local system, or as specified by anonuid. To disable root squashing, specify the no_root_squash option.

• no_all_squash: Does not change the mapping of remote users. To squash every remote user (including root), use the all_squash option.

To specify the user ID (UID) and group ID (GID) that the NFS server should assign to remote users, use the anonuid and anongid options as follows:

export-point client(anonuid=uid,anongid=gid)

The anonuid and anongid options allow you to create a special user/group account for remote NFS users to share. By default, access control lists (ACLs) are supported by NFS. To disable this feature, specify the no_acl option when exporting the file system.

You can use wildcard characters, such as (*) and (?) in client names. You can also export directories to all hosts on an IP network. To do this, specify an IP address and netmask pair as address/netmask. Either of the following forms is valid:• 192.168.1.0/24

• 192.168.1.0/255.255.255.0

Other client options exist. Refer to man exports for descriptions of all options.

/etc/exports ExamplesIn the following example, a client system with the IP address of 192.0.2.102 can mount the /export/directory with read/write permissions. All writes to the disk are asynchronous:

/export/directory 192.0.2.102(rw,async)

The following example exports the /exports/apps directory to all clients, converts all connecting users to the local anonymous user nfsnobody, and makes the directory read-only:

/exports/apps *(all_squash, ro)

The following example exports the /spreadsheets/proj1 directory with read-only permissions to all clients on the 192.168.1.0 subnet, and read-write permissions to the client system named mgmtpc:

/spreadsheets/proj1 192.168.1.0/24(ro) mgmtpc(rw)

Oracle Linux System Administration 16 - 7

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 48: D74508GC10_sg2

Start the NFS ServiceThe rpcbind service must be started before starting nfs:

# service rpcbind start

If the rpcbind service is running, then the nfs service can be started. Restart nfs after making any configuration changes in /etc/exports or run the exportfs –a command.

# service nfs start

Start the nfslock service:

# service nfslock start

Use the chkconfig command to automatically start the services at boot time, for example:

# chkconfig rpcbind on; chkconfig nfs on; chkconfig nfslock on;

Specify configuration options and arguments by placing them in /etc/sysconfig/nfs.

Use the showmount –e command to display exported file systems:

# showmount –e

Export list for host03.example.com

/Test *

Oracle Linux System Administration 16 - 8

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Starting the NFS Service

• Start rpcbind before starting the nfs services:– # service rpcbind start

– # service nfs start

– # service nfslock start

• Use the chkconfig command to automatically start the services at boot time.

• Specify configuration options and arguments in /etc/sysconfig/nfs.

• To display exported file systems:– # showmount –e

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 49: D74508GC10_sg2

You can also configure an NFS server from the command line by using exportfs. This command allows the root user to selectively export or unexport directories without changing /etc/exports and without restarting the NFS service. The syntax for the command is:

exportfs [options] [client:dir ...]

The client argument is the name of the client system that dir is exported to. The dirargument is the absolute path name of the directory being exported. The following is a list of some of the options:

• -r: Re-export the entries in /etc/exports and synchronize /var/lib/nfs/etabwith /etc/exports. The NFS server runs exportfs –r when the service starts (this command is in the nfs init script, /etc/init.d/nfs). The /var/lib/nfs/etab file is the master export table. rpc.mountd reads this file when a client sends an NFS mount command.

• -a: Export the entries in /etc/exports but do not synchronize /var/lib/nfs/etab. Run exportfs –a after making any configuration changes.

• -i: Ignore the entries in /etc/exports and use only command-line arguments.

• -u: Unexport one or more directories.

• -o: Specify client options as specified in /etc/exports.

Oracle Linux System Administration 16 - 9

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

The exportfs Utility

• exportfs exports or unexports directories, and is run from the command line.– No need to change /etc/exports

– No need to restart NFS service

• Syntax for the command:– exportfs [options] [client:dir ...]

• Example:– # exportfs –i –o rw *:/Dev

• This example does the following:– Exports /Dev

– To all clients systems (*)

– Allows read-write permission (-o rw)

– Ignores /etc/exports entries (-i)

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 50: D74508GC10_sg2

Use the mount command to mount exported file systems (NFS shares) on the client side. Syntax for the command is:

mount -t nfs -o options host:/remote/export /local/directory

The following are descriptions of the arguments:

• -t nfs: Indicates that the file system type is nfs. With this option, mount uses NFSv4 if the server supports it; otherwise, it uses the highest version supported by the server.

• -o options: A comma-delimited list of mount options

• host:/remote/export: The host name exporting the file system, followed by a colon, followed by the absolute path name of the NFS share

• /local/directory: The mount point on the client system

For example, to mount the /home directory exported from host abc with read-only permissions (ro option) on local mount point /abc_home, and prevent remote users from gaining higher privileges by running a setuid program (nosuid option):

# mount -t nfs -o ro,nosuid abc:/home /abc_home

For a list of options used for NFS mounts, see the MOUNT OPTIONS section of man nfs.

Oracle Linux System Administration 16 - 10

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

NFS Client Configuration

• Use the mount command to mount exported file systems.

• Syntax for the command:– mount -t nfs -o options host:/remote/export

/local/directory

• Example:– # mount -t nfs -o ro,nosuid abc:/home

/abc_home

• This example does the following:– Mounts /home from remote host abc

– On local mount point /abc_home

– Read-only, and prevents users from running a setuidprogram (-o ro,nosuid options)

• Update /etc/fstab to mount NFS shares at boot time.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 51: D74508GC10_sg2

/etc/fstab

To mount NFS shares at boot time, add entries to the file system mount table, /etc/fstab. Entries are in the following format:

server:/exported-filesystem local_mount_point nfs options 0 0

For example, the /etc/fstab entry that replicates the mount command on the previous page is:

abc:/home /abc_home nfs ro,nosuid 0 0

The df command displays mounted file systems, including NFS-mounted file systems. For NFS mounts, the “File system” column displays the server:/exported-filesystem information. Use the -T option to include a “Type” column:

# df –hT

Oracle Linux System Administration 16 - 11

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 52: D74508GC10_sg2

An alternative to creating NFS mount entries in /etc/fstab or using the mount command from the command line to mount NFS shares is automounting. Auto-mounting mounts remote file systems when they are accessed, rather than maintaining these remote mounts at all times. When the remote file systems are inactive, they are unmounted. This frees up system resources and improves overall system performance.

Auto-mounting consists of two components:

• autofs: Kernel module

• automount: User-space daemon

To implement auto-mounting, first install the autofs package:

# yum install autofs

The main configuration file, known as the master map-file, is /etc/auto.master. This file lists mount points, known as keys, and corresponding map-files that indicate which remote file systems can be mounted on the key. The format for entries in /etc/auto.master is:

/key map-file [options]

Auto-mounting supports direct maps, indirect maps, and host maps. Direct maps use a special key, /-, in /etc/auto.master. Indirect maps specify a relative path name in their map-file. Host maps use a special map, -hosts, in the /etc/auto.master file.

Oracle Linux System Administration 16 - 12

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Auto-Mounting File Systems

• Remote file systems are mounted only when accessed.• Install the autofs package.

– autofs: Kernel module

– automount: Userspace daemon

• The main configuration file is /etc/auto.master.

• Format of /etc/auto.master entries:– /key map-file [options]

• Format of map-file entries:– key [options] location

• Direct maps, indirect maps, host maps

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 53: D74508GC10_sg2

Options included in the master map-file apply to all entries in the associated map-file, unless the map-file specifies mount options. The following is a sample listing of the /etc/auto.masterfile:

# cat /etc/auto.master

/- auto.direct

/misc /etc/auto.misc

/net -hosts

+auto.master

The first entry represents a direct map, which begins with /-. The second entry represents an indirect map, the relative path name is included in the associated map-file. The third entry represents a host map, and uses the special map –hosts. The last entry is an example of how to include a map from its source as if it were present in the master map. Maps to be included are preceded with a plus sign (+).

Map-FilesMap-files have the following format:

key [options] location

The key can be a single directory name for an indirect map or the absolute path name of the mount point for direct mounts. Mount options can be included in map-files. Any options specified in map-files override options specified in the master map-file. The location is the exported NFS file system, or a local file system, or any other supported file system type.

Direct MapsThe first line in the sample /etc/auto.master listing is a direct map. With direct maps, the key is always /- and the map-file, auto.direct in this example, contains the absolute path name of the directory to be mounted. The following is a sample of the auto.direct map-file:

/usr/man -ro,soft host01:/usr/man

This entry mounts the file system /usr/man from the server host01. automount creates the /usr/man directory if it does not already exist. If /usr/man does exist and is not empty, the mounted file system hides the local existing file system.

Indirect MapsIndirect maps are more common than direct maps. The following is an example of an indirect map named /etc/auto.misc:

# cat /etc/auto.misc

xyz -fstype=nfs host01:/xyz

cd -fstype=iso9600,ro,nosuid,nodev :/dev/cdrom

abc -fstype=ext3 :/dev/hda1

kernel -ro,soft,intr ftp.kernel.org:/pub/linux

windoz -fstype=smbfs ://windoz/c

The key field is relative to the actual location of the autofs mount point, /misc, from the master map-file, /etc/auto.master. For example, entering the command cd /misc/xyzmounts the /xyz directory from machine host01 locally on /misc/xyz. Only the /miscmount point needs to exist on the local machine. For indirect maps, the key is created when the file system is accessed, then removed when the file system is unmounted.

Oracle Linux System Administration 16 - 13

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 54: D74508GC10_sg2

The second and third entries are examples of automounting local file systems:

cd -fstype=iso9600,ro,nosuid,nodev :/dev/cdrom

abc -fstype=ext3 :/dev/hda1

The location field is the local file system path preceded with a colon (:). Entering the command ls /misc/cd would display the contents of the iso file on the cdrom. Entering the command ls /misc/abc would display the contents of the ext3 file system on the hda1 device.

The fourth line is a NFS mount (excluding the –fstype option defaults to NFS), which mounts the /pub/kernel directory from ftp.kernel.org on local mount point /misc/kernel:

kernel -ro,soft,intr ftp.kernel.org:/pub/linux

The last line mounts a share exported from a Windows machine on /misc/windoz:

windoz -fstype=smbfs ://windoz/c

Host MapThe third line in the sample /etc/auto.master file gives the following entry:

/net -hosts

When –hosts is given as the map, the automount daemon creates a subdirectory under the /key directory for every server listed in the /etc/hosts file. For example, entering the following command mounts all exports from host03 over the /net/host03 directory:

# cd /net/host03

All exports are mounted with the “no-suid,nodev,intr” options by default.

Start the autofs ServiceThe main configuration file for autofs is /etc/sysconfig/autofs.

To start the autofs service:

# service autofs start

Changes made to map-files become effective immediately. If the master map-file, /etc/auto.master is modified, then the autofs service must be restarted.

Oracle Linux System Administration 16 - 14

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 55: D74508GC10_sg2

Samba is an open-source implementation of the Server Message Block (SMB) protocol. It allows Linux to work with the Windows operating system, as both a server and a client. Samba shares Linux files and printers with Windows systems, and also gives Linux users access to files on Windows systems. Samba uses NetBIOS over TCP/IP (NetBT) protocols and does not need the NetBEUI (Microsoft Raw NetBIOS frame) protocol.

There are several “samba” packages included with the Oracle Linux distribution:

• samba: Provides an SMB/CIFS (Common Internet File System) server that can be used to provide network services to SMB/CIFS clients

• samba-client: Provides some SMB/CIFS clients to complement the built-in SMB/CIFS file system in Linux. These clients allow access of SMB/CIFS shares and printing to SMB/CIFS printers.

• samba-common: Provides files necessary for both the server and client Samba packages

• samba-winbind: Provides the winbind daemon and client tools. winbind enables Linux membership in Windows domains and use of Windows user and group accounts.

• samba-winbind-clients: Provides the NSS (Network Security Services) library and PAM (Pluggable Authentication Modules) needed to communicate with winbind

Oracle Linux System Administration 16 - 15

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Introduction to Samba

• Samba:– Is an open-source implementation of the Server Message

Block (SMB) protocol– Allows Linux and Windows systems to share files and

printers

• Samba packages included with Oracle Linux:– samba: SMB/CIFS server package.– samba-client: Allows clients to access SMB/CIFS shares

and printers– samba-common: Provides files necessary for both the server

and client Samba packages– samba-winbind: Provides the winbind daemon and client

tools– samba-winbind-clients: Provides the NSS library and

PAM modules needed to communicate with winbind

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 56: D74508GC10_sg2

Use the yum install <package_name> to install the packages. The samba server package includes the following daemons and associated services:

• smbd: The server daemon that provides file-sharing and printing services to Windows clients. It is also responsible for user authentication, resource locking, and data sharing through the SMB protocol.

• nmbd: The NetBIOS nameserver daemon replies to name service requests produced by SMB/CIFS in Windows-based systems. It also provides browsing support in the Windows Network Neighborhood view.

These daemons are controlled by their associated services, smb and nmb, for example:

# service smb start

# service nmb start

The samba-winbind package includes the winbindd daemon and associated service:

• winbindd: Resolves user and group information on a server running Windows and makes this information understandable by Linux

This daemon is controlled by the winbind service:

# service winbind start

Oracle Linux System Administration 16 - 16

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Samba Daemons and Services

• The samba server package includes two daemons:– smbd: Provides file and print services for Samba clients

– nmbd: NetBIOS nameserver

• The samba-winbind package includes one daemon:– winbindd: Resolves user/group information on Windows

• Each daemon has an associated service:– smb

– nmb

– winbind

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 57: D74508GC10_sg2

The main configuration file for Samba is /etc/samba/smb.conf. This configuration file is divided into sections, each beginning with text surrounded by square brackets. With the exception of the [global] section, each section describes a shared resource, known as a “share”. Typical sections are:

• [global]: Defines global parameters

• [homes]: Defines shares in the homes directory

• [printers]: Defines printers

• [share name]: Defines a share

Parameters within the section define the share attributes. Assuming that the global parameters are configured properly, the following example defines a share that gives any Windows user read-write permissions to the local /tmp directory:

[tmp]

comment = Insert a comment here

path = /tmp

writable = yes

guest ok = yes

Oracle Linux System Administration 16 - 17

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Samba Server Configuration

• The main configuration file for Samba is: /etc/samba/smb.conf

• The configuration file contains the following sections:– [global]: Defines global parameters

– [homes]: Defines shares in the homes directory

– [printers]: Defines printers

– [share name]: Defines a share

• Example share definition:[tmp]

path = /tmp

writable = yes

guest ok = yes

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 58: D74508GC10_sg2

Refer to man smb.conf for a description of all the parameters that you can set in the configuration file. There are global parameters, security parameters, logging parameters, browser parameters, communication parameters, and share parameters. There are also several graphical user interfaces to configure and manage Samba. A list of these can be found at http://www.samba.org/samba/GUI/.

The [homes] ShareSamba provides this share to make it easy for users to share their Linux home directories with a Windows system. The following is an example:

[homes]

comment = Insert a comment here

browsable = no

writable = yes

These settings prevent users other than the owners from browsing home directories, while allowing logged-in owners full access.

Start a Samba ServerTo start a Samba server:

# service smb start

When making configuration changes to the /etc/samba/smb.conf file, issue a restart or reload:

# service smb restart

# service smb reload

The reload argument does not stop and start the smb service, it only reloads the configuration file.

Use the chkconfig command to automatically start the service at boot time, for example:

# chkconfig smb on

Oracle Linux System Administration 16 - 18

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 59: D74508GC10_sg2

There are three different ways a Samba server can be configured:

• Stand-alone server

• Domain member server

• Domain controller

To understand the differences between the different server types, a brief introduction to Windows environments is necessary.

Windows Workgroups and DomainsComputers running Windows on a network belong to a workgroup or to a domain. Workgroup networks consist of a small number of computers when compared to a domain. Domains are best suited for corporate networks with many systems networked together.

A workgroup environment is a peer-to-peer network. Computers do not rely on each other for services. There is no centralized management. Each computer is sustainable on its own. Each computer has its own set of user accounts, its own access control, and its own resources. The systems can share resources, however, if configured to do so.

A domain is a trusted group of computers that share security and access control. Domains provide centralized management and security from a separate computer called a domain controller. Most modern Windows domains use Active Directory.

Oracle Linux System Administration 16 - 19

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Samba Server Types

• Three different ways to configure a Samba server:– Stand-alone server: Can be a workgroup server or a member

of a workgroup

– Domain member server: Logs in to a domain controller and is subject to the domain's security rules

– Domain controller: Can only be a domain controller in a Windows NT domain, not an Active Directory domain

• Server type is configured in the [global] section of the /etc/samba/smb.conf file.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 60: D74508GC10_sg2

Stand-Alone ServerA stand-alone Samba server can be a workgroup server or a member of a workgroup environment and does not participate in a Windows domain in any way. The following is an example of configuring the [global] directives in /etc/samba/smb.conf for a stand-alone server:

[global]

workgroup = workgroup_name

netbios name = netbios_name

security = share

The security parameter set to share indicates share-level security as opposed to user-level security. With share-level security, the server accepts only a password without an explicit username from the client. The server expects a password for each share, independent of the username. The use of share-level security is discouraged in favor of user-level security. There are four different ways to implement user-level security, each of which are discussed in the “Authentication and Directory Services” lesson.

Domain Member ServerA domain member server is similar to a stand-alone server, but the server is logged into a domain controller (either Windows or Samba) and is subject to the domain’s security rules. An example of a domain member server would be a departmental server running Samba that has a machine account on the Primary Domain Controller (PDC). All of the department’s clients still authenticate with the PDC, but the departmental server controls printer and network shares. To set up a domain member server, you must first join the domain or Active Directory using the net join command before starting the smb service.

The following is an example of configuring /etc/samba/smb.conf to implement an Active Directory domain member server. Samba authenticates users for services being run locally, but is also a client of the Active Directory.

[global]

realm = EXAMPLE.COM

security = ADS

password server = kerberos.example.com

The realm directive identifies the Kerberos realm and must be capitalized. Kerberos is an authentication protocol that allows nodes communicating over a non-secure network to prove their identity to one another. Windows requires Kerberos for Active Directory authentication. The password server directive is only required if Active Directory and Kerberos are running on different servers.

The following is an example of configuring /etc/samba/smb.conf to implement a Windows NT4-based domain member server. NT4-based domains do not use Kerberos in their authentication method.

[global]

workgroup = workgroup_name

netbios name = netbios_name

security = domain

Oracle Linux System Administration 16 - 20

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 61: D74508GC10_sg2

Domain ControllerA Samba server can be a member of an Active Directory but it cannot operate as an Active Directory domain controller. For Windows NT, a domain controller is similar to a Network Information Service (NIS) server in a Linux environment. They both host user and group information databases and other services. Domain controllers are mainly used for security, including the authentication of users accessing domain resources. Authentication services are discussed in another lesson.

Oracle Linux System Administration 16 - 21

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 62: D74508GC10_sg2

To access a share on a Linux Samba server from Windows, open My Computer or Explorer and enter the host name of the Samba server and the share name in the following format:

\\servername\sharename

You can enter \\servername and Windows displays the directories that the Linux system is sharing. You can also map a network drive to a share name by using the same syntax.

smbusers FileFor a Windows user to access a Samba share on a Linux system, the user must provide a Windows username and a Samba password. The Windows username must be the same as the Linux username or must map to a Linux username. Samba stores these username maps in the /etc/samba/smbusers file. Users with the same username on Linux and Windows do not need an entry in this file, but they still need a Samba password.

The /etc/samba/smbusers file has two default entries:

root = administrator admin

nobody = guest pcguest smbguest

The first entry maps the Linux root user to the administrator and admin users in Windows. The second entry maps the Linux user nobody to three Windows usernames.

Oracle Linux System Administration 16 - 22

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Access Linux Shares from Windows

• Browse using \\servername\sharename syntax.– servername is the Linux Samba server.

• Provide a Windows username and a Samba password.

• The Windows username must map to the Linux username.– /etc/samba/smbuser maps Linux>Windows usernames.

– oracle = wuser

• Use the smbpasswd command to add a Samba password:– # smbpasswd –a oracle

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 63: D74508GC10_sg2

To map the Windows username of wuser to the Linux username of oracle, add the following entry to /etc/samba/smbusers:

oracle = wuser

Samba uses Samba passwords, not Linux passwords, to authenticate users. Add a password for the oracle user with the following command:

# smbpasswd –a oracle

New SMB password:

Retype new SMB password:

Added user oracle.

Oracle Linux System Administration 16 - 23

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 64: D74508GC10_sg2

Use the findsmb command to query a subnet for Samba servers. The command displays the IP address, NetBIOS name, workgroup, operating system and version for each server found.

You can also use the smbtree command, which is a text-based SMB network browser. It displays a hierarchy diagram with all the known domains, the servers in those domains, and the shares on the servers.

The GNOME and KDE desktops provide browser-based file managers to view Windows shares on the network. Enter smb: in the location bar of the file managers to browse shares.

Use the smbclient utility to connect to a Windows share from the command line. The format is as follows:

smbclient //<servername>/<sharename> [-U <username>]

The smb:\> prompt is displayed after successfully logging in. Type help to display a list of commands. Type exit to exit smbclient.

To mount Samba shares, install the cifs-utils package:

# yum install cifs-utils

Use the mount command with the following format to mount Samba shares:

mount -t cifs //<servername>/<sharename> /mount-point -o username=<username>,password=<password>

Oracle Linux System Administration 16 - 24

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Access Windows Shares from Linux

• Utilities to query Samba servers:– findsmb

– smbtree

• From GNOME and KDE desktops file managers:– Enter smb: in the location bar

• Use the smbclient utility to connect to a Windows share from the command line:– smbclient //<servername>/<sharename> [-U

<username>]

• Use the mount –t cifs command to mount a Samba share.

• The mount command requires the cifs-utils package.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 65: D74508GC10_sg2

The following list summarizes the command-line utilities included with the “samba” packages. Use the which utility command to display the absolute pathname of the command. Include the output as an argument to the rpm –qf command to display which “samba” package provides the command.

Example:

# which findsmb

/usr/bin/findsmb

# rpm –qf /usr/bin/findsmb

samba-client-<version>

• findsmb: Lists information about systems that respond to SMB name queries on a subnet

• smbtree: A text-based SMB network browser

• smbclient: An FTP-like client to access SMB/CIFS resources on servers

• smbpasswd: Used to add or modify a user’s SMB password

Oracle Linux System Administration 16 - 25

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Samba Utilities

Samba packages include several command-line utilities like:• net: Works like the net utility for Windows and MS-DOS

• nmblookup: Resolves NetBIOS names to IP addresses

• smbstatus: Displays the status of Samba server connections

• smbtar: Backs up and restores Windows-based share files and directories to a local Linux tape archive

• testparm: Checks the syntax of the /etc/samba/smb.conf file

• wbinfo: Displays information from the winbindd daemon

• smbget: A wget-like utility for downloading files over SMB

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 66: D74508GC10_sg2

• net: A tool for the administration of Samba and remote CIFS servers. It is designed to work like the net utility used for Windows and MS-DOS. The syntax is:

net <protocol> [options]

The <protocol> argument specifies the protocol to use when executing a command. Specify the type of server connection by using ads (Active Directory), rap(Win9x/NT3), or rpc (Windows NT4/2000/2003/2008). If the protocol is omitted, netautomatically tries to determine it. Use net –h for online help and usage examples.

• nmblookup: Used to query NetBIOS names and map them to IP addresses

• pdbedit: Manages accounts located in the SAM database (the database of Samba users)

• rpcclient: Tool for executing client side Microsoft RPCs functions

• smbcacls: Modifies Windows ACLs on files and directories shared by a Samba server or a Windows server

• smbcontrol: Sends control messages to running smbd, nmbd, or winbindd daemons

• smbspool: Sends a print file to an SMB printer

• smbstatus: Displays the status of current connections to a Samba server

• smbtar: Backs up and restores Windows-based share files and directories to a local Linux tape archive

• testparm: Checks the syntax of the /etc/samba/smb.conf file

• wbinfo: Displays information from the winbindd daemon (The winbindd daemon must be running.)

• smbcquotas: Manipulates quotas on NTFS (NT file system) quotas on SMB file shares

• smbget: A wget-like utility for downloading files over SMB

Oracle Linux System Administration 16 - 26

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 67: D74508GC10_sg2

File Transfer Protocol (FTP) is a commonly used method of downloading and uploading files between systems on a network. FTP sites are typically public sites that allow anonymous users to log in and download software and documentation without needing a user account on the remote system.

The FTP server daemon included with Oracle Linux is called very secure FTP, or vsftpd. To install the vsftpd package:

# yum install vsftpd

The following configuration files are installed with the package:• /etc/vsftpd/vsftpd.conf: The main configuration file for vsftpd

• /etc/vsftpd/ftpusers: A list of users not allowed to log in to vsftpd

• /etc/vsftpd/user_list: This file contains users who are denied access when the userlist_deny directive is set to YES (default) in /etc/vsftpd/vsftpd.conf or users who are allowed access when userlist_deny is set to NO.

• /var/ftp: The directory containing files served by vsftpd. It also contains the /var/ftp/pub directory for anonymous users.

To start the vsftpd service:

# service vsftpd start

Oracle Linux System Administration 16 - 27

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Introduction to vsftpd

• vsftpd allows system to function as an FTP server.

• vsftpd includes the following configuration files and directories:– /etc/vsftpd/vsftpd.conf

– /etc/vsftpd/ftpusers

– /etc/vsftpd/user_list

– /var/ftp

• To start the service:– service vsftpd start

• To start automatically at boot time:– chkconfig vsftpd on

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 68: D74508GC10_sg2

The vsftpd service allows local and anonymous users to log in without any additional configuration. When a user logs in, they can download files from the /var/ftp directory on the vsftpd server and upload files by default.

These and other options are configured in /etc/vsftpd/vsftpd.conf. The following lists some of the more common configuration parameters:• listen: This setting decides whether vsftpd should run stand-alone (default) and

listen to the FTP port itself or allow itself to be run by a superserver, such as xinetd.

• userlist_enable: This setting tells vsftpd to read /etc/vsftpd/user_list and use that as a list of users to allow or not allow on the server.

• userlist_deny: When set to yes, vsftpd blocks all users in the user_list. When set to no, it allows only users in the user_list.

• local_enable: This setting allows users in /etc/passwd to log in with their accounts.

• anonymous_enable: This setting allows anonymous connections to the server.

• no_anon_password: This setting allows anonymous connections without a password (otherwise, users must provide an email address as a password).

• write_enable: When set to yes, this setting allows users to upload files to the server and create directories.

Oracle Linux System Administration 16 - 28

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

vsftpd Configuration Options

• Local and anonymous users can download files by default.– local_enable=YES

– anonymous_enable=YES

• Users can upload files by default, too.– write_enable=YES

• Additional configuration parameters in /etc/vsftpd/vsftpd.conf include:– listen

– userlist_enable

– userlist_deny

– no_anon_password

– xferlog_enable

– xferlog_file

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 69: D74508GC10_sg2

• anon_mkdir_write_enable: When set to yes, this setting allows anonymous users to create directories.

• anon_other_write enable: When set to yes, this setting allows anonymous users to make other changes to the file system, such as deleting, renaming and modifying existing files.

• anon_upload_enable: This setting allows anonymous users to upload files to the server.

• ascii_download_enable: This setting allows conversion of text files transferred from the server to other operating systems. This can be a good idea if you are transferring text files from UNIX systems to Mac OS or Windows.

• ascii_upload_enable: This setting allows conversion of text files uploaded to the server.

• xferlog_enable: This setting activates logging of uploads and downloads.

• xferlog_file: This setting names the upload/download log file. The default is /var/log/vsftpd.log.

Oracle Linux System Administration 16 - 29

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 70: D74508GC10_sg2

Oracle Linux System Administration 16 - 30

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Quiz

Which of the following statements are true?

a. NFS allows Linux clients to mount exported file systems from remote Linux systems.

b. Samba allows Linux clients to mount exported file systems on remote Windows systems.

c. Samba allows Windows clients to mount exported file systems on remote Linux systems.

d. Automounter allows NFS and Samba shares to be automatically mounted.

e. The vsftpd daemon enables a system to be configured as an FTP server.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 71: D74508GC10_sg2

Oracle Linux System Administration 16 - 31

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Summary

In this lesson, you should have learned how to:

• Describe NFS

• Configure NFS server and client• Describe the exportfs utility

• Describe and configure automounter

• Describe and configure Samba

• Access Samba shares• Describe and configure vsftpd

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 72: D74508GC10_sg2

Oracle Linux System Administration 16 - 32

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Practice 16: Overview

The practices for this lesson cover the following:

• Configuring an NFS server

• Configuring an NFS client

• Using automounter

• Configuring an FTP server

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 73: D74508GC10_sg2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

OpenSSH

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 74: D74508GC10_sg2

Oracle Linux System Administration 17 - 2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Objectives

After completing this lesson, you should be able to:

• Describe OpenSSH

• Describe OpenSSH configuration files

• Configure OpenSSH server and client• Use the ssh command

• Use the scp command

• Use the sftp command

• Use the ssh-keygen command

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 75: D74508GC10_sg2

OpenSSH (Secure Shell) is suite of network connectivity tools that provides secure communications between systems. OpenSSH tools include the following:

• ssh: Secure shell logs on or runs a command on a remote system

• scp: Secure copy

• sftp: Secure ftp (file transfer protocol)

• sshd: The OpenSSH daemon

• ssh-keygen: Creates DSA or RSA host/user authentication keys:

- DSA (Digital Signature Algorithm)

- RSA is named for the designers Rivest, Shamir, and Adleman.

Unlike other tools such as telnet, rcp, rsh, rlogin, and ftp, OpenSSH tools encrypt all communication between the client and server systems, including passwords. Each network packet is encrypted using a key known only by the local and remote systems.

OpenSSH supports both versions of SSH, SSH protocol version 1 (SSH1) and SSH protocol version 2 (SSH2). Additionally, OpenSSH provides a secure means to use graphical applications over a network using X11 forwarding. It also provides a way to secure otherwise insecure TCP/IP protocols using port forwarding.

Oracle Linux System Administration 17 - 3

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Introduction to OpenSSH

OpenSSH:

• Is a suite of secure network connectivity tools:– ssh: Secure shell command

– scp: Secure copy command

– sftp: Secure FTP (file transfer protocol) command

– sshd: The OpenSSH daemon

– ssh-keygen: Creates DSA or RSA authentication keys

• Is a secure alternative to telnet, rcp, rsh, rlogin, ftp

• Encrypts all communication between the client and server

• Supports both the SSH1 and the SSH2 protocol

• Provides X11 forwarding and port forwarding

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 76: D74508GC10_sg2

OpenSSH clients and servers have several configuration files. Global configuration files are stored in the /etc/ssh directory. User configuration files are stored in a .ssh directory in user home directories (~/.ssh).

/etc/ssh: Global FilesThe following are brief descriptions of the global configuration files:• moduli: Contains key exchange information used to establish a secure connection

• ssh_config: The default OpenSSH client configuration file. Entries are overridden by a user’s ~/.ssh/config file.

• sshd_config: The configuration file for the sshd daemon

• ssh_host_dsa_key: The DSA private key for version SSH2

• ssh_host_dsa_key.pub: The DSA public key for version SSH2

• ssh_host_key: The RSA private key for version SSH1

• ssh_host_key.pub: The RSA public key for version SSH1

• ssh_host_rsa_key: The RSA private key for version SSH2

• ssh_host_rsa_key.pub: The RSA public key for version SSH2

Oracle Linux System Administration 17 - 4

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

OpenSSH Configuration Files

• Global files are stored in the /etc/ssh directory.

• User files are stored in ~/.ssh directory.

• Global files include:– ssh_config: The default OpenSSH client configuration file

– sshd_config: The configuration file for the sshd daemon

– Various DSA and RSA public and private key files

• User files include:– config: Overrides global ssh_config file

– known_hosts: Contains host keys of SSH servers accessed by the user

– Various user DSA and RSA public and private key files

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 77: D74508GC10_sg2

~/.ssh: User FilesOpenSSH creates the ~/.ssh directory and the known_hosts file automatically when you connect to a remote system. The following are brief descriptions of the user-specific configuration files:

• authorized_keys: Contains a list of authorized public keys for SSH servers. The server authenticates the client by checking its signed public key within this file.

• id_dsa: The DSA private key of the user

• id_dsa.pub: The DSA public key of the user

• id_rsa: The RSA private key for version SSH2

• id_rsa.pub: The RSA public key for version SSH2

• identity: The RSA private key for version SSH1

• identity.pub: The RSA public key for version SSH1

• known_hosts: Contains host keys of SSH servers accessed by the user. OpenSSH automatically adds entries each time the user connects to a new server.

Oracle Linux System Administration 17 - 5

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 78: D74508GC10_sg2

OpenSSH ServerTo begin configuring a system as an OpenSSH server, install the following packages (these are installed by default):

# yum install openssh

# yum install openssh-server

Start the sshd daemon:

# service sshd start

Use the chkconfig command to automatically start the sshd service at boot time:

# chkconfig sshd on

OpenSSH ClientTo configure a system as an OpenSSH client, install the following packages (these are installed by default):

# yum install openssh

# yum install openssh-client

There are no services to start for OpenSSH clients.

Oracle Linux System Administration 17 - 6

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

OpenSSH Configuration

• To configure an OpenSSH server:– The following packages are installed by default:

— openssh

— openssh-server

– Start the sshd daemon:— service sshd start

• To configure an OpenSSH client:– The following packages are installed by default:

— openssh

— openssh-client

– There are no services to start on the client.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 79: D74508GC10_sg2

All of the OpenSSH tools require you have a user account on the remote system. Each time you attempt to connect to a remote system, you must provide a username and password for the remote system.

When you connect to an OpenSSH server for the first time, the OpenSSH client prompts you to confirm that you are connected to the correct system. The following example uses the sshcommand to connect to a remote host named host03:

$ ssh host03

The authenticity of host ‘host03 (192.0.2.103)’ can’t be established. RSA key fingerprint is ...

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘host03,192.0,2,103’ (RSA) to the list of known hosts.

Host validation is one of OpenSSH’s major features. The command checks to make sure that you are connecting to the host that you think you are connecting to. When you type yes, the client appends the server’s public host key to the user’s ~/.ssh/known_hosts file, creating the ~/.ssh directory if necessary. The next time you connect to the remote server, the client compares this key to the one the server supplies. If the keys match, you are not asked if you want to continue connecting.

Oracle Linux System Administration 17 - 7

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Using OpenSSH Utilities

• All OpenSSH utilities require a remote user account.

• The first time you connect to an OpenSSH server, the OpenSSH client prompts you to confirm that you are connected to the correct system:$ ssh host03

The authenticity of host ‘host03 (192.0.2.103)’ can’t be established. RSA key fingerprint is ...

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘host03,192.0,2,103’ (RSA) to the list of known hosts.

• The user’s ~/.ssh/known_hosts file is updated.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 80: D74508GC10_sg2

If someone tries to trick you into logging in to their machine so that they can sniff your SSH session, you will receive a warning similar to the following:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

The RSA host key for ... has changed,

and the key for the according IP address ...

is unchanged. This could either mean that

DNS SPOOFING is happening or the IP address for the host

and its host key have changed at the same time.

Offending key for IP in /home/<user>/.ssh/known_hosts:10

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!

Someone could be eavesdropping on you right now (man-in-the-middle attack)!

It is also possible that the RSA host key has just been changed.

The fingerprint for the RSA key sent by the remote host is ...

Please contact your system administrator.

Add correct host key in /home/<user>/.ssh/known_hosts to get rid of this message.

Offending key in /home/<user>/.ssh/known_hosts:53

RSA host key for ... has changed and you have requested strict

checking.

Host key verification failed.

If you ever get a warning like this, stop and determine whether there is a reason for the remote server’s host key to change (such as if SSH was upgraded or the server itself was upgraded). If there is no good reason for the host key to change, then you should not try to connect to that machine until you have contacted its administrator about the situation.

Oracle Linux System Administration 17 - 8

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 81: D74508GC10_sg2

The ssh command allows you to connect to a remote system, or to execute a command on a remote system.

The format of the ssh command is:

ssh [options] [user@]host [command]

The host argument is the name of the OpenSSH server that you want to connect to, and is the only required argument. For example, to connect to a remote host named host03, you only need to enter the following:

$ ssh host03

This command attempts to connect to the remote host with the same username that you are logged on as on the local system. You are only prompted for the remote user’s password. To connect to a remote host as a different user, provide the user@ argument:

$ ssh root@host03

To execute a command on a remote system, include the command as an argument. ssh logs you in, executes the command, then closes the connection. For example:

$ ssh host03 ls

Oracle Linux System Administration 17 - 9

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Using the ssh Command

• The ssh command:– Allows you to connect to a remote system

– Allows you to execute a command on a remote system

• The format of the command is:– ssh [options] [user@]host [command]

• Examples:– ssh host03

– ssh root@host03

– ssh host03 ls

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 82: D74508GC10_sg2

The scp command allows you to copy files or directories (use the -r option to copy directories) between remote systems. A connection is established, files are copied, and the connection closes.

To copy a file to a remote system (upload), the format of the scp command is:

scp [options] local-file [user@]to-host[:remote-file]

For example, to copy a file named test to the remote user’s home directory on host03:

$ scp test host03

To copy the same file to the same location but rename it to new_test:

$ scp test host03:new_test

To copy a file from a remote system (download), the format of the scp command is:

scp [options] [user@]from-host:remote-file local-file

For example, to copy a file named new_test from user’s home directory on remote host03:

$ scp host03:new_test .

To copy a file named new_test from user’s home directory on remote host03 and rename it to newer_test:

$ scp host03:new_test newer_test

Oracle Linux System Administration 17 - 10

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Using the scp Command

• Use scp to copy files or directories to or from a remote system.

• To copy to a remote system, the format is:– scp [options] local-file [user@]to-

host[:remote-file]

• Examples:– scp test host03– scp test host03:new_test

• To copy from a remote system, the format is:– scp [options] [user@]from-host:remote-file

local-file

• Examples:– $ scp host03:new_test .– $ scp host03:new_test newer_test

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 83: D74508GC10_sg2

The sftp command is a secure alternative to ftp and is functionally the same as ftp. Use sftp instead of ftp when logging on to a server that is running the OpenSSH daemon, sshd.

The format to connect to a remote system is:

sftp [options] [user@]host

The following example assumes that you are logged on to your local system as user oracleand are connecting to a remote system named host03:

$ sftp host03

Connecting to host03...

oracle@host03’s password:

sftp>

After providing the correct password, you are presented with an sftp> prompt as shown. Type help or ? to display a list of available commands. The following example uploads a file, or copies the file from the local system to the remote system:

sftp> put newer

Type exit, quit, or bye to close the connection and exit sftp.

Oracle Linux System Administration 17 - 11

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Using the sftp Command

• sftp is a secure alternative to, and is functionally the same as, ftp.

• The format to connect to a remote system is:– sftp [options] [user@]host

• Example:– sftp host03

• You are presented with the sftp> prompt after connecting:– sftp>

• Enter help or ? to display a list of sftp commands.• To upload a file (copy to remote system):

– sftp> put filename

• To download a file (copy from a remote system):– sftp> get filename

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 84: D74508GC10_sg2

Use the ssh-keygen command to generate a public/private authentication key pair. Authentication keys allow a user to connect to a remote system without supplying a password. Keys must be generated for each user separately. If you generate key pairs as the root user, only the root can use the keys.

The following example creates the public and private parts of an RSA key:

$ oracle@host03: ssh-keygen –t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/oracle/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/oracle/.ssh/id_rsa.

Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.

The key fingerprint is:...

The key’s randomart image is:...

Use ssh-keygen –t dsa command to generate DSA keys.

Oracle Linux System Administration 17 - 12

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Using the ssh-keygen Command

• The ssh-keygen command generates authentication key pairs.– ssh-keygen –t rsa (generates RSA keys)

– ssh-keygen –t dsa (generates DSA keys)

• ssh-keygen generates two keys:

– Private key

– Public key

• Specify a passphrase to encrypt the private part of the key.

• To allow remote connectivity without supplying a password:1. Copy the public key to ~/.ssh on the remote system.

2. Do one of the following:— Rename the public key file name to authorized_keys.

— Append the public key to the authorized_keys file on the remote system to allow connection from multiple clients.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 85: D74508GC10_sg2

You have the option of specifying a passphrase to encrypt the private part of the key. If you encrypt your personal key, you must supply the passphrase each time you use the key. This prevents an attacker, who has access to your private key and can impersonate you and access all the computers you have access to, from being able to do so. The attacker still needs to supply the passphrase.

The ssh-key command in the example generated two keys in the ~/.ssh directory:

$ oracle@host03: ls ~/.ssh

id_rsa

id_rsa.pub

To log on to, or copy files to a remote system without supplying a password, copy the public key (~/.ssh/id_rsa.pub in this example) to ~/.ssh/authorized_keys on the remote system. Set the remote ~/.ssh directory permissions to 700. You then can use the ssh or scptools to access the remote system without supplying a password.

To allow multiple connections, append the public key the to authorized_keys file on the remote system instead of copying it. The following example appends the public key:

$ cat id_rsa.pub >> authorized_keys

You can improve the system security even further by disabling the standard password authentication, and enforce the key-based authentication. To do so, set the PasswordAuthentication option to no in the /etc/ssh/sshd_config configuration file as follows:

PasswordAuthentication no

This disallows users whose keys are not in the authorized_keys file of the specific user on the server to connect via ssh. The connection is denied and the following message displays:

$ ssh host01

Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

Setting the PasswordAuthentication option to yes, which is the default, permits a user to use a password for authentication.

Oracle Linux System Administration 17 - 13

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 86: D74508GC10_sg2

Oracle Linux System Administration 17 - 14

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Quiz

OpenSSH connectivity tools encrypt all network traffic, including passwords.

a. True

b. False

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 87: D74508GC10_sg2

Oracle Linux System Administration 17 - 15

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Summary

In this lesson, you should have learned how to:

• Describe OpenSSH

• Describe OpenSSH configuration files

• Configure OpenSSH server and client• Use the ssh command

• Use the scp command

• Use the sftp command

• Use the ssh-keygen command

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 88: D74508GC10_sg2

Oracle Linux System Administration 17 - 16

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Practice 17: Overview

The practices for this lesson cover the following :

• Configuring OpenSSH• Using the ssh, scp, and sftp utilities

• Using the ssh-keygen command to enable “no password required” connectivity

• Installing Unbreakable Enterprise Kernel Release 2

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 89: D74508GC10_sg2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Authentication and Directory Services

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 90: D74508GC10_sg2

Oracle Linux System Administration 18 - 2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Objectives

After completing this lesson, you should be able to:• Describe authentication options

• Describe the Authentication Configuration Tool

• Describe NIS

• Configure NIS server and NIS client

• Configure NIS authentication

• Describe LDAP

• Describe OpenLDAP

• Describe OpenLDAP server and client utilities

• Configure LDAP authentication

• Configure Winbind authentication

• Configure Kerberos authentication

• Describe and configure SSSD services and domains

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 91: D74508GC10_sg2

Authentication is the verification of the identity of a user. A user logs in by providing a username and a password and is authenticated by comparing this information to data stored on the system. If the login credentials match and the user account is active, then the user is authenticated and can successfully access the system.

The information to verify the user can be located on the local system in the /etc/passwdand /etc/shadow files. A local system can also reference data stored on remote systems using services such as Lightweight Directory Access Protocol (LDAP), Network Information Service (NIS), and Winbind. Additionally, both LDAP and NIS data files can use Kerberos authentication.

NIS simplifies the maintenance of common administration files such as /etc/passwd by keeping them in a central database and having clients retrieve information from this database server.

An LDAP directory can hold many types of information, including usernames, network services, and authentication data. Much like NIS, LDAP clients contact a centralized server to access this information.

Oracle Linux includes a tool to select user databases and configure associated authentication options called the Authentication Configuration Tool.

Oracle Linux System Administration 18 - 3

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Authentication Options

• Authentication is the verification of the identity of a user.

• Local account verification authenticates user information from local files:– /etc/passwd

– /etc/shadow

• A local system can also access other directory services:– NIS (Network Information Service)

– LDAP (Lightweight Directory Access Protocol)

– Winbind

• Authentication Configuration Tool:– Provides for the selection of user account databases and

authentication configurations

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 92: D74508GC10_sg2

To use the Authentication Configuration Tool, enter the command:

# system-config-authentication

Identity & AuthenticationClick this tab to select how users should be authenticated. Under the User Account Configuration section of the page, select one of four options for the User Account Database field:

• Local accounts only: Users and passwords are checked against local system accounts.

• LDAP

• NIS

• Winbind

Additional User Account Configuration fields appear, depending on which user account database is selected. The Authentication Configuration section of the page also changes, depending on which user account database is selected.

Advanced OptionsClick this tab to enable fingerprint reader support, enable local access control using the /etc/security/access.conf file, configure smart card authentication options, change the password hashing algorithm, and configure other authentication options.

Oracle Linux System Administration 18 - 4

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Authentication Configuration Tool

system-config-authentication

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 93: D74508GC10_sg2

NIS was among the first directory services, but it has largely been replaced by other technologies, such as LDAP. NIS stores administrative information such as usernames, passwords, and hostnames on a centralized server. Client systems on the network can access this common data. This allows users the freedom to move from machine to machine without having to remember different passwords and copy data from one machine to another. Storing administrative information centrally, and providing a means of accessing it from networked systems, also ensures the consistency of that data.

An NIS network of systems is called an NIS domain. Each system within the domain has the same NIS domain name, which is different from a DNS domain name. The DNS domain is used throughout the Internet to refer to a group of systems. An NIS domain is used to identify systems that use files on an NIS server. An NIS domain must have exactly one master server but can have multiple slave servers. When using the Authentication Configuration Tool and selecting NIS as the user account database, you are prompted to enter the:

• NIS Domain

• NIS Server

For Authentication Method, NIS allows simple NIS password authentication or Kerberos authentication. Kerberos is an authentication protocol that allows nodes communicating over a non-secure network to prove their identity to one another in a secure manner.

Oracle Linux System Administration 18 - 5

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

NIS Authentication

• NIS Domain– A network of systems

that share a common set of configuration files

• NIS Server– A single system that

stores the configuration files

• Authentication Method– NIS password

– Kerberos password

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 94: D74508GC10_sg2

The administrative files within an NIS domain are called NIS maps. NIS maps are generated from standard configuration “source” files such as:

• /etc/hosts: Maps IP addresses to host names

• /etc/passwd: List user information

• /etc/shadow: Provides shadow passwords for users

• /etc/group: Defines groups and group members

• /etc/gshadow: Provides shadow passwords for groups

• /etc/networks: Maps IP network addresses to network names

• /etc/services: Maps service names and port numbers

• /etc/rpc: Maps RPC program names and numbers

• /etc/protocols: Maps protocol numbers to protocol names

Source files are converted to dbm-format files called maps. Each map is indexed on one field. Records from these indexed maps are retrieved by specifying a value from the indexed field. Some source files have two maps. For example, /etc/passwd has two maps:

• passwd.byname: Indexed on username

• passwd.byuid: Indexed on UID

Oracle Linux System Administration 18 - 6

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

NIS Maps

• NIS maps are indexed administrative files within an NIS domain.

• NIS maps are generated from standard administrative “source” files such as:– /etc/hosts

– /etc/passwd

– /etc/shadow

– /etc/group

• You define which maps to build in /var/yp/Makefile.

• Maps are generated by using the ypinit command.

• Some source files generate two maps. For example:– passwd.byname: /etc/passwd indexed on username

– passwd.byuid: /etc/passwd indexed on UID

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 95: D74508GC10_sg2

NIS was originally called Yellow Pages but was renamed by Sun Microsystems. The names of NIS utilities, files, and directories still begin with the letters “yp” for yellow pages.

You specify which NIS maps to build in /var/yp/Makefile. NIS maps are created by running the ypinit –m command on the server and are stored in the /var/yp/domainname directory on the server. The following is a sample listing of NIS maps:

# ls /var/yp/nis.example.com

group.bygid mail.aliases protocols.byname services.byname

group.byname netid.byname protocols.bynumber hosts.byaddr

passwd.byname rpc.byname hosts.byname. passwd.byuid

rpc.bynumber

You can assign nicknames to maps to make it easier to refer to them. The /var/yp/nicknames file contains a list of commonly used nicknames:

# cat /var/yp/nicknames

passwd passwd.byname

group group.byname

networks networks.byaddr

hosts hosts.byname

protocols protocols.bynumber

services services.byname

aliases mail.aliases

ethers ethers.byname

Oracle Linux System Administration 18 - 7

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 96: D74508GC10_sg2

To begin configuring a system as an NIS server, install the ypserv package:

# yum install ypserv

Specify the NIS domain name by creating an entry in the /etc/sysconfig/network file:

NISDOMAIN=nisdomainname

The main configuration file for the NIS server, /etc/ypserv.conf, specifies server options and access rules. Some options are set by default. Options have the following format:

option: value

Access rules specify which hosts and domains can access which NIS maps. Access rules have the following format:

host:domain:map:security

The host and domain fields specify the IP address and NIS domain the rule applies to. The map field is the name of the map the rule applies to. The security field is either none(always allow access), port (allow access if from port < 1024), or deny (never allow access). The following example grants access to anyone logging in from an IP address in the range of 192.0.2.1 to 192.0.2.255:

192.0.2.1/24: * : * : none

Oracle Linux System Administration 18 - 8

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

NIS Server Configuration

• Install the ypserv package.

• Specify the NIS domain name in /etc/sysconfig/network:– NISDOMAIN=nisdomainname

• The main configuration file for the NIS server is:– /etc/ypserv.conf

• Specify which hosts are allowed access to the NIS server in:– /var/yp/securenets

• Specify which NIS maps to create in:– /var/yp/Makefile

• Start the services: ypserv, ypxfrd, yppasswdd

• Run ypinit -m to create the maps.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 97: D74508GC10_sg2

Create the /var/yp/securenets file to restrict access to your NIS server to certain hosts. This file prevents unauthorized systems from sending RPC requests to the NIS server and retrieving NIS maps. NIS accepts requests from systems whose IP addresses are included in this file and ignores requests from other systems. Each line contains a netmask and IP address. The following examples accept requests from the local system and from systems with IP addresses starting with 192.0.2:

255.255.255.255 127.0.0.1

255.255.255.0 192.0.2.0

Edit /var/yp/Makefile to set options and specify which NIS maps to create. The all:target in /var/yp/Makefile specifies the maps to create:

all: passwd group hosts rpc services netid protocols mail \

# netgrp shadow publickey networks ethers bootparams printcap \

# amd.home auto.master auto.home auto.local. passwd.adjunct \

# timezone locale netmasks

Run chkconfig to cause the following services to start when the system enters multiuser mode:

# chkconfig ypserv on

# chkconfig ypxfrd on

The rpc.ypxfrd daemon is used to speed up the distribution of very large NIS maps from an NIS master to NIS slave servers. It runs on the master server only, not the slave server.

# chkconfig yppasswdd on

The rpc.yppasswdd daemon is the password update daemon and allows normal NIS users to change their password in an NIS shadow map.

Start the three services:

# service ypserv start

# service ypxfrd start

# service yppasswdd start

Run the command ypinit on the master server to create the NIS maps. The ypinit utility builds the domain subdirectory in /var/yp for the domain. After building the subdirectory, ypinit gathers information from the passwd, group, hosts, rpc, services, netid, protocols, and mail files (or whatever was targeted as all: in /var/yp/Makefile) in the /etc directory and builds the database. Use the absolute path name of ypinit and include the –m option when running the command on the master server.

# find / -name ypinit

/usr/lib64/yp/ypinit

# /usr/lib64/yp/ypinit -m

Oracle Linux System Administration 18 - 9

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 98: D74508GC10_sg2

To begin configuring a system as an NIS client, install the following packages:

# yum install yp-tools

# yum install ypbind

Specify the name of the NIS domain that the system belongs to, by creating an entry in the /etc/sysconfig/network file:

NISDOMAIN=nisdomainname

You can use the nisdomainname command to view and set the name as well, but this is not persistent across a reboot:

# nisdomainname nis.example.com

# nisdomainname

nis.example.com

Specify the NIS server in the /etc/yp.conf file. You can specify one or more NIS servers (masters and/or slaves):

ypserver hostname

Start the ypbind service:

# service ypbind start

Oracle Linux System Administration 18 - 10

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

NIS Client Configuration

• Install the following packages:– # yum install yp-tools

– # yum install ypbind

• Specify NIS domain name in /etc/sysconfig/network:– NISDOMAIN=nisdomainname

• Specify the NIS server in /etc/yp.conf:– ypserver hostname

• Start the ypbind service:– # service ypbind start

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 99: D74508GC10_sg2

After configuring the NIS server and NIS clients, open the Authentication Configuration Tool by entering the command:

# system-config-authentication

Select NIS as the user account database. The NIS Domain and NIS Server fields are automatically filled in if NIS is configured. NIS authentication can also be enabled and configured from the command line by using the authconfig command. The syntax is as follows:

authconfig --enablenis --nisdomain nisdomainname --nisserver hostname –-update

For example, if the nisdomain is nis.example.com and the NIS server is host03.example.com, enter the following:

# authconfig --enablenis --nisdomain nis.example.com --nisserver host03.example.com –-update

Add an NIS UserTo create a new NIS user account, add the user on the NIS server:

# useradd new_user

This command updates the /etc/passwd file and creates a home directory on the NIS server.

Oracle Linux System Administration 18 - 11

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Implementing NIS Authentication

• Select NIS as the user account database by using either of the following:– Authentication Configuration Tool– Command line: authconfig

• Add a new user, and create a password.• Update the NIS maps.• Update /etc/nsswitch.conf.• Log in as new_user from an NIS client to test the

authentication.• NIS command summary:

– yppasswd: Change the NIS password.– ypcat: Display the contents of an NIS map.– ypmatch: Search an NIS map.– Others

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 100: D74508GC10_sg2

Create a password for the new NIS user:

# passwd new_user

This command updates the /etc/shadow file with the hashed password.

Update the NIS maps by running ypinit –m from the NIS server:

# /usr/lib64/yp/ypinit –m

This command updates the NIS maps, adding new_user to the passwd and shadow maps.

Update nsswitch.confWhether a system uses NIS, local files, DNS, or a combination as the source of information, and in what order, is determined by the /etc/nsswitch.conf file. To query the passwd, shadow, and group NIS maps first, make the following changes to /etc/nsswitch.conf:

passwd: nis files

shadow: nis files

group: nis files

To test the authentication, log in as new_user from a remote NIS client.

host02 login: new_user

Password:

No directory /home/new_user!

Logging in with home = “/”

You can log in, but the home directory, /home/new_user, is on the NIS server. Use NFS or automounter to mount the remote home directory.

Use the yppasswd command to change the NIS password:

# yppasswd

Changing NIS account information for new_user on host03.example.com.

Please enter old password:

Changing NIS password for new_user on host03.example.com.

Please enter new password:

Please retype new password:

The NIS password has been changed on host03.example.com.

Summary of NIS CommandsThe following summarizes the various NIS commands:• ypinit: Update the NIS server maps.

• ypwhich: Display the NIS server name.

• ypcat: Display the contents of an NIS file.

- Example: ypcat passwd

• ypmatch: Search an NIS map.

- Example: ypmatch new_user passwd

• yptest: Test the NIS configuration.

• yppasswd: Change the NIS password.

• yppush: Update NIS slaves from the NIS master.

Oracle Linux System Administration 18 - 12

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 101: D74508GC10_sg2

Lightweight Directory Access Protocol (LDAP) is used to access centrally stored information over a network. LDAP servers store information in a database called a directory which is optimized for searches. Directory entries are arranged in a hierarchical tree-like structure. This directory can store a variety of information such as names, addresses, phone numbers, network services, printers, and other types of data. LDAP can also be used to authenticate users, allowing users to access their accounts from any machine on the LDAP network.

An entry is the basic unit of information within an LDAP directory. Each entry has one or more attributes. Each attribute has a name, a type or description, and one or more values. An example of a type would be cn for a common name, or mail for an email address. In addition, LDAP allows you to control which attributes are required and which are optional through the use of a special attribute called objectClass. The values of the objectClassattribute determine the schema rules that the entry must obey.

Each entry is uniquely identified and referenced by its distinguished name (DN). The DN is constructed by taking the name of the entry itself (called the “relative distinguished name” or RDN) and concatenating the names of its ancestor entries. For example, the DN for a user with an RDN of uid=crm567 would be something like uid=crm567,ou=People, dc=example,dc=com. In this example, ou stands for “organizational unit” and dc stands for “domain component.”

Oracle Linux System Administration 18 - 13

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Lightweight Directory Access Protocol (LDAP)

• LDAP is a protocol for accessing directory services.

• A directory is a hierarchical database.

• LDAP can also be used to authenticate users.

• An entry is the basic unit of information in a directory.

• Each entry has attributes.

• Required attributes are defined in a schema.

• Entries are uniquely identified and referenced by their distinguished name (DN).

• Example of a DN:– uid=crm567,ou=People,dc=example,dc=com

• LDIF is a plain-text representation of a DN.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 102: D74508GC10_sg2

The following is an example of the information needed for each user:

uid=crm567,ou=People,dc=example,dc=com

uid=crm567

cn=Carl Robert Miller

sn=Miller

givenname=Carl

objectclass=person

objectclass=posixaccount

objectclass=account

ou=People

uidnumber=3347

gidnumber=3450

homedirectory=/home/crm567

loginshell=/bin/bash

The following is an example group:

cn=students,ou=Groups,dc=example,dc=com

cn=students

gidnumber=3450

memberuid=crm567

objectclass=posixGroup

objectclass=top

LDIF (LDAP Data Interchange Format) is a plain-text representation of an LDAP entry. It takes the following form:

[id] dn: distinguished_name

attribute_type: attribute_value...

attribute_type: attribute_value...

The optional id number is determined by the application that is used to edit the entry. Each entry can contain as many attribute_type and attribute_value pairs as needed, as long as they are all defined in a corresponding schema file.

Oracle Linux System Administration 18 - 14

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 103: D74508GC10_sg2

Oracle Linux includes OpenLDAP, which is an open source implementation of the LDAP protocols. To begin configuring a system as a OpenLDAP server, install the following OpenLDAP packages:

• openldap: Contains the libraries necessary to run the OpenLDAP server and client applications

• openldap-clients: Contains the command-line utilities for viewing and modifying directories on an LDAP server

• openldap-servers: Contains the services and utilities to configure and run an LDAP server. This includes the stand-alone LDAP daemon, slapd.

• nss-pam-ldapd: Contains nslcd, a local LDAP name service that allows a user to perform local LDAP queries. This package is only required to authenticate by using OpenLDAP.

Install the packages by using the yum install <package_name> command. Run chkconfig to cause the slapd service to start when the system enters multiuser mode:

# chkconfig slapd on

Start the slapd service:

# service slapd start

Oracle Linux System Administration 18 - 15

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

OpenLDAP

• OpenLDAP is an open-source implementation of LDAP.

• Packages include:– openldap: OpenLDAP libraries

– openldap-clients: Client command-line utilities

– openldap-servers: Server package; includes slapd

– nss-pam-ldapd: Required for LDAP authentication

• OpenLDAP service is the stand-alone LDAP daemon, slapd: # service slapd start

• Previous versions of OpenLDAP used a configuration file:– /etc/openldap/slapd.conf

• The current version uses a configuration database located in:– /etc/openldap/slapd.d

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 104: D74508GC10_sg2

Additional OpenLDAP packages, not required for a standard configuration, are:

• compat-openldap: Includes older versions of the OpenLDAP shared libraries that may be required by some applications.

• mod_authz_ldap: Contains the LDAP authorization module for the Apache HTTP Server

The OpenLDAP configuration is stored in the /etc/openldap directory. This directory contains the following:

• /etc/openldap/ldap.conf: The configuration file for client applications

• /etc/openldap/slapd.d: The directory containing the slapd configuration

• /etc/openldap/slapd.d/cn=config/cn=schema: The directory containing the schema files

The /etc/openldap/slapd.d directory also contains LDAP definitions that were previously located in the following directory:

/etc/openldap/schema

The schema used by OpenLDAP can be extended to support additional attribute types and object classes. This is described at:

http://www.openldap.org/doc/admin/schema.html

A README file, containing descriptions of the installed schema files, is located at:

/usr/share/doc/openldap-servers-version/README.schema

Previous versions of OpenLDAP used a configuration file:

/etc/openldap/slapd.conf

OpenLDAP now uses a configuration database located in the following directory:

/etc/openldap/slapd.d

To convert a previous installation to the new format, run the following command:

# slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d

Additional configuration files and directories include:• /etc/openldap/slapd.d/cn=config.ldif: A file containing the global configuration

directives for the LDAP server

• /etc/openldap/slapd.d/cn=config: A directory containing additional configuration files

Refer to man slapd-config for a description of all the configuration directives.

The OpenLDAP Software Administrator’s Guide also describes the configuration. A copy of this administrator’s guide is located at:

/usr/share/doc/openldap-servers-<version>/guide.html

Oracle Linux System Administration 18 - 16

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 105: D74508GC10_sg2

The openldap-servers package also includes the following utilities:

• slapacl: Checks the access to a list of attributes

• slapadd: Adds entries from an LDIF file to an LDAP directory

• slapauth: Checks a list of IDs for authentication and authorization permissions

• slapcat: Generates LDIF output from an LDAP directory

• slapdn: Checks a list of distinguished names (DNs) based on schema syntax

• slapindex: Re-indexes the directory. Run slapindex whenever indexing options are changed in the configuration file.

• slappasswd: A password utility for creating an encrypted user password

• slapschema: Checks compliance of a database with the corresponding schema

• slaptest: Checks the LDAP server configuration

Oracle Linux System Administration 18 - 17

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

OpenLDAP Server Utilities

• slapacl: Checks the access to a list of attributes

• slapadd: Adds entries from an LDIF file

• slapauth: Checks permissions

• slapcat: Generates LDIF output from an LDAP directory

• slapdn: Checks a list of DNs based on schema syntax

• slapindex: Re-indexes the directory

• slappasswd: A password utility

• slapschema: Checks compliance of a directory

• slaptest: Checks the LDAP server configuration

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 106: D74508GC10_sg2

The openldap-clients package installs the following utilities:

• ldapadd: Adds entries to an LDAP directory either from a file or from standard input. ldapadd is a symbolic link to ldapmodify -a.

• ldapmodify: Modifies entries in an LDAP directory

• ldapcompare: Compares a given attribute with an LDAP directory entry

• ldapdelete: Deletes entries from an LDAP directory

• ldapexop: Performs extended LDAP operations

• ldapmodrdn: Modifies the RDN value of an LDAP directory entry

• ldappasswd: A password utility for an LDAP user

• ldapsearch: An LDAP directory search tool

• ldapurl: An LDAP URL formatting tool

• ldapwhoami: Performs a whoami operation on an LDAP server

There are several LDAP client software applications that provide a graphical user interface (GUI) for maintaining LDAP directories, but none of them are included in Oracle Linux.

Oracle Linux System Administration 18 - 18

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

OpenLDAP Client Utilities

• ldapadd: Adds entries to an LDAP directory

• ldapmodify: Modifies entries in an LDAP directory

• ldapcompare: Compares a given attribute with an entry

• ldapdelete: Deletes entries from an LDAP directory

• ldapexop: Performs extended LDAP operations

• ldapmodrdn: Modifies the RDN value of an entry

• ldappasswd: A password utility for an LDAP user

• ldapsearch: An LDAP directory search tool

• ldapurl: An LDAP URL formatting tool

• ldapwhoami: Performs a whoami operation

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 107: D74508GC10_sg2

To configure LDAP authentication, in the Authentication Configuration Tool, select LDAP as the user account database. You are then prompted to enter the:

• LDAP Search Base DN

• LDAP Server

For LDAP Search Base DN, enter the DN, or the root suffix, for the user directory. The LDAP directory is hierarchical, so all the user entries used for identity and authentication exist below this parent entry. An example of a base DN would be ou=people,dc=example,dc=com.

For LDAP Server, enter the URL of the LDAP server and include the port number. Examples of this would be:• ldap://host03.example.com:389

• ldaps://host03.example.com:389

You also have the option to “Use TLS to encrypt connections.” TLS stands for Transport Layer Security. It provides a secure connection by encrypting the connections to the LDAP server. Selecting TLS enables the “Download CA Certificate” button. CA stands for certificate authority or certification authority and is an entity that issues digital certificates. The digital certificate certifies the ownership of a public key. Clicking the “Download CA Certificate” button prompts you to enter the URL from which to download the CA certificate.

Oracle Linux System Administration 18 - 19

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Configuring LDAP Authentication

• LDAP Search Base DN– The distinguished

name (DN), or root suffix, for the user directory

• LDAP Server– The URL of the LDAP

server

• Authentication Method– LDAP password

– Kerberos password

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 108: D74508GC10_sg2

Do not select “Use TLS to encrypt connections” if the server URL uses a secure protocol (ldaps).

For Authentication Method, select either one of the following:

• LDAP password

• Kerberos password

The LDAP password option uses PAM (Pluggable Authentication Module) applications for LDAP authentication. This option requires either a secure URL or the use of TLS to connect to the LDAP server.

You can also enable and configure LDAP from the command line by using the authconfigcommand. To use an LDAP identity data store, use the --enableldap flag. To use LDAP as the authentication source, use the --enableldapauth flag. Include the LDAP server name, the base DN for the user suffix, and TLS information if used. Use the full LDAP URL, including the protocol (ldap or ldaps) and the port number.

The following is an example:

# authconfig --enableldap --enableldapauth

--ldapserver=ldap://host03.example.com:389

--ldapbasedn="ou=people,dc=example,dc=com" --enableldaptls

--ldaploadcacert=https://ca.server.example.com/caCert.crt --update

Oracle Linux System Administration 18 - 20

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 109: D74508GC10_sg2

To configure Winbind authentication, install the samba-winbind package:

# yum install samba-winbind

This package includes the winbindd daemon, which is controlled by the winbind service. winbind is a client-side service used to connect to Windows servers. It resolves user and group information on a Windows server, allowing Linux to understand Windows users and groups.

Select Winbind as the user account database in the Authentication Configuration Tool. You are then prompted for information required to connect to a Microsoft workgroup, Active Directory, or Windows NT domain controller.

Enter the Windows domain to connect to. Select the security model to use for Samba clients. The security model options are user, server, domain, and ads. Selection of a security model updates the security directive in the [global] section of /etc/samba/smb.conf.

User Security ModelUser-level security is the default setting for Samba. It requires a client to log in with a valid username and password. This mode does support encrypted passwords. If the server accepts the client’s username and password, the client can then mount multiple shares without specifying a password for each instance.

Oracle Linux System Administration 18 - 21

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Configuring Winbind Authentication

• Winbind Domain

• Security Model– ads, domain, server,

user

• Winbind ADS Realm– ads only

• Winbind Domain Controllers– ads, domain only

• Template Shell– ads, domain only

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 110: D74508GC10_sg2

Server Security ModelIn this model, a local Samba server validates the username and password by authenticating it through another server, such as a Windows NT server. Do not use this model, because it presents numerous security issues. It was designed before Samba could act as a domain member server.

Domain Security ModelIn this model, the Samba server has a machine account (domain security trust account) and Samba validates the username and password by authenticating it through a domain controller.

ADS (Activity Directory Server) Security ModelIn this model, Samba is configured to act as a domain member in an ADS realm. Windows requires Kerberos tickets for Active Directory authentication. In addition, a machine account must be created on the Active Directory domain server. Install the krb5-server package and configure Kerberos before attempting to join a domain.

# yum install krb5-server

Use the kinit command to create an administrative Kerberos ticket as follows:

# kinit [email protected]

The kinit command references the Active Directory administrator account and Kerberos realm. It then obtains and caches a Kerberos ticket which is required for authentication.

To complete Winbind authentication configuration, provide the following information:

• Winbind ADS Realm: The Active Directory realm that the Samba server joins. This is required only when using the ads security model.

• Winbind Domain Controllers: The domain controller to use

• Template Shell: The login shell to use for Windows NT user account settings

• Allow offline login: Allows user authentication while the system is offline. Authentication information is stored in a local cache provided by SSSD (System Security Services Daemon).

Assuming Kerberos has been initialized, click the Join Domain button to attempt to join the domain immediately. Alternatively, use the following command to join:

# net ads join -S <active_directory_server> -U administrator%password

This command creates the appropriate machine account on the Active Directory server and grants permissions to the Samba domain member server to join the domain.

Winbind authentication can also be configured from the command line by using the authconfig command. For user and server security models, only the domain (or workgroup) name and the domain controller host names are required:

# authconfig --enablewinbind --enablewinbindauth --smbsecurity

user|server --enablewinbindoffline --smbservers=ad.example.com

--smbworkgroup=EXAMPLE --update

For ads and domain security models, specify using the --smbsecurity flag and append the template shell and realm (ads only) flags to the previous example:

--smbrealm EXAMPLE.COM --winbindtemplateshell=/bin/sh --update

Oracle Linux System Administration 18 - 22

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 111: D74508GC10_sg2

Both LDAP and NIS authentication support Kerberos authentication. Kerberos provides a secure connection over standard ports. It also uses credentials caching with SSSD, which allows offline logins.

Install the following packages required for Kerberos authentication:

# yum install krb5-libs

# yum install krb5-workstation

Select Kerberos password as the Authentication Method. You are then prompted for information required to connect to the Kerberos realm:

• Realm: The realm for the Kerberos server is the network that uses Kerberos. It is composed of KDCs (Key Distribution Center) and clients systems.

• KDCs: A comma-separated list of servers that issue Kerberos tickets

• Admin Servers: A comma-separated list of administration servers that run the kadmind process in the realm

You can also select the check boxes to use DNS to resolve server host name and to find additional KDCs within the realm.

You can also use the authconfig command to configure Kerberos authentication.

Oracle Linux System Administration 18 - 23

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Configuring Kerberos Authentication

• Realm– The realm for the

Kerberos server

• KDCs– The servers that

issue Kerberos tickets

• Admin Servers– The servers

running the kadmind process in the realm

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 112: D74508GC10_sg2

Clicking the Advanced Options tab allows you to configure local authentication options which define authentication behavior on the local system. You can also configure your system to automatically create home directories the first time that a user logs in, and you can enable smart card authentication. Each of these configuration options is discussed:

Enable Fingerprint Reader SupportAssuming that the appropriate hardware is in place, this allows fingerprint scans to be used to authenticate local users rather than using other credentials. Use the following command to enable fingerprint reader support, from the command line:

# authconfig --enablefingerprint --update

Enable Local Access ControlThis checks the /etc/security/access.conf file for local user authorization rules. This file specifies combinations for logins that are accepted or refused. The syntax of the entries is:

permission : users : origin

A plus sign (+) in the permission field means that the login is granted. Login is denied if the field contains a minus sign (-). The users field can be a username, group, or the ALLkeyword. The origin field is a host name, network, TTY (terminal), or the ALL or NONEkeywords.

Oracle Linux System Administration 18 - 24

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Configuring Advanced Options

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 113: D74508GC10_sg2

Password Hashing AlgorithmThis sets the hashing algorithm to use to encrypt locally-stored passwords. The options are:

• DESCRYPT

• BIGCRYPT

• MD5

• SHA256

• SHA512

You can also look at the password field in /etc/shadow to determine the algorithm. The field starts with a specific set of characters, depending on the hashing algorithm used. For example:

• MD5 starts with $1$

• SHA-256 starts with $5$

• SHA-512 starts with $6$

To determine the current algorithm from the command line:

# authconfig --test |grep hashing

You can also change the hashing algorithm from the command line. The following example changes it to SHA512:

# authconfig --passalgo=sha512 --update

Other Authentication OptionsTo enable the creation of user home directories at the first login, from the command line:

# authconfig --enablemkhomedir --update

Smart Card Authentication OptionsA system can accept smart cards (or tokens) to authenticate users. The appropriate hardware must be available and the following package must be installed:

# yum install pam_pkcs11

Enabling smart card support prompts for additional configuration information:

• Require smart card for login: This disables Kerberos password authentication and all other methods of authentication for logging in to the system.

• Card removal action: Sets the system’s response to a smart card being removed during an active session. Options are Ignore meaning that the system continues functioning, and Lock, which immediately locks the screen.

To enable smart card use, from the command line:

# authconfig --enablesmartcard --update

To enable smart cards and lock the system when the smart card is removed:

# authconfig --enablesmartcard --smartcardaction=0 --update

Setting --smartcardaction=1 does not lock the system when the smart card is removed.

Oracle Linux System Administration 18 - 25

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 114: D74508GC10_sg2

The System Security Services Daemon (SSSD) provides access to remote identity and authentication providers. Providers are configured as back ends with SSSD acting as an intermediary between local clients and any configured back-end provider. The local clients connect to SSSD and then SSSD contacts the providers. Benefits of SSSD include:

• Reduced load: Clients do not have to contact the identification/authentication servers directly; they only need to contact SSSD.

• Offline authentication: SSSD can, optionally, keep a cache of user identities and credentials, allowing users to authenticate offline.

• Single user accounts: SSSD maintains network credentials, allowing users to connect to network resources by authenticating with their local username on their local machine.

Install the following SSSD packages:

# yum install sssd

# yum install sssd-client

To cause SSSD to start when the system enters multiuser mode, enter either of the following:

# chkconfig sssd on

# authconfig --enablesssd --update

Oracle Linux System Administration 18 - 26

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

SSSD

• System Security Services Daemon (SSSD) provides access to remote identity and authentication providers.

• SSSD acts as an intermediary between local clients and any back-end providers.– Reduces the load on back-end providers

– Allows offline authentication

– Allows for single-user accounts

• Install the packages:– # yum install sssd

– # yum install sssd-client

• Start the service:– # authconfig --enablesssd --update

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 115: D74508GC10_sg2

The main configuration file for SSSD is /etc/sssd/sssd.conf. SSSD services and domains are configured in separate sections of this file, each beginning with a name of the section in square brackets. The following are examples:

[sssd]

[nss]

[pam]

The [sssd] Section SSSD functionality is provided by specialized services that run together with SSSD. These specialized services are started and restarted by a special service called “monitor.” Monitor options and identity domains are configured in the [sssd] section of /etc/sssd/sssd.conf. The following is an example:

[sssd]

domains = LDAP

services = nss, pam

The domains directive can define multiple domains. Enter them in the order in which you want them to be queried. The services directive lists the services that are started when sssd itself starts.

Oracle Linux System Administration 18 - 27

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Configuring SSSD Services

• The main configuration file is /etc/sssd/sssd.conf.

• SSSD services are configured in separate sections of this file.

• [sssd] section:

– Specify specialized services that run together with SSSD.

– Specify identity domains.

• [nss] section:

– Configuration parameters for NSS service

• [pam] section:

– Configuration parameters for PAM service

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 116: D74508GC10_sg2

Services SectionsEach of the specialized services that run together with SSSD are configured in separate sections in /etc/sssd.sssd.conf. For example, the [nss] section is used to configure the NSS (Name Service Switch) service. The [pam] section is used to configure the PAM (Pluggable Authentication Module) service.

Configuring the NSS ServiceIncluded in the sssd package is an NSS module, sssd_nss, which instructs the system to use SSSD to retrieve user information. This is configured in the [nss] section of /etc/sssd/sssd.conf. The following is an example that includes only a partial list of configurable directives:

[nss]

filter_groups = root

filter_users = root

reconnection_retries = 3

entry_cache_timeout = 300

The filter_users and filter_groups directives tell SSSD to exclude certain users and groups from being fetched from the NSS database. The reconnection_retries directive specifies the number of times to attempt to reconnect in the event of a data provider crash. The enum_cache_timeout directive specifies, in seconds, how long sssd_nss caches requests information about all users.

Configuring the PAM ServiceThe sssd package also provides a PAM module, sssd_pam, which is configured in the [pam]section of /etc/sssd/sssd.conf. The following is an example that includes only a partial list of configurable directives:

[pam]

reconnection_retries = 3

offline_credentials_expiration = 2

offline_failed_login_attempts = 3

offline_failed_login_delay = 5

The offline_credentials_expiration directive specifies, in days, how long to allow cached logins if the authentication provider is offline.

The offline_failed_login_attempts directive specifies how many failed login attempts are allowed if the authentication provider is offline.

PAM is discussed in a separate lesson, but to update the PAM configuration to reference all of the SSSD modules, use the authconfig command as follows to enable SSSD for system authentication:

# authconfig --update --enablesssd –enablesssdauth

This command auto-generates the PAM configuration file to include the necessary pam_sss.so entries.

Oracle Linux System Administration 18 - 28

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 117: D74508GC10_sg2

SSSD domains are a combination of an identity provider and an authentication method. SSSD works with LDAP identity providers (including OpenLDAP, Red Hat Directory Server, and Microsoft Active Directory) and can use native LDAP authentication or Kerberos authentication. When configuring a domain, you define both where the user information is stored and how those users are allowed to authenticate to the system.

Similar to SSSD services, SSSD domains are also configured in separate sections of the /etc/sssd/sssd.conf file. The services and the domains are identified in the [sssd]section. For example:

[sssd]

domains = LDAP

services = nss, pam

This example specifies an LDAP domain. The domain section of the configuration would begin with the following header:

[domain/LDAP]

The domain configuration section would then specify the identity provider, the authentication provider, and any specific configuration to access the information in those providers.

Oracle Linux System Administration 18 - 29

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Configuring SSSD Domains

• SSSD domains are also configured in separate sections of /etc/sssd/sssd.conf.

• The syntax is:[domain/Name]

id_provider = type

auth_provider = type

provider_specific = value

global = value

• Identity provider: ldap, local, or proxy

• Authentication provider: ldap, krb5, proxy, or none

• Provider-specific directives

• Global directives apply to all domains.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 118: D74508GC10_sg2

The following is an example of a domain section:

[domain/LDAP]

id_provider = ldap

ldap_uri = ldap://ldap.example.com

ldap_search_base = dc=example,dc=com

auth_provider = krb5

krb5_server = kerberos.example.com

krb5_realm = EXAMPLE.COM

min_id = 10000

max_id = 20000

Identity ProviderThe id_provider specifies the data provider identity back end to use for this domain. Supported back ends are:

• proxy: Support a legacy NSS provider

• local: SSSD internal local provider

• ldap: LDAP provider

The ldap_uri directive gives a comma-separated list of the URIs (Universal Resource Identifiers) of the LDAP servers, in order of preference, to which SSSD connects.

The ldap_search_base directive gives the base DN to use for performing LDAP user operations.

Authentication ProviderThe auth_provider directive specifies the authentication provider used for the domain. If un-specified, the id_provider is used. Supported authentication providers are:

• ldap: Native LDAP authentication

• krb5: Kerberos authentication

• proxy: Relays authentication to some other PAM target

• none: Disables authentication explicitly

The krb5_server directive gives a comma-separated list of Kerberos servers, in order of preference, to which SSSD connects.The krb5_realm directive gives the Kerberos realm to use for SASL (Simple Authentication and Security Layer)/GSS-API (Generic Security Services API) authentication. Configuration of SASL connections by using GSS-API are required before SSSD can use Kerberos to connect to the LDAP server.The last two directives, min_id and max_id, are examples of global attributes that are available to any type of domain. Other attributes include cache and timeout settings. These two directives specify UID and GID limits for the domain. If a domain contains an entry that is outside these limits, it is ignored.

Start or restart the sssd service after making any configuration changes to domains or services:

# service sssd start

Oracle Linux System Administration 18 - 30

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 119: D74508GC10_sg2

Oracle Linux System Administration 18 - 31

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Quiz

Which of the following stores information in a database, called a directory, that is optimized for searches?

a. NIS

b. LDAP

c. Winbind

d. Kerberos

e. SSSD

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 120: D74508GC10_sg2

Oracle Linux System Administration 18 - 32

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Summary

In this lesson, you should have learned how to:• Describe authentication options

• Describe the Authentication Configuration Tool

• Describe NIS

• Configure NIS server and NIS client

• Configure NIS authentication

• Describe LDAP

• Describe OpenLDAP

• Describe OpenLDAP server and client utilities

• Configure LDAP authentication

• Configure Winbind authentication

• Configure Kerberos authentication

• Describe and configure SSSD services and domains

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 121: D74508GC10_sg2

Oracle Linux System Administration 18 - 33

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Practice 18: Overview

The practices for this lesson cover the following:

• Configuring an NIS server

• Configuring an NIS client

• Implementing NIS authentication

• Testing the NIS authentication

• Auto-mounting the user home directory

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 122: D74508GC10_sg2

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 123: D74508GC10_sg2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Pluggable Authentication Modules (PAM)

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 124: D74508GC10_sg2

Oracle Linux System Administration 19 - 2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Objectives

After completing this lesson, you should be able to:• Describe the purpose PAM

• Describe PAM configuration files

• Describe PAM authentication modules

• Describe PAM module types

• Describe PAM control flags

• Walk through PAM authentication examples

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 125: D74508GC10_sg2

PAM (Pluggable Authentication Modules) is an authentication mechanism that allows you to configure how applications use authentication to verify the identity of a user. Configuration files, located in the /etc/pam.d directory, describe the authentication procedure for the application. Each of these configuration files have names that are the same as, or similar to, the name of the application that they authenticate. For example, there is a configuration file for the login process named login, a configuration file for the reboot application named reboot, and many others. Following is a partial list of the configuration files in /etc/pam.d:

# ls /etc/pam.d

atd authconfig crond halt login passwd

poweroff reboot sshd su sudo system-config-date

Each PAM configuration file contains a group of directives that define the authentication module as well as any controls or arguments. The directives for configuration file entries are:• module_type

• control_flag

• module_name

• module_arguments

Oracle Linux System Administration 19 - 3

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Introduction to PAM

• PAM allows you to configure how applications use authentication to verify the identity of a user.

• Configuration files are located in /etc/pam.d directory.

• Each configuration file has the same, or a similar, name as the application it authenticates, for example:– login, halt, reboot, sudo, sshd, samba

• Each configuration file lists authentication modules which contain the authentication code.

• Authentication modules are shared libraries located in /lib/security (and /lib64/security).

• PAM documentation includes man pages for most modules and SAG in /usr/share/doc/pam-<version>.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 126: D74508GC10_sg2

PAM Configuration FilesEach of these configuration files contains a list, or stack, of calls to authentication modules. For example, the following is the contents of the su configuration file, which lists four authentication modules:

# cat /etc/pam.d/su

auth sufficient pam_rootok.so

auth required pam_wheel.so use_uid

auth include system-auth

account sufficient pam_succeed_if.so uid = 0 use_uid quiet

account include system-auth

password include system-auth

session include system-auth

session optional pam_xauth.so

The authentication modules used for the su application are named pam_rootok.so, pam_wheel.so, pam_succeed_if.so, and pam_xauth.so.

The pam_wheel.so and pam_succeed_if.so modules include module arguments.

The system-auth file is not an authentication module but is a common configuration file for PAM-ified services. This file is located in the /etc/pam.d directory. Contents of the system-auth file are appended to the su configuration file and processed as if they were part of the file.

PAM Authentication ModulesPAM provides several authentication modules in shared libraries which are located in /lib/security (or /lib64/security for 64-bit Linux). The following is a partial list of the authentication modules:

# ls /lib64/security

pam_access.so pam_cap.so pam_chroot.so pam_console.so

pam_ftp.so pam_group.so pam_krb5.so pam_ldap.so

pam_limits.so pam.mail.so pam.selinux.so pam_winbind.so

This pluggable, modular architecture provides flexibility in setting authentication policies for a system. With the authentication code separate from the application code, you can configure the authentication mechanism for a given application without ever touching the application.

PAM DocumentationPAM has an extensive documentation set with much detail about both using PAM and writing modules to extend or integrate PAM with other applications. Almost all of the major authentication modules and configuration files with PAM have their own man pages. Also, the /usr/share/doc/pam-<version> directory contains the PAM System Administrator’s Guideand a copy of the PAM standard, rfc86.0.txt.

Oracle Linux System Administration 19 - 4

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 127: D74508GC10_sg2

The contents of the /etc/pam.d/reboot configuration file is listed here:

auth sufficient pam_rootok.so

auth required pam_console.so

account required pam_permit.so

The first column is the PAM module interface, or module type indicator. Four module types are available. Only the types auth and account determine authorization to run a command.

• auth: Proves that the user is authenticated, or authorized to use the service. This may be done by requesting and verifying the validity of a password. Modules with this interface can also set credentials, such as group memberships or Kerberos tickets.

• account: Verifies whether an already authenticated user is allowed access to the application. For example, it could check whether a user account has expired or whether a user is allowed to use this service at a particular time of day.

• password: Is used when a user tries to update his or her authentication token

• session: Configures and manages user sessions. Performs tasks that are needed to allow access, such as mounting a user’s home directory and unmounting when the service is terminated.

Oracle Linux System Administration 19 - 5

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

PAM Module Types

• The first column in the /etc/pam.d configuration file (auth in this example) is the module type:– auth sufficient pam_rootok.so

• Module types represent a different aspect of the authorization process.

• Four types are available:– auth: Proves the user is authorized to use the service

– account: Determines whether an already authenticated user is allowed to use the service

– password: Updates user authentication credentials

– session: Configures and manages user sessions

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 128: D74508GC10_sg2

The contents of the /etc/pam.d/reboot configuration file is listed as follows:

auth sufficient pam_rootok.so

auth required pam_console.so

account required pam_permit.so

The second column is the PAM control flag. PAM reads the stack from top to bottom and calls the modules listed in the configuration file. Each PAM module generates a success or failure result when called. Control flags tell PAM what to do with the result.

Modules can be stacked in a particular order, and the control flags determine how important the success or failure of a particular module is to the overall goal of authenticating the user to the service. The available control flags are listed:

• required: All required modules are tried and all must “pass” before access is granted by PAM. If the module fails at this point, the user is not notified until all modules in the stack have been executed.

• requisite: Similar to required in that success of the module is required for authentication to continue. However, if the module fails, no further modules are executed. The user is notified immediately of the first failed required or requisitemodule test.

Oracle Linux System Administration 19 - 6

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

PAM Control Flags

• The second column in the /etc/pam.d configuration file (sufficient in this example) is the control flag:– auth sufficient pam_rootok.so

• Each PAM module generates a success or failure result.

• Control flags tell PAM what to do with the result:– required: The module must pass before access is granted.

The user is not notified immediately if the module fails.– requisite: This is similar to required except that the

user is notified immediately if the module fails.– sufficient: Failure is not necessarily fatal, depending on

other module test results.– optional: The module result is ignored unless only this is

the only module.– include: This includes lines from another file.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 129: D74508GC10_sg2

• sufficient: Success indicates that this module type has succeeded and no subsequent required modules of this type are executed. Failure is not fatal to the stack of this module type, however. PAM processes the remaining modules listed to decide whether access is allowed.

• optional: The module result is generally ignored. A module flagged as optionalbecomes necessary for successful authentication when it is the only module in the stack for a particular service.

• include: Unlike the other controls, this does not relate to how the module result is handled. This flag pulls in all lines in the configuration file that match the given parameter and appends them as an argument to the module.

PAM also includes some predefined actions in the control flag field, which are included within brackets as follows:

[value1=action1 value2=action2 ...]

The use of brackets in the control flag field gives you full control of PAM’s actions. When the result returned by a function matches value, then the action is evaluated.

Oracle Linux System Administration 19 - 7

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 130: D74508GC10_sg2

To see PAM in action, the following example steps through the processing of the rebootapplication’s authentication stack. The contents of the /etc/pam.d/reboot configuration file is listed here:

# cat /etc/pam.d/reboot

#%PAM-1.0

auth sufficient pam_rootok.so

auth required pam_console.so

account required pam_permit.so

Lines that begin with # are comments and are not processed. The remaining lines tell PAM to do something as part of the authentication process. The first two lines have a module type of auth, meaning that the reboot application asks PAM to authenticate. The third line has a type of account, meaning that the reboot application asks PAM to check the account status. Processing of each line in the stack is described:

auth sufficient pam_rootok.so

This line uses the pam_rootok.so module to attempt to authenticate the user. The man page for pam_rootok indicates that the module is used to gain only root access.

Oracle Linux System Administration 19 - 8

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

PAM: Example #1

• The contents of the /etc/pam.d/reboot file:#%PAM-1.0

auth sufficient pam_rootok.so

auth required pam_console.so

account required pam_permit.so

• Lines that begin with # are comments.

• Two lines have a module type of auth, meaning that the reboot application asks PAM to authenticate.

• The third line has a type of account, meaning that the reboot application asks PAM to check the account status.

• If the pam_rootok.so module passes, authentication is allowed, because the control flag is sufficient.

• Otherwise, both required modules must pass.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 131: D74508GC10_sg2

The name suggests what this module does. If user is root, then it is okay to allow access to the application. A more detailed description from man pages follows:

# man pam_rootok

pam_rootok is a PAM module that authenticates the user if the user’s UID is 0. Applications that are created with setuid-root generally retain the UID of the user but run with the authority of an enhanced effective-UID. It is the real UID that is checked.

This test succeeds if the user’s UID is 0. Because the control flag is sufficient, no other modules are consulted and the reboot command is executed. If this test fails, the next module is consulted.

auth required pam_console.so

This line uses the pam_console.so module to attempt to authenticate the user. Because the control flag is required, this module is required to succeed if the authentication stack is to succeed.

The man page for pam_console indicates that the module is used to determine the user owning the system console. If this user is already logged in at the console, pam_console.sochecks whether there is a file in the /etc/security/console.apps directory with the same name as the service name (reboot in this case). If the file exists, authentication succeeds and control is passed to the next module.

account required pam_permit.so

This line uses the pam_permit.so module to check the account status of the user. However, the man page for this module reveals that pam_permit.so is a PAM module that always permit access. It does nothing else. This module is very dangerous. Use it with extreme caution. The man page does suggest that you add this line to your other login entries to disable account management, but continue to permit users to log in.

Oracle Linux System Administration 19 - 9

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 132: D74508GC10_sg2

To demonstrate a more complex example of PAM in action, the following is a partial listing of the login service’s authentication stack:

# cat /etc/pam.d/login

#%PAM-1.0

auth [user_unknown=ignore success=on ignore=ignore default=bad] pam_securetty.so

auth include system-auth

account required pam_nologin.so

account include system-auth

password include system-auth

Processing of each line in the stack is described:

auth [user_unknown=ignore success=on ignore=ignore default=bad pam_securetty.so

The first non-commented line calls the pam_securetty.so module, which allows rootlogins only if logging in on a secure TTY, as defined in the /etc/securetty file. This module has no effect on non-root users. This entry also contains specific actions for the control flag.

Oracle Linux System Administration 19 - 10

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

PAM: Example #2

Example # 2:• Uses value=action pairs in the control flag field,

allowing full control of PAM actions– [user_unknown=ignore success=on ignore=ignore

default=bad]

• Uses authentication module arguments– pam_unix.so nullok try_first_pass– pam_succeed_if.so uid >= 500 quiet

• Includes the contents of the common configuration file, system-auth– system-auth is included in nearly all individual service

configuration files.– system-auth is auto-generated each time the

authconfig command runs.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 133: D74508GC10_sg2

Several predefined control flag actions are available. This example uses the following actions and values:

• user_unknown=ignore:

- user_unknown: The user is not known to the underlying authentication module.

- ignore: The return status does not contribute to the return code.

• success=ok:

- success: Successful function return

- ok: If the module fails, the total stack state is fail. If the stack was already fail, the return code of this module does nothing.

• ignore=ignore:

- ignore: Ignore underlying account modules regardless of whether the control flag is required, optional, or sufficient.

- ignore: The return status does not contribute to the return code.

• default=bad:

- default: All not explicitly mentioned values

- bad: The return status is set to fail.

auth include system-auth

The next line includes the contents of a common configuration file, system-auth, into the /etc/pam.d/login file. The system-auth configuration file is included in nearly all individual service configuration files. It checks that the user who is logging in is authorized to do so, including verification of the username and password. The system-auth configuration file is auto-generated each time the authconfig command is executed. An example of auth entries in a system-auth file are:

auth required pam_env.so

auth sufficient pam_fprintd.so

auth sufficient pam_unix.so nullok try_first_pass

auth requisite pam_succeed_if.so uid >= 500 quiet

auth required pam_deny.so

The pam_env.so module allows the setting and unsetting of environmental variables. The pam_fprintd.so module is used for fingerprint authentication. The pam_unix.so module is the standard UNIX password authentication module. The nullok argument overrides the default action to not permit the user access to a service if the user’s password is blank. The try_first_pass argument tries the previous stacked module’s password before prompting the user for his or her password. The pam_succeed_if.so module tests account characteristics. In this case, it tests for uid >= 500. The quiet argument means do not log success or failure to the system log file. The pam_deny.so module is the locking-out PAM module and can be used to deny access.

account required pam_nologin.so

The next line uses the pam_nologin.so module. This module prevents users from logging in to the system when the /etc/nologin.txt file exists. This module has no affect on the rootuser.

The remaining entries also include the contents of the system-auth file for module types of account and password.

Oracle Linux System Administration 19 - 11

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 134: D74508GC10_sg2

Oracle Linux System Administration 19 - 12

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Quiz

Which of the following are examples of PAM module types?a. requisite

b. required

c. auth

d. account

e. password

f. sufficient

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 135: D74508GC10_sg2

Oracle Linux System Administration 19 - 13

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Summary

In this lesson, you should have learned how to:

• Describe the purpose PAM

• Describe PAM configuration files

• Describe PAM authentication modules

• Describe PAM module types

• Describe PAM control flags

• Walk through PAM authentication examples

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 136: D74508GC10_sg2

Oracle Linux System Administration 19 - 14

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Practice 19: Overview

The practices for this lesson cover the following:

• Configuring PAM for a single login session

• Configuring PAM to prevent non-root login

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 137: D74508GC10_sg2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Security Administration

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 138: D74508GC10_sg2

Several methods of securing your computer system are covered in this lesson.

Oracle Linux System Administration 20 - 2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Objectives

After completing this lesson, you should be able to:• Describe SELinux

• Use the SELinux Administration GUI

• Describe SELinux modes, policies, Booleans, and contexts

• Use SELinux utilities• Describe the chroot jail

• Use the chroot utility

• Describe iptables

• Use the Firewall Configuration Tool• Describe iptables tables, chains, rules, and targets

• Use the iptables utility

• Describe TCP wrappers

• Configure TCP wrappers

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 139: D74508GC10_sg2

SELinux (Security Enhanced Linux) was created by the National Security Agency to provide a finer-grained level of control over files, processes, users, and applications in the system. It is an enhancement to the Linux kernel, and it implements a different type of security called Mandatory Access Control (MAC). MAC policy is centrally managed rather than being managed by the user.

Standard Linux security is based on Discretionary Access Control (DAC). DAC provides minimal protection from broken software or malware running as a normal user or root. Access to files and devices are based solely on user identity and ownership. Malicious or flawed software can do anything with the files and resources it controls through the user that started the process. If the user is root or the application is setuid or setgid to root, the process can have root level control over the entire filesystem.

MAC under SELinux allows you to define a security policy that provides granular permissions for all users, programs, processes, files, and devices. Access control decisions are based on all the security-relevant information available, and not just authenticated user identity. When security-relevant access is taking place, such as when a process attempts to open a file, the operation is intercepted in the kernel by SELinux. If an SELinux policy rule allows the operation, it continues; otherwise, the operation is blocked and the process receives an error. The kernel checks and enforces MAC rules after it checks DAC rules. SELinux policy rules are not used if DAC rules deny access first.

Oracle Linux System Administration 20 - 3

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Introduction to SELinux

• SELinux:– Was created by the National Security Agency

– Is an enhancement to the Linux kernel

– Implements a type of security called MAC

• Standard Linux security is based on DAC:– DAC provides minimal protection.

– Access to objects is based on user identity and ownership.

• MAC can define security policy:– It provides granular permissions for all users, programs,

processes, files, and devices.

– SELinux policy rule determines whether access is allowed.

• The Linux kernel checks and enforces MAC rules after it checks DAC rules.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 140: D74508GC10_sg2

Many of the SELinux packages are installed by default. The following is a list with brief descriptions of the main SELinux packages:

• policycoreutils: Provides utilities such as sestatus, restorecon, secon, setfiles, semodule, load_policy, and setsebool for operating and managing SELinux

• libselinux-utils: Provides the avcstat, getenforce, getsebool, matchpathcon, selinuxconlist, selinuxdefcon, selinuxenabled, setenforce, and togglesebool tools

• libselinux: Provides an API for SELinux applications to get and set process and file security contexts and to obtain security policy decisions

• libselinux-python: Contains the Python bindings for developing SELinux applications

• selinux-policy: Provides the SELinux Reference Policy. The SELinux Reference Policy is a complete SELinux policy and is used as a basis for other policies, such as the SELinux targeted policy.

• selinux-policy-targeted: Provides the targeted policy. For MLS policy, install selinux-policy-mls.

Oracle Linux System Administration 20 - 4

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

SELinux Packages

• policycoreutils: Provides the policy core utilities that are required for basic operation of SELinux

• libselinux-utils: Provides additional SELinux tools

• libselinux: Provides an API for SELinux tools

• libselinux-python: Contains the Python bindings for developing SELinux applications

• selinux-policy: Provides the SELinux Reference Policy

• selinux-policy-targeted: Provides targeted policies. For MLS, install selinux-policy-mls.

• Other packages are available but not installed by default.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 141: D74508GC10_sg2

The following is a partial list of SELinux packages that are not installed by default:

• setroubleshoot-server: Translates denial messages, produced when access is denied by SELinux, into detailed descriptions that are viewed with the sealert command

• policycoreutils-python: Provides additional utilities such as semanage, audit2allow, audit2why, and chcat for operating and managing SELinux

• policycoreutils-gui: Provides system-config-selinux, which is a graphical tool for managing SELinux

• setools-console: Provides the Tresys Technology SETools distribution, several tools and libraries for analyzing and querying policy, audit log monitoring and reporting, and file context management

• mcstrans: Translates levels, such as s0-s0:c0.c1023, to an easier-to-read form, such as SystemLow-SystemHigh

The semanage command is described in this lesson. Install the policycoreutils-pythonpackage as follows to run the semanage command:

# yum install policycoreutils-python

This installs the following dependencies:• audit-libs-python

• libcgroup

• libsemanage-python

• setools-libs

• setools-libs-python

Oracle Linux System Administration 20 - 5

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 142: D74508GC10_sg2

The SELinux Administration graphical user interface (GUI) is a tool used to manage SELinux. To run this GUI, install the policycoreutils-gui package:

# yum install policycoreutils-gui

This installs the following dependencies:• gnome-python2-gtkhtml2

• gtkhtml2

• setools-console

Enter the following command to display the GUI:

# system-config-selinux

The GUI displays a list of options on the left side. The right side of the GUI changes as different options are selected from the left.

The example shown in the slide is the Status view. From this view, you can change:

• Enforcing Mode: Enforcing, Permissive, Disabled

• Policy Type: Targeted, MLS (Multi-Level Security)

• Relable on next reboot: Labels all files at boot time with an SELinux contextThe sestatus command displays the SELinux mode and the SELinux policy being used.

Oracle Linux System Administration 20 - 6

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

SELinux Administration GUI

system-config-selinux

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 143: D74508GC10_sg2

SELinux runs in one of three modes (or states).

EnforcingThis is the default state which enforces SELinux security policy. Access is denied to users and programs unless permitted by SELinux security policy rules. All denial messages are logged as AVC (Access Vector Cache) Denials.

PermissiveThis is a diagnostic state. The security policy rules are not enforced, but SELinux sends denial messages to a log file. This allows you to see what would have been denied if SELinux were running in enforcing mode.

DisabledSELinux does not enforce a security policy because no policy is loaded in the kernel. Only DAC rules are used for access control.

Oracle Linux System Administration 20 - 7

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

SELinux Modes

• Enforcing:– This is the default state. Access is denied to users and

programs unless permitted by SELinux security policy rules.

• Permissive:– Security policy rules are not enforced but denial messages

are logged.

• Disabled:– No security policy is loaded. Only DAC rules are used for

access control.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 144: D74508GC10_sg2

There are multiple ways of setting the SELinux mode. One way is to select the mode from the Status view in the SELinux GUI.

You can also edit the main configuration file for SELinux, /etc/selinux/config. Set the mode by changing the SELINUX directive in this file. For example, to set the mode to enforcing:

SELINUX=enforcing

The setenforce command is used to change between enforcing and permissive mode. Changes made with this command do not persist across reboots.

To change to enforcing mode:

# setenforce 1

To change to permissive mode:

# setenforce 0

Display the Current ModeUse the getenforce command to view the current SELinux mode:

# getenforce

Enforcing

Oracle Linux System Administration 20 - 8

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Setting a Mode

• Set the mode from the SELinux GUI.• Define the SELINUX directive in /etc/selinux/config:

– SELINUX=enforcing

– SELINUX=permissive

– SELINUX=disabled

• Use the setenforce command to set either enforcing (1) or permissive (0) mode. Mode does not persist after a reboot:– # setenforce 1

– # setenforce 0

• To view the current SELinux mode:– # getenforce

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 145: D74508GC10_sg2

The SELinux policy describes the access permissions for all users, programs, processes, files, and devices they act upon. SELinux implements one of two different policies:

• Targeted: This default policy applies access controls to certain (targeted) processes.

• MLS: Multi-Level Security.

Select the policy type from the SELinux GUI, or set the SELINUXTYPE directive in the /etc/selinux/config file. For example:

SELINUXTYPE=targeted

With the targeted policy, targeted processes run in their own domain, called a confined domain. In a confined domain, the files that a targeted process has access to are limited. If a confined process is compromised by an attacker, the attacker’s access to resources and the possible damage they can do is also limited. SELinux denies access to these resources and logs the denial.

Only specific services are placed into these distinct security domains that are confined by the policy. For example, a user runs in a completely unconfined domain while services that listen on a network for client requests, such as named, httpd, and sshd, run in a specific, confined domain tailored to its operation. Processes that run as the Linux root user and perform tasks for users, such as the passwd application, are also confined.

Oracle Linux System Administration 20 - 9

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

SELinux Policies

• SELinux implements one of two different policies:– Targeted: Applies access controls to targeted processes

– MLS: Multi-Level Security

• Select the policy type from the SELinux GUI or define the SELINUXTYPE directive in /etc/selinux/config:– SELINUXTYPE=targeted

– SELINUXTYPE=mls

• Targeted policy:– Targeted processes run in a confined domain.

– All network services are targeted processes.

– Access to files is limited.

• Non-targeted processes run in an unconfined domain.– Access to files is not limited.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 146: D74508GC10_sg2

Processes that are not targeted run in an unconfined domain. SELinux policy rules allow processes running in unconfined domains almost all access. If an unconfined process is compromised, SELinux does not prevent an attacker from gaining access to system resources and data. DAC rules still apply in an unconfined domain.

The following are examples of unconfined domains:• initrc_t domain: init programs run in this unconfined domain.

• kernel_t domain: Unconfined kernel processes run in this domain.

• unconfined_t domain: Linux users logged in to the system run in this domain.

Many domains that are protected by SELinux have man pages describing how to customize their policies.

The policy configuration for each policy is installed in the /etc/selinux/<SELINUXTYPE>directories. The following example shows a partial listing of the /etc/selinux directory with both targeted and MLS policies installed:

# ls –l /etc/selinux

-rw-r--r--. root root config

drwxr-xr-x. root root mls

drwxr-xr-x. root root targeted

The targeted policy is installed by default, but the MLS policy is not. To use the MLS policy, install the selinux-policy-mls package:

# yum install selinux-policy-mls

Oracle Linux System Administration 20 - 10

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 147: D74508GC10_sg2

A given SELinux policy can be customized by enabling or disabling a set of policy Booleans. Booleans allow parts of SELinux policy to be changed at run time, without any knowledge of SELinux policy writing. This allows changes without reloading or recompiling SELinux policy.

The system-config-selinux command displays the SELinux GUI, which, via the Boolean view (shown in the slide), allows customization of these Booleans. In the Boolean view, the Active check box indicates whether a Boolean is on or off. You can sort by any of the three columns (Active, Module, Description).

You can also display this list from the command line by using the following command:

# semanage boolean –l

SELinux boolean

ftp_home_dir -> off Allow ftp to read and write files...

smartmon_3ware -> off Enable additional permissions...

xdm_sysadm_login-> off Allow xdm logins as sysadm

...

In the sample listing, the ftp_home_dir Boolean is off, which prevents the FTP daemon, vsftpd, from reading and writing to files in user home directories.

Oracle Linux System Administration 20 - 11

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

SELinux Booleans

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 148: D74508GC10_sg2

Displaying BooleansYou can also use the getsebool command to list Booleans. This command displays statuses but no descriptions.

To display all Booleans and their statuses:

# getsebool –a

abrt_anon_write --> off

abrt_handle_event --> off

allow_console_login --> on

...

Include the Boolean name as an argument to display the status of a specific Boolean. Multiple Boolean arguments are also allowed:

# getsebool allow_ftpd_use_nfs mozilla_read_content

allow_ftpd_use_nfs --> off

mozilla_read_content --> off

The seinfo command also displays the list of Booleans:

# seinfo –b

Conditional Booleans: 179

allow_domain_fs_use

allow_ftpd_full_access

...

Setting BooleansUse the setsebool command to configure Booleans from the command line. The syntax is:

setsebool <Boolean> on|off

For example, the following sequence of commands displays the current status of a Boolean, then enables it to allow the syslogd daemon to send mail, and then displays the status again:

# getsebool logging_syslogd_can_sendmail

logging_syslogd_can_sendmail --> off

# setsebool logging_syslogd_can_sendmail on

logging_syslogd_can_sendmail --> on

To make the change persistent across reboots, use the –P option:

# setsebool –P logging_syslogd_can_sendmail on

Oracle Linux System Administration 20 - 12

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 149: D74508GC10_sg2

The SELinux GUI’s File Labeling view is shown in the slide. All files, directories, devices, and processes have a security context (or label) associated with them. For files, this context is stored in the extended attributes of the filesystem. Problems with SELinux often arise from the filesystem being mislabeled. If you see an error message containing file_t, that is usually a good indicator that you have a problem with filesystem labeling.

There are several ways to relabel the filesystem:

• Create the file /.autorelabel and reboot.

• The Status view in SELinux GUI provides an option to relable.

• Two command line utilities, restorcon and fixfiles, relabel files.

To view the filesystem context information from the command line, use the ls –Z command:

# ls –Z

-rw-------. root root system_u:object_r:admin_home_t:s0 anaco...

-rw-r--r--. root root system_u:object_r:admin_home_t:s0 insta...

-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 k...

This information is also stored in the /etc/selinux/<SELINUXTYPE>/contexts/files directory.

Oracle Linux System Administration 20 - 13

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

SELinux File Labeling

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 150: D74508GC10_sg2

The SELinux context contains additional information such as SELinux user, role, type, and, optionally, a level. Access control decisions on processes, Linux users, and files are based on this context information.

To view the SELinux context information about files, use the ls –Z command:

# ls –Z

-rw-------. root root system_u:object_r:admin_home_t:s0 anaco...

To view the SELinux context information about processes, use the ps –Z command:

# ps -Z

unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 16445 su

unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 16531 bash

To view the SELinux context associated with your Linux user, use the id –Z command:

# id –Z

unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

SELinux context is displayed by using the following syntax:

user:role:type:level

Oracle Linux System Administration 20 - 14

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

SELinux Context

• Contest is additional information about users, files, and processes.

• Access control is based on this information:– SELinux user: Linux users are mapped to SELinux users.

– Role: An attribute of RBAC that acts as an intermediary between domains and SELinux users

– Type: An attribute of TE that defines a domain for processes

– Level: Optional information; an attribute of MLS and MCS

• Use -Z option to display context information:– ls -Z

– ps -Z

– id –Z

• The format is user:role:type:level.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 151: D74508GC10_sg2

SELinux UserThere are SELinux users in addition to the regular Linux users. SELinux users are part of an SELinux policy. The policy is authorized for a specific set of roles and for a specific MLS (Multi-Level Security) range. Each Linux user is mapped to an SELinux user as part of the policy. This allows Linux users to inherit the restrictions and security rules and mechanisms placed on SELinux users.

To define what roles and levels they can enter, the mapped SELinux user identity is used in the SELinux context for processes in that session. Use the SELinux Administration GUI to display User Mapping. You can also view a list of mappings between SELinux and Linux user accounts from the command line:

# semanage login –l

Login Name SELinux User MLS/MCS Range

_default_ unconfined_u s0-s0:c0.c1023

root unconfined_u s0-s0:c0.c1023

system_u system_u s0-s0:c0.c1023

Linux users are mapped to the SELinux _default_ login by default, which is mapped to the SELinux unconfined_u user. The last column, MLS/MCS Range, is the level used by MLS and MCS (Multi-Category Security).

RoleThe role is an attribute of the Role-Based Access Control (RBAC) security model. The role serves as an intermediary between domains and SELinux users. SELinux users are authorized for roles, roles are authorized for domains, and processes run in their own separate domains. The roles determine which domains you can enter, and ultimately, which files you can access.

TypeThe type is an attribute of Type Enforcement (TE). The type defines a type for files, and defines a domain for processes. Processes are separated from each other by running in their own domains. This separation prevents processes from accessing files used by other processes, as well as preventing processes from accessing other processes. SELinux policy rules define how types can access each other, whether it be a domain accessing a type, or a domain accessing another domain.

LevelThe level is an attribute of MLS and MCS. An MLS range is a pair of levels, written as lowlevel-highlevel if the levels differ, or lowlevel if the levels are identical (s0-s0 is the same as s0). Each level is a sensitivity-category pair, with categories being optional. If there are categories, the level is written as sensitivity:category-set. If there are no categories, it is written as sensitivity.

If the category set is a contiguous series, it can be abbreviated. For example, c0.c3 is the same as c0,c1,c2,c3. The /etc/selinux/targeted/setrans.conf file is the Multi-Category Security translation table for SELinux and maps levels to human readable form such as s0:c0.c1023=SystemHigh. Do not edit this file with a text editor, use the semanagecommand to make changes.

Use the chcon command to change the SELinux context for files. Changes made with the chcon command do not survive a filesystem relabel, or the execution of the restoreconcommand. When using chcon, provide all or part of the SELinux context to change.

Oracle Linux System Administration 20 - 15

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 152: D74508GC10_sg2

Linux users are mapped to the SELinux _default_ login by default, which is mapped to the SELinux unconfined_u user. However, SELinux can confine Linux users, to take advantage of the security rules and mechanisms applied to them, by mapping Linux users to SELinux users.

A number of confined SELinux users exist in SELinux policy. The following is a list of confined SELinux users and their associated domains:

• guest_u: The domain for the user is guest_t.

• staff_u: The domain for the user is staff_t.

• user_u: The domain for the user is user_t.

• xguest_x: The domain for the user is xguest_t.

Linux users in the guest_t, xguest_t, and user_t domains can only run set user ID (setuid) applications if the SELinux policy permits it (such as passwd). They cannot run the su and sudo setuid applications to become the root user.

Linux users in the guest_t domain have no network access, and can only log in from a terminal. They can log in with ssh, but cannot use ssh to connect to another system.

The only network access Linux users in the xguest_t domain have is Firefox for connecting to webpages.

Oracle Linux System Administration 20 - 16

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Confined SELinux Users

• Confined SELinux users and their associated domains:– guest_u: The domain for the user is guest_t.

– staff_u: The domain for the user is staff_t.

– user_u: The domain for the user is user_t.

– xguest_x: The domain for the user is xguest_t.

• SELinux can confine Linux users by mapping Linux users to SELinux users.

• Use semanage to map a Linux user to an SELinux user:– # semanage login -a -s user_u newuser

• Booleans are available to change user behavior when running applications in home directories and in /tmp.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 153: D74508GC10_sg2

Linux users in the xguest_t, user_t, and staff_t domains can log in using the X Window System and a terminal.

By default, Linux users in the staff_t domain do not have permissions to execute applications with the sudo command.

By default, Linux users in the guest_t and xguest_t domains cannot execute applications in their home directories or /tmp, preventing them from executing applications in directories they have write access to. This helps prevent flawed or malicious applications from modifying files that users own.

By default, Linux users in the user_t and staff_t domains can execute applications in their home directories and /tmp.

Mapping Linux Users to SELinux UsersUse the semanage login –a command to map a Linux user to an SELinux user. For example, to map Linux newuser user to the SELinux user_u user, run the following command:

# semanage login -a -s user_u newuser

The -a option adds a new record and the -s option specifies the SELinux user. The last argument, newuser, is the Linux user that you want mapped to the specified SELinux user.

Booleans for Users Executing ApplicationsSome Booleans are available to change user behavior when running applications in their home directories and in /tmp. Use the setsebool –P <boolean> on|off command:

To allow Linux users in the guest_t domain to execute applications in their home directories and /tmp:

# setsebool -P allow_guest_exec_content on

To allow Linux users in the xguest_t domain to execute applications in their home directories and /tmp:

# setsebool -P allow_xguest_exec_content on

To prevent Linux users in the user_t domain from executing applications in their home directories and /tmp:

# setsebool -P allow_user_exec_content off

To prevent Linux users in the staff_t domain from executing applications in their home directories and /tmp:

# setsebool -P allow_staff_exec_content off

Oracle Linux System Administration 20 - 17

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 154: D74508GC10_sg2

This slide lists some of the more commonly used command line utilities for managing and operating SELinux. More utilities are provided. The policycoreutils package installs the following utilities:

• fixfiles: Fixes the security context on filesystems

• load_policy: Loads a new SELinux policy into the kernel

• restorecon: Resets the security context on one or more files

• setfiles: Initializes the security context on one or more files

• secon: Displays the SELinux context from a file, program, or user input

• semodule_deps: Displays the dependencies between SELinux policy packages

• semodule_expand: Expands an SELinux policy module package

• semodule_link: Links SELinux policy module packages together

• semodule_package: Creates an SELinux policy module package

• restorecond: Is a daemon that watches for file creation and sets the default file context

• semodule: Manages SELinux policy modules

• sestatus: Displays SELinux status

• setsebool: Sets SELinux Boolean value

Oracle Linux System Administration 20 - 18

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

SELinux Utilities: Summary

• sestatus: Displays SELinux status

• semanage: Is an SELinux policy management tool

• semodule: Manages SELinux policy modules

• setsebool: Sets SELinux Boolean value

• avcstat: Displays SELinux AVC statistics

• getenforce: Reports the current SELinux mode

• getsebool: Reports SELinux Boolean values

• seinfo: Is an SELinux policy query tool

• sesearch: Is an SELinux policy query tool

• fixfiles: Fixes the security context on filesystems

• restorecon: Resets the security context on files

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 155: D74508GC10_sg2

The libselinux-utils package installs the following utilities:

• avcstat: Displays SELinux AVC statistics

• getenforce: Reports the current SELinux mode

• getsebool: Reports SELinux Boolean values

• matchpathcon: Queries the system policy and displays the default security context associated with the file path

• selinuxconlist: Displays all SELinux context reachable for a user

• selinuxdefcon: Displays the default SELinux context for a user

• selinuxenabled: Indicates whether SELinux is enabled

• setenforce: Modifies the SELinux mode

• togglesebool: Flips the current value of an SELinux Boolean

The setools-console package installs the following utilities:

• findcon: An SELinux file context search tool

• indexcon: An SELinux file context indexing tool

• replcon: An SELinux file context replacement tool

• seaudit-report: An SELinux audit log reporting tool

• sechecker: An SELinux policy checking tool

• sediff: An SELinux policy difference tool

• seinfo: An SELinux policy query tool

• sesearch: An SELinux policy query tool

The policycoreutlis-python package installs the following utilities:

• semanage: Is an SELinux policy management tool

• audit2allow, audit2why: Generates SELinux policy allow/don’t_audit rules from logs of denied operations

• chcat: Changes or removes the security category for each file or user.

• sandbox: Runs a command in an SELinux sandbox

The policycoreutlis-gui package installs the following utilities:

• system-config-selinux: SELinux Administration GUI

Oracle Linux System Administration 20 - 19

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 156: D74508GC10_sg2

Oracle Linux System Administration 20 - 20

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Quiz

A given SELinux policy can be customized by enabling or disabling which of the following?

a. Modes

b. Policies

c. Booleans

d. Contexts

e. Labels

f. Users

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 157: D74508GC10_sg2

As the name implies, a chroot operation changes the apparent root directory for a running process and its children. It allows you to run a program (process) with a root directory other than /. The program cannot see or access files outside the designated directory tree.

For example, you can run a program and specify its root directory as /home/oracle/jail. In this case, the program’s root directory is actually /home/oracle/jail. The program would not be aware of, or able to access, any files above this directory in the hierarchy.

This artificial root directory is called a chroot jail. Its purpose is to limit the directory access of a potential attacker. The chroot jail locks down a given process and any user ID it is using so that the user sees only the directory that the process is running in. To the process, it appears that the directory it is running in is the root directory.

The chroot mechanism is not intended to defend against intentional tampering by privileged (root) users. It is also not intended by itself to be used to block low-level access to system devices by privileged users. A chroot root user can still create device nodes and mount the filesystems on them.

For a chroot process to successfully start, the chroot directory must be populated with all required program files, configuration files, device nodes, and shared libraries at their expected locations.

Oracle Linux System Administration 20 - 21

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

chroot Jail

• The chroot utility changes the apparent root directory.

• A program (process) runs with a root directory other than /.

• The artificial root directory is called a chroot jail.

• To the process, it appears that the directory it is running in the root directory.

• A chroot jail limits the directory access of a potential attacker.

• A chroot jail is not intended to:– Defend against intentional tampering by privileged (root) users

– Be used to block low-level access to system devices by privileged users

• The chroot jail directory must be populated with all files required by the process at their expected locations.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 158: D74508GC10_sg2

To use a chroot jail, use the following command (new_root must be an existing directory):

# chroot new_root [command]

The new_root directory becomes the artificial root directory. chroot changes to new_rootand runs the optional command. Without specifying a command as an argument, chrootchanges to new_root and runs the value of the SHELL environment variable or /bin/sh if SHELL is not set.

For example, assuming SHELL is set to /bin/bash, and the /home/oracle/jaildirectory exists, running the chroot command results in the following:

# chroot /home/oracle/jail

chroot: failed to run command ‘/bin/bash’: No such file or directory

The /home/oracle/jail directory takes the name of /. chroot cannot find the /bin/bash within this chroot jail and returns the error message.

To implement a chroot jail, create the new root directory structure and copy all the necessary files into this new root directory before running the chroot command.

Oracle Linux System Administration 20 - 22

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

chroot Utility

• To use a chroot jail, use the following command:– # chroot new_root [command]

• The new_root directory becomes the artificial root.

• chroot changes to new_root and runs the optional command.– Alternatively, it runs the SHELL variable if the command is

omitted.

• The command fails unless the necessary files are copied into the new_root directory before running chroot:# chroot /home/oracle/jail

chroot: failed to run command ‘/bin/bash’: No such file or directory

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 159: D74508GC10_sg2

To implement a chroot jail and run /bin/bash, create the bin directory in the artificial root directory (/home/oracle/jail in this example), and copy /bin/bash into this directory:

$ mkdir /home/oracle/jail/bin

$ cp /bin/bash /home/oracle/jail/bin

The /bin/bash command is dynamically linked to shared libraries. These libraries must also be copied into the chroot jail.

Use the ldd command to determine which libraries are required by the /bin/bashcommand:

$ ldd /bin/bash

linux-vdso.so.1 => (0x00007fff83512000)

libtinfo.so.5 => /lib64/libtinfo.so.5 (0x000000351cc00000)

libdl.so.2 => /lib64/libdl.so.2 ...

libc.so.6 => /lib64/libc.so.6 ...

/lib64/ld-linux-x86-64.so.2

Copy each of these files into a lib64 directory in the artificial root directory.

Oracle Linux System Administration 20 - 23

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Implementing a chroot Jail

• Make the necessary directories and copy all required files into these directories:– $ mkdir /home/oracle/jail/bin

– $ cp /bin/bash /home/oracle/jail/bin

• Determine whether any shared libraries are required:– $ ldd /bin/bash

• Create the lib (or lib64) directory and copy all required shared libraries into this directory:– $ mkdir /home/oracle/jail/lib64

– $ cp /lib64/{...} /home/oracle/jail/lib64

• Execute the chroot command (as root):# chroot /home/oracle/jail

bash-4.1#

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 160: D74508GC10_sg2

Make the lib64 directory and copy the shared libraries into this directory:

$ mkdir /home/oracle/jail/lib64

$ cp /lib64/{libtinfo.so.5,libdl.so.2,libc.so.6,ld-linux-x86-64.so.2} /home/oracle/jail/lib64

Now that all the required files are in their expected locations, running the chroot command (as root) results in the following:

# chroot /home/oracle/jail

bash-4.1#

The command succeeded this time and the /bin/bash program executed. Entering pwd to print the current directory displays /, even though the actual directory is /home/oracle/jail:

bash-4.1# pwd

/

The pwd command runs because it is a shell built-in command. Running any other command fails as bash cannot find the command. The process assumes it is in the root directory and has no visibility or knowledge of any files above this directory in the hierarchy.

For example, running the ls command fails:

bash-4.1# ls

bash: ls: command not found

Use the exit command to exit the chroot jail.

bash-4.1# exit

exit

#

Oracle Linux System Administration 20 - 24

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 161: D74508GC10_sg2

Two services are set up to take advantage of chroot jails. You can set up DNS so that named runs in a jail. The vsftpd FTP server can automatically start chroot jails for clients.

DNS in chroot JailThe bind-chroot package allows you to set up named to run in a chroot jail. When you install this package, the /var/named/chroot directory is created and becomes the chrootjail directory for all BIND files.

• The /var/named directory becomes /var/named/chroot/var/named.

• /etc/named* files become /var/named/chroot/etc/named* files.

Installing this package also sets the ROOTDIR shell variable to /var/named/chroot in the /etc/sysconfig/named file.

The advantage of running named in a chroot jail is that if a hacker enters your system via a BIND exploit, the hacker’s access to the rest of your system is isolated to the files under the chroot jail directory.

FTP Clients in chroot JailBy default, anonymous users are placed in a chroot jail. When an anonymous user logs in to a vsftpd server, the user’s home directory is /var/ftp. However, all the user sees is /.

Oracle Linux System Administration 20 - 25

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Running Services in a chroot Jail

• DNS and FTP includes chroot jail options.

• DNS:– Install the bind-chroot package.

– /var/named/chroot becomes the chroot for BIND files.

• FTP (vsftpd daemon):– Anonymous users are automatically placed in a chroot jail.

– /var/ftp appears as /.

– Local user home directories can be configured as chrootjails.

– Set options in the /etc/vsftpd/vsftpd.conf file.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 162: D74508GC10_sg2

For example, a directory named /var/ftp/upload appears as /upload to an anonymous user. This prohibits anonymous users from being able to access any files above /var/ftp in the directory hierarchy.

Local users that access an vsftpd server are placed in their home directory. You can enable options in the /etc/vsftpd/vsftpd.conf file to put local users in a chroot jail, where the artificial root directory is the user’s home directory. The following options exist in the vsftpdconfiguration file to implement a chroot jail for local users:

• chroot_list_enable

• chroot_local_user

• chroot_list_file

When a local user logs into the vsftpd server, the chroot_list_enable directive is checked. If this directive is set to YES, the service checks the /etc/vsftpd/chroot_listfile (by default) or another file specified by the chroot_list_file directive.

Another directive is then checked, chroot_local_user. If this directive is set to YES, then the chroot_list becomes a list of users to NOT chroot. If this directive is set to NO, the user is put into a chroot jail in his home directory.

Oracle Linux System Administration 20 - 26

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 163: D74508GC10_sg2

A packet filtering firewall reads incoming network packets and filters (allows or denies) each data packet based on the header information in the packet. You can create packet filters, or rules, that determine which packets are accepted and which are rejected. For example, you can create a rule to block a port. If a request is made to the port that is blocked by the firewall, the request is ignored. If a service is listening on a blocked port, it does not receive the packets and is effectively disabled.

The Linux kernel has built-in packet filtering functionality. Kernel versions earlier than 2.4 relied on ipchains for packet filtering. The 2.4 kernel (and above) includes iptables which is similar to ipchains, but provides advanced features and more control of filtering network packets. iptables pertains to IPv4 packets. ip6tables is available for IPv6 packets.

The iptables mechanism is composed of two components:

• netfilter: A kernel component consisting of a set of tables that store rules that the kernel uses to control network packet filtering

• iptables: A user utility to create, maintain, and display the rules stored by netfilter

Oracle Linux provides a GUI called the Firewall Configuration Tool for configuring a simple firewall. This tool creates basic iptables rules for implementing a general-purpose firewall. To create a more complex firewall configuration, you can manually configure packet filtering rules by using the iptables utility. Rules are stored in the /etc/sysconfig/iptablesfile.

Oracle Linux System Administration 20 - 27

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Introduction to iptables

• Packet filtering firewalls accept or deny network packets.

• The Linux kernel has built-in packet filtering functionality.• iptables is used for IPv4 traffic.

– ip6tables is used for IPv6 traffic.

• Two components:– netfilter: A kernel component that stores filtering rules

– iptables: A user utility to maintain rules stored by netfilter

• Firewall Configuration Tool (GUI):– This tool creates basic iptables rules.

• Use the iptables command-line utility to create complex firewall configuration rules.

• Rules are stored in /etc/sysconfig/iptables.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 164: D74508GC10_sg2

The Firewall Configuration Tool allows you to configure a basic firewall. You can define which network services on your system remote users can access. For more complex rules, use the iptables utility.

Use the following command to launch the tool:

# system-config-firewall

If the command is not found, install the system-config-firewall package:

# yum install system-config-firewall

From the GUI, you can enable or disable the firewall:• Disable: Provides complete access, does no security checking.

• Enable: Configures the system to allow outgoing packets and to reject incoming connections that are not in response to outbound requests, such as DNS replies or DHCP requests.

It is recommended that you configure a firewall for any system with an Internet connection. Only allow access to specific services running on your server as needed. Enable options in the Trusted Services list in the GUI to allow service requests to pass through the firewall. For example, if your system is configured as an FTP server (running vsftpd), check the FTP check box as shown. Click Apply to save any changes.

Oracle Linux System Administration 20 - 28

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Firewall Configuration Tool

system-config-firewall

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 165: D74508GC10_sg2

The netfilter component of iptables is a set of tables. The three main tables are described as follows:

• Filter: The default table. This table is used primarily to DROP or ACCEPT packets based on their content.

• NAT: The Network Address Translation table. Packets that create new connections are routed through this table.

• Mangle: This table is used to alter certain fields in a packet.

These tables store rules that the kernel uses to make network packet filtering decisions. A rule consists of one or more criteria and a single action, or target. If the criteria in a rule matches the information in a network packet header, then the action, or target, is applied to the packet. Examples of targets include:

• ACCEPT: Continue processing the packet.

• DROP: End the packet’s life without notice.

• REJECT: Similar to DROP, except it notifies the sending system that the packet was blocked.

Rules are stored in chains. Each rule in a chain is applied, in order, to a packet until a match is found. If there is no match, the chain’s policy, or default action, is applied to the packet.

Oracle Linux System Administration 20 - 29

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

iptables Terminology

• The netfilter component is a set of tables:– Filter: The default table

– NAT: The Network Address Translation table

– Mangle: The table used to alter certain fields in a packet

• Tables store rules, which consists of:– One or more match criteria– A single action, or target, such as ACCEPT, DROP, REJECT

• Rules are stored in chains. Filter table chains are:– INPUT: Inbound packets pass through this chain.

– OUTPUT: Outbound packets pass through this chain.

– FORWARD: Packets not addressed to the local system pass through this chain.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 166: D74508GC10_sg2

Each netfilter table has several built-in chains. The default netfilter table, named filter, contains the following built-in chains:

• INPUT: Inbound packets to the local system pass through this chain.

• OUTPUT: Packets created locally pass through this chain.

• FORWARD: Packets not addressed to the local system pass through this chain.

These chains are permanent and cannot be deleted. You can create additional, user-defined chains in this filter table.

Oracle Linux System Administration 20 - 30

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 167: D74508GC10_sg2

The firewall rules are only active if the iptables service is running. Start the service as follows. After changing the configuration, save the configuration and restart the service:

# service iptables start

To ensure that iptables starts at boot time, enter the following command to enable the service for runlevels 2, 3, 4, and 5:

# chkconfig iptables on

You can turn off the ip6tables service if you are not using IPv6.

Use the iptables command to create, maintain, and display the rules stored by netfilter. Several options exist for the command. Long or short options are allowed. For example, to add rules to the end of a chain, use either of the following:

# iptables --append ...

# iptables -A ...

To remove rules from a chain, use either of the following:

# iptables --delete ...

# iptables -D ...

Use iptables -h or iptables --help to display all options.

Oracle Linux System Administration 20 - 31

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Beginning iptables Maintenance

• To start the service:– # service iptables start

• To configure iptables to start at boot time:– # chkconfig iptables on

• To list iptables:– # iptables –L [chain]

• Each chain has a default policy:– The action to take (ACCEPT or DROP) if no rules match

• To set default policy:– # iptables -P chain DROP|ACCEPT

• To save configuration changes to iptables:– # service iptables save

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 168: D74508GC10_sg2

Use the -L option, or --list, to list the current rules:

# iptables –L

Chain INPUT (policy ACCEPT)

target prot opt source destination

ACCEPT all -- anywhere anywhere state RELATED, ESTABLISHED

ACCEPT icmp -- anywhere anywhere

ACCEPT all -- anywhere anywhere

ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ftp

ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh

REJECT all -- anywhere anywhere reject-with icmp-host-...

Chain FORWARD (policy ACCEPT)

target prot opt source destination

REJECT all -- anywhere anywhere reject-with icmp-host-...

Chain OUTPUT (policy ACCEPT)

target prot opt source destination

The rules in all three chains (INPUT, FORWARD, OUTPUT) of the default table, filter, are displayed. Include the chain as an argument to limit output to a specific chain. For example, to list the rules in the INPUT chain only:

# iptables –L INPUT

PoliciesEach iptables chain consists of a default policy and zero or more rules, which together define the overall ruleset for the firewall. If the information in a network packet header does not match any rule, the chain’s policy, or default action, is applied to the packet. In this example, the policy for each chain is ACCEPT.

The default policy for a chain can be either DROP or ACCEPT. A more secure system would have a default of DROP and would only allow specific packets on a case-by-case basis. Set the default policy as follows, providing either the DROP or ACCEPT argument. This example blocks all incoming and outgoing network packets:

# iptables -P INPUT DROP

# iptables -P OUTPUT DROP

The FORWARD chain routes network traffic to its destination node. To create a DROP policy for these packets and to restrict internal clients from inadvertent exposure to the Internet, use the following rule:

# iptables -P FORWARD DROP

After establishing the default policies for each chain, create and save additional rules to meet your particular network and security requirements.

To save the rules so that they are loaded when the iptables service is started, use the following command:

# service iptables save

Oracle Linux System Administration 20 - 32

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 169: D74508GC10_sg2

To add a rule to a chain, use the following syntax:

iptables [-t <table>] -A <chain> <rule_specs> -j <target>

The command-line options and arguments are described as follows:• -t <table> option: Specifies the table (filter, nat, mangle). If omitted, the

filter table is used by default.

• -A <chain> option: Appends a rule to <chain>. The chain value depends on the table. If table is filter, the possible chains are INPUT, OUTPUT, and FORWARD.

• rule_specs: Specifies the rule criteria, or how to match a network packet.

• -j <target> option: Specifies the target of the rule, or what action to take if the packet matches the rule. The target value depends on the table. If table is filter, the possible targets are ACCEPT, DROP, and REJECT.

The following example allows access to TCP port 80 on the firewall:

# iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT

Because no table is defined, the rule is written to the filter table. The chain is INPUT, so the rule is applied to incoming packets. The rule_specs consists of –p tcp –m tcp –-dport 80. If information in the packet header matches the rule, the action taken is ACCEPT.

Oracle Linux System Administration 20 - 33

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Adding a Rule by Using the iptables Utility

• To add a rule to a chain, use the following syntax:– iptables [-t <table>] -A <chain> <rule_specs>

-j <target>

• Command-line options and arguments:– -t <table>: Defaults to the Filter table if omitted

– -A <chain>: Appends a rule to <chain>

– rule_specs: Specifies the rule criteria

– -j <target>: Specifies the action to take if a match occurs

• Example:– # iptables -A INPUT -p tcp -m tcp --dport 80

-j ACCEPT

– Accept incoming packets if protocol is TCP and destination port is 80 (http).

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 170: D74508GC10_sg2

The rule_specs in this example are defined as follows:

• -p tcp: Matches if the packet uses the TCP protocol. Protocol can also use the long option, --protocol. The specified protocol can be any protocol name or number listed in the /etc/protocols file. When omitted, the default is all.

• -m tcp: The -m option specifies match extensions. Match extensions are loaded implicitly when -p or --protocol is specified, or explicitly using the -m or --match option followed by the matching module name. Various extra command line options become available, depending on the specific module. The module name in this example is tcp, Use the -h or --help option after the module has been specified to receive help specific to that module. For example (the optional exclamation point [!] matches packets that do not match the criterion):

# iptables -p tcp –h

...

tcp match options:

[!] --tcp-flags mask comp match when TCP flags & mask == comp

(Flags: SYN ACK FIN RST URG PSH ALL...

[!] --syn match when only SYN flag set

(equivalent to --tcp-flags SYN, RST...

[!] --source-port port[:port]

--sport ...

match source port(s)

[!] --destination-port port[:port]

--dport ...

match destination port(s)

[!] --tcp-option number match if TCP option set

• –-dport 80: Matches if the destination port is 80.

Save any changes, so that they are loaded when the iptables service is started, using the following command:

# service iptables save

The new entry appears in the /etc/sysconfig/iptables file:

-A INPUT –p tcp –m tcp --dport 80 –j ACCEPT

The iptables -L output displays the new entry as follows:

ACCEPT tcp -- anywhere anywhere tcp dpt:http

The TCP destination port of 80 is represented as http in the output because the http daemon listens for client requests on port 80.

Oracle Linux System Administration 20 - 34

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 171: D74508GC10_sg2

The –p (or --protocol) rule specification as shown in the previous example is commonly used as match criterion. The following describes some additional rule specifications for matching a network packet. Each of the rule specs can be preceded with an exclamation point (!) to have the inverse effect, that is to match packets that do not match the criterion:

• -p, --protocol protocol: Matches if the packet uses protocol

• -s, --source address[/mask]: Matches if the packet came from address. The address can be a name or IP address and can include the optional mask with an IP address. The --src option is an alias and can also be used.

• -d, --destination address[/mask]: Matches if the packet is going to address. The address can be specified as described in the --source option. The --dst option can also be used.

• -j, --jump target: This specifies what to do if the packet matches the rule specification.

• -g, --goto chain: This specifies that the processing continues in a user specified chain.

• -i, --in-interface name: Matches if the packet came from interface name

• -o, --out-interface name: Matches if the packet is to be sent to interface name

Oracle Linux System Administration 20 - 35

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

iptables Rule Specs

• -p, --protocol protocol: Matches if the packet uses protocol

• -s, --source address[/mask]: Matches if the packet came from address

• -d, --destination address[/mask]: Matches if the packet is going to address

• -j, --jump target: Specifies what to do if the packet matches the rule specification

• -i, --in-interface name: Matches if the packet came from interface name

• -o, --out-interface name: Matches if the packet is to be sent to interface name

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 172: D74508GC10_sg2

Three iptables options have been discussed; the -A (or --append) option to add a rule to the end of a chain, the -L (or --list) option to list all rules, and the -P (or --policy) option to set the default policy. The following describes some of the other options available with the iptables command:

• -D, --delete chain rule_spec|rule_number: Removes a rule from chain. Define the rule to be removed by the rule_spec or the rule_number. To display rule numbers, use the following command:

# iptables –L --line-numbers

• -I, --insert chain rule_spec|rule_number: Inserts a rule in chain above an existing rule that is specified by the rule_spec or the rule_number. If no existing rule is specified, the rule is inserted at the beginning of the chain.

• -R, --replace chain rule_spec|rule_number: Replaces an existing rule in chain

• -F, --flush [chain]: Deletes rules in chain. If you omit the chain argument, all rules in all chains are deleted.

• -N, --new-chain chain: Creates a new user-defined chain

• -X, --delete-chain chain: Deletes a user-defined chain

Oracle Linux System Administration 20 - 36

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

More iptables Options

• -D, --delete chain rule_spec|rule_number: Removes a rule from chain

• -I, --insert chain rule_spec|rule_number: Inserts a rule in chain above an existing rule

• -R, --replace chain rule_spec|rule_number: Replaces an existing rule in chain

• -F, --flush [chain]: Deletes rules in chain

• -N, --new-chain chain: Creates a user-defined chain

• -X, --delete-chain chain: Deletes a user-defined chain

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 173: D74508GC10_sg2

NAT (Network Address Translation) is the process where a network device, usually a firewall, assigns a public address to a computer (or group of computers) inside a private network. NAT places private IP subnetworks behind one or a small pool of public IP addresses, masquerading all requests to one source rather than several. The main use of NAT is to limit the number of public IP addresses an organization or company must use, for both economy and security purposes.

The netfilter kernel subsystem provides a nat table in addition to the default filtertable to facilitate NAT. The nat table is consulted when a packet that creates a new connection is encountered. Use the iptables -t <table> option to specify the nat table when adding, deleting, replacing, or displaying rules:

# iptables –t nat ...

Whereas the built-in chains for the filter table are INPUT, OUTPUT, and FORWARD, the following built-in chains exist for the nat table:

• PREROUTING: Alters packets, such as destination address, when they arrive

• OUTPUT: Alters locally-generated packets before they are sent out

• POSTROUTING: Alters packets before they are sent out

Oracle Linux System Administration 20 - 37

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

NAT Table

• The netfilter kernel subsystem provides a nat table in addition to the default filter table to facilitate NAT.

• Use the following option to specify the nat table:– # iptables –t nat ...

• Built-in chains for the nat table:– PREROUTING: Alters packets when they arrive

– OUTPUT: Alters locally-generated packets before they are sent out

– POSTROUTING: Alters packets before they are sent out

• Targets for the nat table:– DNAT: Alters the destination IP address

– SNAT: Alters the source IP address

– MASQUERADE: Facilitates use with DHCP

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 174: D74508GC10_sg2

The targets for the filter table are DROP, ACCEPT, and REJECT. The nat table has specific targets as well:

• DNAT: Alters the destination IP address on an inbound packet so that it is routed to another hosts

• SNAT: Alters the source IP address on an outbound packet so that it appears to come from a fixed IP address, such as a firewall or router

• MASQUERADE: Differs from SNAT in that it checks for an IP address to apply to each outbound packet, making it suitable for use with DHCP

The following example specifies that the nat table use the built-in PREROUTING chain to forward incoming HTTP requests to a dedicated HTTP server at 172.31.0.23. The rule changes the destination address of the packet.

# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 172.31.0.23:80

The following example allows LAN nodes with private IP addresses to communicate with external public networks:

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

This rule masks requests from LAN nodes with the IP address of the firewall’s external device (in this case, eth0). POSTROUTING allows packets to be altered as they are leaving the firewall’s external device. The -j MASQUERADE target masks the private IP address of a node with the external IP address of the firewall/gateway.

Oracle Linux System Administration 20 - 38

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 175: D74508GC10_sg2

TCP wrappers provide basic traffic filtering of incoming network traffic. Access to “wrapped” network services running on a Linux server from other systems can be allowed or denied. A TCP wrapped service is one that has been compiled against the libwrap.a library. Use the ldd command to determine whether a network service is linked to libwrap.a. The following example determines the absolute path name of the sshd service, and then lists the shared libraries linked to the sshd service, using the grep command to search for the libwraplibrary:

# which sshd

/usr/sbin/sshd

# ldd /usr/sbin/sshd | grep libwrap

libwrap.so.0 => /lib64/libwrap.so.0 (0x00007f769e067000)

TCP wrappers rely on two configuration files as the basis for access control:• /etc/hosts.allow

• /etc/hosts.deny

When a client attempts to connect to a network service on a remote system, these files are used to determine whether client access is allowed or denied.

Oracle Linux System Administration 20 - 39

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

TCP Wrappers

• A TCP wrapper provides basic traffic filtering of incoming network traffic.

• Specifically, a TCP wrapper provides or denies access to “wrapped” network services.

• Use ldd command to determine whether a network service is wrapped (linked to libwrap.a):# ldd /usr/sbin/sshd | grep libwrap

libwrap.so.0 => /lib64/libwrap.so.0 ...

• TCP wrappers rely on two configuration files as the basis for access control:– /etc/hosts.allow– /etc/hosts.deny

• These files determine whether client access is network service is allowed or denied.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 176: D74508GC10_sg2

Use /etc/hosts.allow and /etc/hosts.deny to define rules that selectively allow or deny clients access to server daemons on local system. The format for entries is as follows for both files:

daemon_list : client_list [: command]

A description of each field follows:• daemon_list: A comma-separated list of daemons, or keyword ALL for all daemons

• client_list: A comma-separated list of clients, or keyword ALL for all clients

• command: An optional command that is executed when a client tries to access a server daemon

To allow client access, add the client host name or IP address in /etc/hosts.allow. To deny client access, add its name or IP address in /etc/hosts.deny.

The /etc/hosts.allow file is read first and is read from top to bottom. If daemon/client pair matches the first line in the file, access is granted. If the line is not a match, the next line is read and the same check is performed. If all lines are read and no match occurs, the /etc/hosts.deny file is read, starting at the top. If daemon/client pair match is found in the deny file, access is denied. If no rules for the daemon/client pair are found in either file, or if neither file exists, access to the service is granted.

Oracle Linux System Administration 20 - 40

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

TCP Wrappers Configuration

• Configuration files:– /etc/hosts.allow: Defines rules that allow client access

to server daemons– /etc/hosts.deny: Defines rules that deny client access to

server daemons

• The format for entries is the same for both files:– daemon_list : client_list [: command]

– vsftpd : 192.168.2.*

• The /etc/hosts.allow file is read first:– If the daemon/client pair matches, access is granted.– The entry in /etc/hosts.deny is ignored if the entry in

/etc/hosts.allow grants access.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 177: D74508GC10_sg2

Because access rules in hosts.allow are applied first, they take precedence over rules specified in hosts.deny. Therefore, if access to a service is allowed in hosts.allow, a rule denying access to that same service in hosts.deny is ignored.

The following are some examples of entries in the /etc/hosts.allow file:

To allow clients on the 192.168.2 subnet to access FTP (daemon is vsftpd):

vsftpd : 192.168.2.*

To allow all clients to access ssh, scp, and sftp (daemon is sshd):

sshd : ALL

Place the following entry in the /etc/hosts.deny file to deny FTP service to all clients except subnet 192.168.2.* (this assumes the previous entry of vsftpd:192.168.2.* exists in /etc/hosts.allow):

vsftpd : ALL

Use the .domain syntax to represent any hosts from a given domain. The following example allows connections to vsftpd from any host in the example.com domain (if the entry is in /etc/hosts.allow):

vsftpd : .example.com

If this entry appears in /etc/hosts.deny, the connection is denied.

Oracle Linux System Administration 20 - 41

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 178: D74508GC10_sg2

TCP wrappers are capable of more than allowing and denying access to services. With the optional command argument, they can send connection banners, warn of attacks from particular hosts, and enhance logging.

To implement a TCP Wrapper banner for a service, use the banner option. This example implements a banner for vsftpd. You need to create a banner file anywhere on the system, giving it the same name as the daemon. In this example, the file is called /etc/banners/vsftpd and contains the following lines:

220-Hello, %c

220-All activity on ftp.example.com is logged.

220-Inappropriate use results in access privileges being removed.

The %c token supplies a variety of client information. The %d token (not shown) expands to the name of the daemon that the client attempted to connect to. For this banner to be displayed to incoming connections, add the following line to the /etc/hosts.allow file:

vsftpd : ALL : banners /etc/banners/

Oracle Linux System Administration 20 - 42

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

TCP Wrapper Command Options

• Use the optional command argument to send connection banners, warn of attacks, and enhance logging.

• To display the contents of a banner file:– vsftpd : ALL : banners /etc/banners/

• To append entry to log file:– ALL : 200.182.68.0 : spawn /bin/echo `date`

%c %d >> /var/log/intruder_alert

• To elevate the logging level:– sshd : ALL : severity emerg

• To deny access from /etc/hosts.allow:– sshd : .example.com : deny

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 179: D74508GC10_sg2

TCP wrappers can warn you of potential attacks from a host or network by using the spawndirective. The spawn directive executes any shell command. In this example, access is being attempted from the 200.182.68.0/24 network. Place the following line in the /etc/hosts.deny file to deny any connection attempts from that network, and to log the attempts to a special file:

ALL : 200.182.68.0 : spawn /bin/echo `date` %c %d >> /var/log/intruder_alert

To allow the connection and log it, place the spawn directive in the /etc/hosts.allow file.

The following entry in /etc/hosts.deny denies all client access to all services (unless specifically permitted in /etc/hosts.allow) and logs the connection attempt:

ALL : ALL : spawn /bin/echo “%c tried to connect to %d and was blocked” >> /var/log/tcpwrappers.log

The log level can be elevated by using the severity option. Assume that anyone attempting to ssh to an FTP server is an intruder. To denote this, place an emerg flag in the log files instead of the default flag, info, and deny the connection. To do this, place the following line in /etc/hosts.deny:

sshd : ALL : severity emerg

This uses the default authpriv logging facility, but elevates the priority from the default value of info to emerg, which posts log messages directly to the console.

The following example states that if a connection to the SSH daemon (sshd) is attempted from a host in the example.com domain, execute the echo command to append the attempt to a special log file, and deny the connection. Because the optional deny directive is used, this line denies access even if it appears in the /etc/hosts.allow file:

sshd : .example.com \

: spawn /bin/echo `/bin/date` access denied >> /var/log/sshd.log \

: deny

Each option field (spawn and deny) is preceded by the backslash (\) to prevent failure of the rule due to length.

Refer to the man page on hosts_options for additional information and examples.

Oracle Linux System Administration 20 - 43

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 180: D74508GC10_sg2

Oracle Linux System Administration 20 - 44

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Quiz

Which of the following has a specific purpose of allowing or denying access to network services?

a. SELinuxb. chroot jail

c. iptables

d. TCP wrappers

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 181: D74508GC10_sg2

Oracle Linux System Administration 20 - 45

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Summary

In this lesson, you should have learned how to:• Describe SELinux

• Use the SELinux Administration GUI

• Describe SELinux modes, policies, Booleans, and contexts

• Use SELinux utilities• Describe the chroot jail

• Use the chroot utility

• Describe iptables

• Use the Firewall Configuration Tool• Describe iptables tables, chains, rules, and targets

• Use the iptables utility

• Describe TCP wrappers

• Configure TCP wrappers

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 182: D74508GC10_sg2

Oracle Linux System Administration 20 - 46

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Practice 20: Overview

The practices for this lesson cover the following:

• Exploring SELinux files and directories

• Using SELinux utilities

• Using the SELinux Administration GUI

• Configuring SELinux Booleans• Configuring a chroot jail for ftp users

• Configuring iptables to allow NFS mounted filesystems

• Using the Firewall Configuration GUI

• Configuring a TCP wrapper to deny OpenSSH utilities

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 183: D74508GC10_sg2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Web and Email Services

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 184: D74508GC10_sg2

Oracle Linux System Administration 21 - 2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Objectives

After completing this lesson, you should be able to:• Describe the Apache HTTP Web Server

• Configure Apache directives

• Configure Apache containers

• Configure Apache virtual hosts

• Describe email program classifications: MUA, MTA, MDA

• Describe email protocols: SMTP, POP, IMAP

• Describe the Postfix SMTP Server

• Describe the Sendmail SMTP Server

• Configure Sendmail on a client system

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 185: D74508GC10_sg2

The Apache HTTP Server, an open-source web server developed by the Apache Software Foundation, is included with Oracle Linux. The Apache server is used to host web content. It responds to requests for content from web browsers such as Internet Explorer and Firefox.

To configure your system as a web server, begin by installing the httpd software package:

# yum install httpd

Start the HTTP daemon by entering the following command:

# service httpd start

To ensure that httpd starts at boot time, enter the following command to enable the service for runlevels 2, 3, 4, and 5:

# chkconfig httpd on

The main configuration file for Apache is /etc/httpd/conf/httpd.conf. An auxiliary directory, /etc/httpd/conf.d, also exists to store configuration files that are included in the main configuration file.

Restart the httpd service after making any configuration changes. You can check for configuration errors by running the following command:

# service httpd configtest

Oracle Linux System Administration 21 - 3

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Apache HTTP Server

• Apache HTTP Web Server is included with Oracle Linux.

• Install the package:– # yum install httpd

• Start the HTTP daemon:– # service httpd start

• The main configuration file is:– /etc/httpd/conf/httpd.conf

• The auxiliary configuration directory is:– /etc/httpd/conf.d

• Check for configuration errors:– # service httpd configtest

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 186: D74508GC10_sg2

The main configuration file for Apache is /etc/httpd/conf/httpd.conf. Apache runs as installed, but you can modify configuration directives in this file to customize Apache for your environment. Some of these directives are described here. An index of all the directives is available at http://httpd.apache.org/docs/current/mod/directives.html.

Listen [IP address:]port

Tells the server to accept incoming requests on the specified port or IP address and port combination. By default, the server responds to requests on all IP interfaces on port 80. If you specify a port number other than 80, a request to the server must include the port number (as in www.example.com:8080). This is a required directive. Examples are as follows:

Listen 80

Listen 192.168.2.1:8080

ServerName FQDN[:port]

Specifies the fully qualified domain name or IP address of the server and an optional port that Apache listens on. The FQDN must be able to be resolved by DNS. If no FQDN is specified, Apache performs a DNS reverse name lookup on the IP address. If no port is specified, the server uses the port from the incoming request. An example follows:

ServerName www.example.com:80

Oracle Linux System Administration 21 - 4

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Configuring Apache

Examples of configuration directives in the configuration file:• Listen 192.168.2.1:8080

• ServerName www.example.com:80

• ServerRoot /etc/httpd

• DocumentRoot /var/www/html

• UserDir enabled oracle

• ErrorLog logs/error_log

• LoadModule auth_basic_module modules/mod_auth_basic.so

• Order deny,allow

• Deny from all

• Allow from .example.com

• Timeout 60

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 187: D74508GC10_sg2

ServerRoot directory-path

The top of the directory hierarchy under which the Apache server’s configuration, error, and log files are kept. The default is /etc/httpd. Do not add a slash at the end of directory-path:

ServerRoot /etc/httpd

DocumentRoot directory-path

The top of the directory hierarchy that holds the Apache server content. Do not end the path name with a slash. The apache user needs read access to any files and execute access to the directory and any sub-directories in the hierarchy. The following is the default:

DocumentRoot /var/www/html

UserDir directory-path | disabled | enabled user-list

Allows users identified by the user-list argument to publish content from their home directories. The directory-path is the name of a directory in a user’s home directory from which Apache publishes content. If directory-path is not defined, the default is ~/public_html. The following example enables this feature for user oracle. Assuming that the ServerName is www.example.com, browsing to http://www.example.com/~oracle displays the oracle user’s webpage.

UserDir enabled oracle

ErrorLog filename | syslog[:facility]

Specifies the name of the file, relative to ServerRoot, that Apache sends error messages to. Alternatively, syslog specifies that Apache send errors to rsyslogd. The optional facilityargument specifies which rsyslogd facility to use. The default facility is local7.

ErrorLog logs/error_log

LoadModule module filename

Apache, like the Linux kernel, uses external modules to extend functionality. These modules are called dynamic shared objects (DSOs). The module argument is the name of the DSO and filename is the path name of the module, relative to ServerRoot. There are over 60 modules included with Apache, and over 50 of these are loaded by default.

LoadModule auth_basic_module modules/mod_auth_basic.so

Allow from All | host [host ...]

Specifies which clients can access content. All serves content to any client. Alternatively, you can list the specific hosts that are allowed access to content.Deny from All | host [host ...]

Specifies which clients are not allowed access to content.Order deny,allow | allow,deny

Specifies the order in which Allow and Deny directives are evaluated. deny,allow evaluates deny directives first, then evaluates allow directives. The following example grants access to clients from the example.com domain only, by first denying access to all and then allowing it from .example.com:

Order deny,allow

Deny from all

Allow from .example.com

Timeout num

Specifies the number of seconds Apache waits for network operations to finish. The default is 60.

Oracle Linux System Administration 21 - 5

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 188: D74508GC10_sg2

You can confirm that Apache is working by pointing a browser on the local system to http://localhost as shown. From a remote system, point a browser to http:// followed by the ServerName directive that you specified in the configuration file. The test page, shown in the slide, confirms that Apache is working correctly.

To test the display of actual content, create an HTML file named index.html in the directory specified by the DocumentRoot directive (the default directory is /var/www/html). Apache automatically displays the index.html file in this directory, if it exists.

Oracle Linux System Administration 21 - 6

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Testing Apache

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 189: D74508GC10_sg2

Apache containers are special configuration directives that group other directives. Containers use XML-style tags, meaning that the beginning of a container is <name> and the end is </name>. The following are examples of containers:

<Directory directory-path>

This container applies directives to directories within directory-path. The example applies Deny, Allow, and AllowOverride directives to all files and directories within the /var/www/html/test directory hierarchy. Indenting is for readability only.

<Directory /var/www/html/test>

Deny from all

Allow from 192.168.2.

AllowOverride All

</Directory>

The AllowOverride directive in this container specifies classes of directives that are allowed in .htaccess files. .htaccess files are other configuration files that typically contain user authentication directives. The ALL argument to AllowOverride means that all classes of directives are allowed in .htaccess files. There are classes of directives that control authorization, control client access, control directory indexing, and others.

Oracle Linux System Administration 21 - 7

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Apache Containers

• Containers are special directives that group other directives.

• <Directory directory-path>:

– Applies directives to directories within directory-path

• <IfModule module-name>

– Applies directives if module-name is loaded

• <Limit method>

– Limits access control directives to specified methods

• Containers can be nested.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 190: D74508GC10_sg2

<IfModule [!]module-name>

This container applies directives if module-name is loaded. With the optional exclamation point, Apache does the inverse, that is it sets the directives in the container if the module-name is not loaded. An example is as follows:

<IfModule mod_userdir.c>

UserDir disabled

</IfModule>

<Limit method [method] …>

This container limits access control directives to specified methods. An HTTP method specifies actions to perform on a URI (Uniform Resource Identifier). Examples of methods are GET, (the default), PUT, POST, and OPTIONS. The following example disables HTTP uploads (PUT) from systems that are not in the example.com domain:

<Limit PUT>

Order deny,allow

Deny from all

Allow from .example.com

</Limit>

<LimitExcept method [method] …>

This container is the opposite of the Limit container in that it limits access control directives to all except specified methods.The following example uses the LimitExcept container but also illustrates that containers can be nested. This example controls access to UserDir directories by restricting these directories to be read-only:

<Directory /home/*/public_html>

AllowOverride FileInfo AuthConfig Limit

Options MultiViews Indexes SymLinksIfOwnerMatch \IncludesNoExec

<Limit GET POST OPTIONS>

Order allow,deny

Allow from all

</Limit>

<LimitExcept GET POST OPTIONS>

Order deny,allow

Deny from all

</LimitExcept>

</Directory>

The Options directive controls server features by directory. Some of these are described:

• MultiViews: Allows a page to be displayed in different languages for example

• Indexes: Generates a directory listing if the DirectoryIndex directive is not set

• SymLinksIfOwnerMatch: Follows symbolic links if the file or directory being pointed to has the same owner as the link

Oracle Linux System Administration 21 - 8

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 191: D74508GC10_sg2

Apache supports virtual hosts, meaning that a single Apache server can respond to requests directed to multiple IP addresses or host names. Each virtual host can provide different content and be configured differently.

You can configure virtual hosts in two ways:

• IP-based Virtual Hosts (host-by-IP)

• Name-based Virtual Hosts (host-by-name)

With host-by-IP, each virtual host has its own IP address and port combination. The Apache web server responds to the IP address that the host resolves as. Host-by-IP is required for serving HTTPS requests due to restrictions in the SSL (Secure Sockets Layer) protocol.

With host-by-name, all virtual hosts share the common IP address. Apache responds to the request by mapping the host name in the request to ServerName and ServerAliasdirectives in the particular virtual host’s configuration file.

Use the <VirtualHost host-name> container to implement virtual hosts. After the first VirtualHost is defined, all of the content served by Apache must also be moved into virtual hosts.

Oracle Linux System Administration 21 - 9

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Apache Virtual Hosts

• A single Apache server can respond to requests directed to multiple IP addresses or host names.

• Each virtual host can provide different content and be configured differently.

• Use the <VirtualHost host-name> container:<VirtualHost www.example1.com>

ServerName www.example1.com

DocumentRoot /var/www/example1

ErrorLog example1.error_log

</VirtualHost>

<VirtualHost www.example2.com>

...

</VirtualHost>

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 192: D74508GC10_sg2

The following example is a simple name-based virtual hosts configuration:

NameVirtualHost *:80

<VirtualHost *:80>

ServerName example1.com

ServerAlias www.example1.com

DocumentRoot /var/www/example1

ErrorLog example1.error_log

</VirtualHost>

<VirtualHost *:80>

ServerName example2.com

ServerAlias www.example2.com

DocumentRoot /var/www/example2

ErrorLog example2.error_log

</VirtualHost>

Oracle Linux System Administration 21 - 10

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 193: D74508GC10_sg2

Oracle Linux System Administration 21 - 11

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Quiz

On which port does Apache listen for client requests by default?

a. 443

b. 8080

c. 80

d. 280

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 194: D74508GC10_sg2

An email message is created by a mail client program called an MUA (Mail User Agent) and delivered to the recipient’s email server by MTAs (Mail Transfer Agents). From here, an MDA (Mail Delivery Agent) puts the message in the recipient’s mailbox file.

Mail User Agent (MUA)An MUA is an email client application that allows you to create and read email messages, set up mailboxes to store and organize messages, and send outbound messages to an MTA. Many MUAs can also retrieve email messages from remote servers using POP (Post Office Protocol) or IMAP (Internet Message Access Protocol).

Mail Transfer Agent (MTA)An MTA transports email messages between systems by using SMTP (Simple Mail Transport Protocol). It provides mail delivery services from a client program to a destination server, possibly traversing several MTAs along the way. Oracle Linux offers two MTAs, Postfix and Sendmail, and also includes a special purpose MTA called Fetchmail.

Mail Delivery Agent (MDA)An MDA, such as Procmail, is invoked by the MTA to put incoming email in the recipient’s mailbox file. MDAs perform the actual delivery. They distribute and sort messages on the local system for an email client application to access.

Oracle Linux System Administration 21 - 12

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Email Program Classifications

• MUA (Mail User Agent):– An email client application to create and read email

messages– Some MUAs are capable of sending outbound messages to

MTA.– Some MUAs are capable of retrieving messages from

remote servers using POP or IMAP.

• MTA (Mail Transfer Agent):– An email server that transports email messages by using

SMTP– Examples: Sendmail, Postfix, Fetchmail

• MDA (Mail Delivery Agent):– Invoked by MTA– Puts incoming email in the recipient’s mailbox file– Examples: Procmail or mail

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 195: D74508GC10_sg2

Several different network protocols are required to deliver email messages. These protocols work together to allow different systems, often running different operating systems and different email programs, to send and receive email. The most commonly used protocols used to transfer email are described here:

SMTP (Simple Mail Transfer Protocol)SMTP is considered to be a transport protocol (an MTA), as opposed to an email access protocol. It provides mail delivery services from a client program to a server, and from an originating server to the destination server. You must specify the SMTP server when configuring the client program. You can also specify a remote SMTP server for outgoing email.

SMTP does not require authentication. Anyone can send anyone email, including junk email, also known as spam or unsolicited bulk email. You can configure relay restrictions that limit users from sending email through your SMTP server. Servers without any restrictions are called open relay servers.

The SMTP programs provided by Oracle Linux are Postfix and Sendmail. Because these programs use SMTP, they are often referred to as SMTP server programs.

Oracle Linux System Administration 21 - 13

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Email Protocols

• SMTP (Simple Mail Transfer Protocol):– This is a transport protocol (an MTA).

– Specify the SMTP server when configuring the client program.

– Configure relay restrictions to limit junk email.

• POP (Post Office Protocol):– An email access protocol

– Used by client programs to retrieve email messages

• IMAP (Internet Message Access Protocol):– This is similar to POP.

– Email is kept on the server when using IMAP.

• POP and IMAP services are provided by the dovecotpackage.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 196: D74508GC10_sg2

POP (Post Office Protocol)POP is an email access protocol used by client programs to retrieve email messages from remote servers. Users on client systems usually have an email account on a server run by their employer or an ISP (Internet Service Provider). On Linux systems, the MUA on the receiving system either reads the mailbox file or retrieves the email from a remote SMTP server, using POP or IMAP. Unless you own a domain at which you want to receive email, you do not need to set up Sendmail as an incoming SMTP server.

IMAP (Internet Message Access ProtocolIMAP is similar to POP in that it is an email access protocol used to retrieve email remotely. The IMAP server is provided by the same dovecot package that provides the POP server. There are no new software packages to install.

While POP email clients typically delete the message on the server after it has been successfully retrieved, email is kept on the server when using IMAP. The entire message is downloaded only when it is opened. Messages can be read or deleted while still on the server. Both POP and IMAP allow you to manage mail folders and create multiple mail directories to organize and store email.

Oracle Linux includes the dovecot package to implement both the POP and IMAP protocols. To install the package:

# yum install dovecot

Start the daemon by entering the following command:

# service dovecot start

To ensure that the service starts when booting to multi-user mode:

# chkconfig dovecot on

By default, dovecot runs IMAP and POP together with their secure versions using SSL (Secure Socket Layer) encryption for client authentication and data transfer sessions. When starting dovecot, it reports that it started the IMAP server but it also starts the POP server. The servers provided by dovecot are configured to work as installed. You typically do not need to modify the configuration file, /etc/dovecot.conf. Refer to /usr/share/doc/doc/dovecot* for more information.

Oracle Linux System Administration 21 - 14

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 197: D74508GC10_sg2

Postfix and Sendmail are two MTAs (SMTP servers) included with Oracle Linux. Postfix is configured as the default MTA. It is easier to administer than Sendmail, but does not include as many features. Postfix has a modular design that consists of a master daemon and several smaller processes. It stores its configuration files in the /etc/postfix directory. Some of the configuration files are described. Refer to www.postfix.org for complete documentation.• access: This file is used for access control and specifies which hosts are allowed to

connect to Postfix.

• main.cf: This is the global Postfix configuration file in which most of the configuration options are specified.

• master.cf: This file specifies how the Postfix master daemon interacts with the smaller processes to deliver email.

• transport: This file maps email addresses to relay hosts.

By default, Postfix does not accept network connections from any system other than the local host. To enable mail delivery for other hosts, edit the /etc/postfix/main.cf file and configure the domain, host name, and network information for the other hosts. Restart the service after making any configuration changes:

# service postfix restart

Oracle Linux System Administration 21 - 15

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Postfix SMTP Server

• The default MTA with Oracle Linux• The main configuration files are in the /etc/postfix

directory:– access: Specifies which hosts can connect to Postfix

– main.cf: The global Postfix configuration file

– master.cf: Specifies how Postfix processes interact

– transport: Maps email addresses to relay hosts

• Restart the service after making any configuration changes:– # service postfix restart

• Refer to www.postfix.org for complete documentation.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 198: D74508GC10_sg2

Sendmail is also included with Oracle Linux. It is one of the oldest and most commonly used MTAs on the Internet. The main purpose of Sendmail is to transfer email between systems, but it is highly configurable and capable of controlling almost every aspect of how email is handled.

To use Sendmail, install the following packages. The sendmail-cf package is required to configure Sendmail. The procmail package is installed as a dependency. In the default setup, the Sendmail MTA uses Procmail as the local MDA. The Procmail application writes email to the recipient’s mailbox file.

# yum install sendmail sendmail-cf

The Sendmail configuration files are located in /etc/mail. The main configuration file is sendmail.cf, but it is not intended to be edited by using a text editor. Make any configuration changes in the sendmail.mc file and then generate a new sendmail.cf file by restarting the sendmail service:

# service sendmail restart

You can also run the following make command, which calls the Makefile file in the /etc/mail directory and regenerates mail configuration files that have been modified.

# make all –C /etc/mail

Oracle Linux System Administration 21 - 16

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Sendmail SMTP Server

• An MTA included with Oracle Linux

• One of the oldest and most common MTAs on the Internet

• Install two packages:– # yum install sendmail sendmail-cf

• Configuration files are located in /etc/mail:– sendmail.mc: Is the main configuration file

– access: Specifies a relay host

– virtusertable: Serves email to multiple domains

– mailertable: Forwards email from one domain to another

• You must regenerate the configuration files after editing:– # service sendmail restart

– # make all –C /etc/mail

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 199: D74508GC10_sg2

Some of the other configuration files in the /etc/mail directory are described here:

• access: This file sets up a relay host. A relay host processes outbound mail for other systems. The default configuration is to only relay mail from the local host:

Connect: localhost.localdomain RELAY

Connect: localhost RELAY

Connect: 127.0.0.1 RELAY

To configure your system to relay mail from other systems, for example the 192.168subnet, add the following entry:

Connect: 192.168 RELAY

• virtusertable: This file serves email to multiple domains. Each line starts with the address that the email was sent to, followed by the address Sendmail forwards the email to. For example, the following entry forwards email addressed to any user at foo.org to the same username at example.com:

@foo.org %[email protected]

• mailertable: This file forwards email from one domain to another. The following example forwards email sent to the foo.org domain to the SMTP server for the example.com domain:

foo.org smtp:[example.com]

The configuration files in the /etc/mail directory have corresponding .db files. Example:

# ls /etc/mail/*table*

domaintable mailertable virtusertable

domaintable.db mailertable.db virtusertable.db

Make any configuration changes to the files without extensions. Sendmail uses the .db files, however. To update or re-generate the .db files for Sendmail, either restart the sendmailservice or run the make command after making any configuration changes.

/etc/aliases

The /etc/aliases file can also be used to forward incoming email messages. Use the file to map inbound addresses to local users, files, commands, and remote addresses. The following example forwards mail sent to admin on the local system to several users, including user4, who is on a different system:

admin: user1, user2, user3, [email protected]

To direct email to a file, specify the absolute path name of the file in place of the destination address.

Oracle Linux System Administration 21 - 17

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 200: D74508GC10_sg2

Sendmail on a client system simply relays outbound mail to an SMTP server. A remote SMTP server, typically an ISP, relays outbound email to its destination. The following example configuration only sends email to the SMTP server that originates on the local system. It does not forward email originating from other systems. This configuration does not handle inbound email either. Client systems normally use POP or IMAP to receive email.

To configure the system as described, locate the following entry in the main email configuration file, /etc/mail/sendmail.mc:

dnl define(`SMART_host’, ‘smtp.your.provider’)dnl

The dnl at the beginning of the line is a comment. Delete these characters. Replace “smtp.your.provider” with the FQDN of your ISP’s SMTP server. You can choose to delete the dnl characters at the end of the line, or not delete them. Assuming that your ISP’s SMTP server is smtp.isp.com, change the line to appears as follows:

define(`SMART_host’, ‘smtp.isp.com’)dnl

Restart the sendmail service, which regenerates the sendmail.cf file.

# service sendmail restart

To test, send an email message to an account that you have on a remote server to ensure that sendmail is relaying your email.

Oracle Linux System Administration 21 - 18

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Configuring Sendmail on a Client

• Sendmail on a client system simply relays outbound mail to an SMTP server.

• A remote SMTP server, typically an ISP, relays email to its destination.

• Edit the following line in /etc/mail/sendmail.mc:– dnl define(`SMART_host’,

‘smtp.your.provider’)dnl

• Remove the dnl at the beginning of the line.

• Include the ISP’s SMTP server name:– define(`SMART_host’, ‘smtp.isp.com’)dnl

• Restart the sendmail service:– # service sendmail restart

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 201: D74508GC10_sg2

Oracle Linux System Administration 21 - 19

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Quiz

Sendmail is an example of what type of email program classification?

a. MUA

b. MTA

c. MDA

d. MMA

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 202: D74508GC10_sg2

Oracle Linux System Administration 21 - 20

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Summary

In this lesson, you should have learned how to:

• Describe the Apache HTTP Web Server

• Configure Apache directives

• Configure Apache containers

• Configure Apache virtual hosts

• Describe email program classifications: MUA, MTA, MDA

• Describe email protocols: SMTP, POP, IMAP

• Describe the Postfix SMTP Server

• Describe the Sendmail SMTP Server

• Configure Sendmail on a client system

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 203: D74508GC10_sg2

Oracle Linux System Administration 21 - 21

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Practice 21: Overview

The practices for this lesson cover the following:

• Configuring Apache web server

• Creating a test webpage

• Configuring two Apache virtual hosts

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 204: D74508GC10_sg2

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 205: D74508GC10_sg2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

System Monitoring and Troubleshooting

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 206: D74508GC10_sg2

Oracle Linux System Administration 22 - 2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Objectives

After completing this lesson, you should be able to:• Use the sosreport utility

• Set up kdump from the GUI and from the command line• Use the netdump utility

• Use the iostat, mpstat, vmstat, sar, top, iotop, and strace utilities

• Use the netstat and tcpdump utilities

• Use the OSWatcher Black Box (OSWbb) tool

• Describe Enterprise Manager Ops Center

• Describe Performance Counters for Linux (PCL) and the perf tool

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 207: D74508GC10_sg2

The sosreport tool collects information about a system, such as hardware configuration, installed software packages, configuration, and operational state. You can also enable diagnostics and analytical functions. This information is stored in a single compressed file in the /tmp directory, and the file can be sent to a support representative to assist in troubleshooting a problem. The sosreport tool replaces an earlier version of the tool called sysreport.

To run the tool, first install the sos package:

# yum install sos

Run the report as the root user. The version of the tool is display along with a short description of the tool and the output it produces. You are prompted to press Enter to continue or Ctrl + C to quit.

# sosreport

...

Press ENTER to continue, or CTRL-C to quit.

Press Enter to start. You are prompted as follows:

Please enter your first initial and last name [host03]:

Please enter the case number you are generating this report for:

Oracle Linux System Administration 22 - 3

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

sosreport Utility

• The sosreport utility:– Collects debugging information about a system– Stores the information in a single compressed file in /tmp

• Run the tool as follows:# sosreport...Press ENTER to continue, or CTRL-C to quit.Please enter your first initial and last name:Please enter the case number...:

• sosreport uses plug-ins. Options exist to manage plug-ins:– -l: List the status of all available plug-ins.– -n PLUGNAME: Do not load specified plug-in(s).– -e PLUGNAME: Enable the specified plug-in(s).

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 208: D74508GC10_sg2

The name and case number that you provide becomes part of the file name created by the tool. After the tool completes, you can uncompress the file and view the contents, by doing the following:

# cd /tmp

# xz -d <sosfile>.xz

# tar xvf <sosfile>.tar

Extracting the file creates a directory, which includes the output of several system status commands as well as the contents of some configuration directories on your system. The following is a sample list of the output collected on a system named host03:

# ls /tmp/host03*

boot/ etc/ java lspci pstree

sos_commands/ uptime chkconfig free lib/

mount root/ sos_logs/ var/ date

hostname lsb-release netstat route sos_reports/

vgdisplay df ifconfig lsmod proc/

sar18 sys/ dmidecode installed-rpms

lsof ps sestatus uname

The sosreport uses plug-ins, which can be turned on and off. Use the following command to list the plug-ins, which are enabled and disabled, and plug-in options:

# sosreport –l

The following plugins are currently enabled:

acpid acpid related information

anaconda Anaconda / Installation information

...

The following plugins are currently disabled:

amd Amd automounter information

cluster cluster suite and GFS related information

...

The following plugin options are available:

apache.log off gathers all apache logs

auditd.syslogsize 15 max size (MiB) to collect per syslog file

...

Additional options exist to control the plug-ins and the tool. The following is a partial list:• -n PLUGNAME: Do not load specified plug-in(s).

• -e PLUGNAME: Enable the specified plug-in(s).

• -o PLUGNAME: Enable only the specified plug-in(s), disable all others.

• -k PLUGNAME.PLUGOPT=[VALUE]: Specify options for plug-ins.

• --upload FTP_SERVER: Upload the report to Oracle.

• -a: Enable all (Boolean) options for all loaded plug-ins.

• --diagnose: Turn on diagnostic functions.

Oracle Linux System Administration 22 - 4

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 209: D74508GC10_sg2

Kdump is the Linux kernel crash dump mechanism. In the event of a system crash, kdumpprovides a memory dump (vmcore) image. This image can assist in determining the cause of the crash. It is highly recommended that you enable the kdump feature.

Enabling kdump requires you to reserve a portion of the system memory. This portion of memory is unavailable for other uses. You have the option to enable kdump and select an amount of memory to reserve during Firstboot. Firstboot is the program that runs after a successful installation of Oracle Linux.

To enable and use kdump after the initial installation, install the following package:

# yum install kexec-tools

kexec is a fastboot mechanism, which allows booting a Linux kernel from the context of an already running kernel without going through BIOS. Kdump uses kexec to boot into a second kernel whenever the system crashes.

You can enable kdump from the command line or from a GUI. Enter the following command to use the Kernel Dump Configuration GUI:

# system-config-kdump

The GUI appears, as shown in the slide. Click the Enable button to start the kdump daemon at boot time for runlevels 2, 3, 4, and 5.

Oracle Linux System Administration 22 - 5

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Kdump Setup Configuration GUI

system-config-kdump

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 210: D74508GC10_sg2

Four tabs appear on the left side of the GUI. The Basic Settings tab allows you to select the amount of memory to reserved for kdump.

Use the Target Settings tab to specify the target location for the vmcore dump. You can store the dump image in a local file system or store it remotely using NFS or SSH. The default is to store the vmcore file in the /var/crash directory of the local file system. The following targets are supported:

• Raw device: All locally attached raw disks and partitions

• Local file system: Any ext2, ext3, ext4, or minix file system on directly attached disk drives, hardware RAID logical drives, LVM devices, and mdraid arrays

• Remote directory: Remote directories accessed using NFS or SSH over IPv4 and remote directories accessed using iSCSI over hardware initiators

Unsupported targets include:

• Local file system: The eCryptfs file system

• Remote directory: Remote directories on the rootfs file system accessed using NFS, remote directories accessed using iSCSI over software initiators, remote directories accessed over IPv6, remote directories accessed using SMB/CIFS or FCoE (Fibre Channel over Ethernet), remote directories accessed using wireless NICs, and multipath-based storages

The Filtering Settings tab allows you to select the filtering level for the vmcore dump. You can choose to exclude any or all of the following from the dump:

• zero page

• cache page

• cache private

• user data

• free page

The Expert Settings tab allows you to choose which kernel and initial RAM disk to use. From this tab you can also customize the options that are passed to the kernel and the core collector program. And you can choose what to do when the kernel crash is captured. The following options are available:• mount rootfs and run /sbin/init: This is the default action.

• reboot: Reboot the system.

• shell: Present a user with an interactive shell prompt.

• halt: Halt the system.

• poweroff: Power the system off.

Click Apply to save any changes.

Oracle Linux System Administration 22 - 6

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 211: D74508GC10_sg2

When you enable kdump from the GUI, the amount of memory that is reserved for the kdumpkernel is represented by the crashkernel option. This is appended to the kernel line in the GRUB configuration file, /boot/grub/grub.conf. For example, enabling kdump from the GUI and reserving 128 MB of memory results in the following modification to the kernel entry:

kernel /vmlinuz-2.6.39-100.5.1.el6uek ... crashkernel=128M

This implies that you can configure kdump from the command line simply by editing the GRUB configuration file and appending the crashkernel=<size>M parameter to the list of kernel options.

In addition to reserving memory, you can designate the starting address (offset) of this reserved memory. For example, adding the following option to the kernel line reserves 128 MB of memory, starting at physical address 0x01000000 (16 MB):

crashkernel=128M@16M

If kdump fails to start, the following error appears in /var/log/messages:

kdump: No crashkernel parameter specified for running kernel

In this case, set the offset to 48M or higher:

crashkernel=128M@48M

Oracle Linux System Administration 22 - 7

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Kdump Setup Using the Command Line

• Append the crashkernel option to the kernel line in /boot/grub/grub.conf:– kernel /vmlinuz-2.6.39 ... crashkernel=128M

– kernel /vmlinuz-2.6 ... crashkernel=128M@16M

• Specify the target location in /etc/kdump.conf:– path /

– ext4 UUID=bff248...

– raw /dev/sda1

– net host01.example.com:/export/crash

• Specify the filtering level in /etc/kdump.conf:– core_collector makedumpfile -d 17 –c

• Specify the action to perform in /etc/kdump.conf:– default reboot

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 212: D74508GC10_sg2

If you have more than 128 GB RAM, use the following setting:

crashkernel=512M@64M

A setting used by the Red Hat Compatible Kernel (RHCK), crashkernel=auto, is not supported for the Unbreakable Enterprise Kernel (UEK). Using this setting causes the kdump service to fail to start.

Specifying the target location for the vmcore dump from the GUI results in updating the /etc/kdump.conf configuration file. The default target location is the /var/crash directory on the local file system represented by the following entry:

path /var/crash

To change the target location from the command line, edit this file and specify the new target.

To write to a different local directory, edit the path directive and provide the directory path. To write to a different partition, specify the type of file system followed by an identifier. Example:

path /

ext4 UUID=bff248...

To write directly to a device, edit the raw directive and specify the device name. Example:

raw /dev/sda1

To write to a remote system by using NFS, use the net directive followed by the FQDN of the remote system, then a colon (:), and then the directory path. Example:

net host01.example.com:/export/crash

To write to a remote machine by using SSH, use the net directive followed by a valid username, the @ sign, and the host name, in that order. Example:

net [email protected]

Selecting the filtering level for the vmcore dump from the GUI also modifies the /etc/kdump.conf file. You can select the filtering level from the command line by modifying the core_collector directive in this file. To exclude certain pages from the dump, use the -d <value> parameter where <value> is a sum of values of pages that you want to exclude. Use the following values for the pages:

• 1: zero page

• 2: cache page

• 4: cache private

• 8: user data

• 16: free page

For example, to exclude all these pages, add the values (the total for all is 31) and provide the sum as the argument:

core_collector makedumpfile -d 31 –c

The -c option enables dump file compression. To exclude only zero (1) and free (16) pages:

core_collector makedumpfile -d 17 –c

By default, when the kernel crash is captured, the root file system is mounted and /sbin/init runs. To change this, set the default directive in /etc/kdump.conf to reboot, halt, poweroff, or shell. Example:

default reboot

Oracle Linux System Administration 22 - 8

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 213: D74508GC10_sg2

Under a few specific circumstances, Oracle Clusterware might evict a cluster, resulting in a kernel panic. This is to prevent a node from trying to update data without proper synchronization. Loss of heartbeat in a shared disk subsystem can also cause a panic. Oracle Cluster File System Version 2 (OCFS2) causes a panic if the communication is lost to the cluster or to the shared disk subsystem.

When the Linux kernel detects a problem, it prints an oops message and kills any offending process. An oops is a deviation from correct behavior of the kernel that produces a certain error log. Diagnosing the cause of a panic requires that the messages sent by the kernel be captured for analysis. If the serial console is overwhelmed or the disks are not responding, then these messages can be lost.

The netdump utilities allow you to configure a netdump server that listens on the network for crashed kernels to contact it. The server then writes the oops log and a memory dump to /var/netdump/crash before asking the crashed machine to reboot. The system that crashes is a netdump client.

Configuring a netdump ServerThe netdump server is the location where the failing machine writes the dump file and associated messages. Install the netdump-server package on the server.

Oracle Linux System Administration 22 - 9

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

netdump Utility

• A kernel crash log is written to a server on the network.• A netdump server listens on the network for crashed

kernels to contact it.

• Configure the server:– Install the netdump-server package.

– # service netdump-server start

– # passwd netdump

• Configure the client:– Install the netdump package.

– Edit /etc/sysconfig/netdump.— NETDUMPADDR=<netdump-server IP>

– # service netdump propagate

– # service netdump start

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 214: D74508GC10_sg2

There is no netdump-server package in the base OL6 repository. You can get it from EPEL (Extra Packages for Enterprise Linux) at:

http://dl.fedoraproject.org/pub/epel/6/x86_64/repoview/netdump-server.html

After installing the server package, start the server by using the following command:

# service netdump-server start

You must then set the netdump user password by entering the following command as root:

# passwd netdump

Changing password for user netdump.

New UNIX password: *******

Retype new UNIX password: ******

passwd: all authentication tokens updated successfully.

Set up netdump-server to start at boot time by entering the following command:

# chkconfig netdump-server on

Configuring a netdump ClientInstall the netdump-<version>.rpm on the client machine. Edit the configuration file, /etc/sysconfig/netdump and set the NETDUMPADDR directive to the IP address of the netdump server. Example:

NETDUMPADDR=<netdump-server IP>

To allow the netdump client to connect to the netdump server, propagate the key by running the following command (be prepared to provide the netdump user password):

# service netdump propagate

The authenticity of host ... can't be established

RSA key fingerprint is ...

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ... (RSA) to the list of known hosts.

netdump@... password:*****

Set up the netdump client to start at boot as follows:

# chkconfig netdump on

Start the netdump client service as follows:

# service netdump start

initializing netdump [ OK ]

initializing netconsole [ OK ]

...

Notice that the netconsole service is started with netdump client. This module provides logging of kernel events over UDP allowing debugging of problem where disk logging fails and serial consoles are impractical.

Oracle Linux System Administration 22 - 10

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 215: D74508GC10_sg2

The iostat command is used for monitoring system input/output device loading by observing the time that the physical disks are active in relation to their average transfer rates. This information can be used to change system configuration to better balance the input/output load between physical disks and adapters.

# iostat

Linux 2.6.39-100.5.1.el6uek.x86_64 (host03.example.com) 04/21/2012 _x64_64_ (1 CPU)

avg-cpu: %user %nice %system %iowait %steal %idle

25.99 0.78 7.43 12.77 0.00 53.03

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn

xvda 27.40 797.19 201.27 800902 202208

xvdb 0.03 1.24 0.00 1248 0

The first line displays the Linux kernel version, host name, current date, architecture, and number of CPUs on your system.

Oracle Linux System Administration 22 - 11

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

iostat Utility

• The iostat utility:– Reports CPU and I/O statistics– Is used during performance analysis to balance I/O load

• The iostat utility report has the following sections:– CPU Utilization– Device Utilization– NFS statistics

• Include the -x option for extended statistics:– # iostat –x

• Execute iostat continuously at a specific interval, up to count times:– # iostat interval count

• For example, to run iostat every 10 seconds for 5 times:– # iostat 10 5

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 216: D74508GC10_sg2

CPU Utilization ReportThe next two lines display CPU statistics. For multiprocessor systems, the CPU values are global averages among all processors. The columns are defined as follows:

• %user: The percentage of CPU used while executing applications at the user level

• %nice: The percentage of CPU used while executing at the user level with nice priority

• %system: The percentage of CPU used while executing at the system (kernel) level

• %iowait: The percentage of time the CPU(s) were idle while the system had an outstanding disk I/O request

• %steal: The percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor

• %idle: The percentage of time that the CPU was (or the COUs were) idle and the system did not have an outstanding disk I/O request

Device Utilization ReportThe remaining lines in the example display statistics on a per physical device or per partition basis. You can include block devices and partitions as arguments to the iostat command. If no arguments are included, the report displays all devices that the kernel has statistics for. The columns are defined as follows:

• Device: The device or partition name as listed in the /dev directory

• tps: The number of transfers (I/O request) per second issued to the device

• Blk_read/s: The amount of data read from the device expressed in the number of blocks per second. Block size with kernels 2.4 and later are 512 bytes.

• Blk_wrtn/s: The amount of data written to the device expressed in the number of blocks per second

• Blk_read: The total number of blocks read

• Blk_wrtn: The total number of blocks written

Network File system ReportThe example does not include NFS statistics, but iostat also provides statistics for each mounted network file system. This section displays the host name of the NFS server followed by the directory name where the file system in mounted. Read and write information is displayed for each file system, depending on the command-line options provided.

More detailed statistics can be included by providing different options to the iostat command. Some of the command-line options are listed:

• -c: Display the CPU utilization report.

• -d: Display the device utilization report.

• -n: Display the network file system (NFS) report.

• -k: Display statistics in kilobytes per second instead of blocks per second.

• -x: Display extended statistics.

Multiple reports can be run at different intervals using interval and count arguments. The following example displays 6 reports at 2 second intervals for all devices:

# iostat –d 2 6

Oracle Linux System Administration 22 - 12

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 217: D74508GC10_sg2

The mpstat command collects and displays performance statistics for all logical CPUs in the system. When a CPU is occupied by a process, it is unavailable for processing other requests. These other processes must wait until the CPU is free. The mpstat command provides CPU usage to help you identify CPU-related performance problems.

# mpstat

Linux 2.6.39-100.5.1.el6uek.x86_64 (host03.example.com) 04/21/2012 _x64_64_ (2 CPUs)

07:44:18 CPU %user %nice %system %iowait %irq %soft %idle intr/s

07:44:18 all 3.01 57.31 0.36 0.13 0.01 0.00 39.19 1063.46

07:44:18 0 5.87 69.47 0.44 0.05 0.01 0.01 24.16 262.11

07:44:18 1 1.79 48.59 0.36 0.23 0.00 0.00 49.02 268.92

The first line displays the Linux kernel version, host name, current date, architecture, and number of CPUs on your system.

Oracle Linux System Administration 22 - 13

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

mpstat Utility

• The mpstat utility:– Collects and displays performance statistics for all CPUs

– Is used during performance analysis to determine CPU utilization

• Use the -P ALL option to include average usage of all CPUs:– # mpstat –P ALL

• Execute continuously at a specific interval, up to counttimes:– # mpstat interval count

• For example, to run mpstat every 2 seconds for 5 times:– # mpstat 2 5

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 218: D74508GC10_sg2

The first column is a time stamp. The remaining columns are defined as follows:

• CPU: Processor number starting at 0. The keyword all indicates that statistics are calculated as averages among all processors.

• %user: The percentage of CPU used while executing at the user level

• %nice: The percentage of CPU used while executing at the user level with nice priority

• %system: The percentage of CPU used while executing at the system (kernel) level. This does not include time spent servicing hardware and software interrupts.

• %iowait: The percentage of time the CPU was (or the COUs were) idle during which the system had an outstanding disk I/O request

• %irq: The percentage of time spent by the CPU(s) to service hardware interrupts

• %soft: The percentage of time spent by the CPU(s) to service software interrupts

• %idle: The percentage of time that the CPU was (or the COUs were) idle and the system did not have an outstanding disk I/O request

• %intr/s: The total number of interrupts received per second by the CPU(s)

Similar to the iostat utility, mpstat allows multiple reports to run at different intervals. Use the following arguments:

# mpstat interval count

If you omit the count argument, the report runs at interval continuously. Press Ctrl + C to stop the report. The following example displays a report every 3 seconds, until terminated by pressing Ctrl + C:

# mpstat 3

The -P option followed by the keyword ALL displays statistics for processors. To report on a specific CPU, include the processor number as an argument to -P. The following displays 5separate reports at 2 second intervals of all processors, and includes an average line:

# mpstat –P ALL 2 5

Oracle Linux System Administration 22 - 14

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 219: D74508GC10_sg2

The vmstat command allows you to monitor your system’s memory usage. It shows how much virtual memory there is, and how much is free and paging activity. You can observe page-ins and page-outs as they happen. This is extremely useful for detecting shortages of physical memory, which can adversely affect system performance.

The vmstat output contains more than just memory statistics. Output is broken up into six sections: procs, memory, swap, io, system, and cpu. To prevent the sample output from wrapping, the output is shown in two parts. As with iostat and mpstat, vmstat accepts interval and count arguments. The following example runs 3 reports 5 seconds apart:

# vmstat 5 3

procs ----------memory----------- ---swap--

r b swpd free buff cache si so

1 0 13344 1444 1308 19692 0 168

1 0 13856 1640 1308 18524 64 516

3 0 13856 1084 1308 18316 56 64

This portion of the sample output only shows the first three sections. These three sections are described before the remaining three sections are shown.

Oracle Linux System Administration 22 - 15

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

vmstat Utility

• The vmstat utility:

– Monitors system memory usage

– Is useful for detecting shortages of physical memory

• The vmstat report has six sections:– Processes: The numbers of processes in wait or sleep states

– Memory: Amounts of memory free, and amounts used for virtual memory, buffers, and cache

– Swap: The number of page-ins and page-outs

– IO: The number of blocks received and sent

– System: The number of interrupts and context switches

– CPU time: Percentages for user, kernel, idle, iowait, and stolen

• Recommended: Run the utility with a delay interval:– # vmstat 5

• Additional options are available.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 220: D74508GC10_sg2

The first two columns give information on processes:

• r: The number of processes that are in a wait state. These processes are not doing anything but waiting to run.

• b: The number of processes that were in sleep mode and were interrupted since the last update

The next four columns give information on memory:

• swpd: The amount of virtual memory used

• free: The amount of idle memory

• buff: The amount of memory used as buffers

• cache: The amount of memory used as cache

The next two columns give information on swap:

• si: The amount of memory swapped in from disk (per second)

• so: The amount of memory swapped out to disk (per second)

Nonzero si and so numbers indicate that there is not enough physical memory and that the kernel is swapping memory to disk.

The remaining three sections of the vmstat report:

# vmstat 5 3

-----io---- --system-- -----cpu------

bi bo in cs us sy id wa st

129 42 1505 713 20 11 69 0 0

379 129 4341 646 24 34 42 0 0

14 0 320 1022 84 9 7 0 0

The first two columns give information on IO (input-output):

• bi: The number of blocks per second received from a block device

• bo: The number of blocks per second sent to a block device

The next two columns give the following system information:

• in: The number of interrupts per second, including the clock

• cs: The number of context switches per second

The last five columns give the percentages of total CPU time:

• us: The percentage of CPU cycles spent on user processes

• sy: The percentage of CPU cycles spent on system (kernel) processes

• id: The percentage of CPU cycles spent idle

• wa: The percentage of CPU cycles spent waiting for IO

• st: The percentage of CPU cycles stolen from a virtual machine

Additional information can be included by providing different options to the vmstat command. Some of the command-line options are listed:• -a: Display active and inactive memory.

• -f: Display the number of forks since boot.

• -t: Add a time stamp to the output.

• -d: Report the disk statistics.

Oracle Linux System Administration 22 - 16

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 221: D74508GC10_sg2

The iostat and mpstat commands are provided by the sysstat package. Additional resource monitoring tools, including sar and sadc (system activity data collector), are also provided by this package. See http://sebastien.godard.pagesperso-orange.fr/ for more information on sysstat. The following is a partial list of the files provided by the package:

# rpm –ql sysstat

/etc/cron.d/sysstat /usr/bin/sadf

/etc/rc.d/init.d/sysstat /usr/bin/sar

/etc/sysconfig/sysstat /usr/lib64/sa

/etc/sysconfig/sysstat.ioconf /usr/lib64/sa/sa1

/usr/bin/cifsiostat /usr/lib64/sa/sa2

/usr/bin/iostat /usr/lib64/sa/sadc

/usr/bin/mpstat /var/log/sa

/usr/bin/pidstat

The sadc command collects system resource utilization data and writes it to a file. The sadccommand is normally run by the sa1 script, which is invoked by cron via the /etc/cron.d/sysstat file. By default, cron runs the sa1 script every 10 minutes.

Oracle Linux System Administration 22 - 17

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

sar Utility

• Provided by the sysstat package:– sar: Collects and displays ALL system activities statistics

– sadc: The sar back-end tool that does the data collection.

– sa1: A script that runs sadc and stores system activities in a binary data file. sa1 runs from cron.

– sa2: Creates daily summary of the collected statistics. sa2runs from cron.

– pidstat: Reports statistics based on the process ID (PID)

– cifsiostat: Generates CIFS statistics

• Many options exists for sar:– -A, -r, -b, -B, -d, -S, and more

• You can specify interval and count parameters.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 222: D74508GC10_sg2

The sar command produces system utilization reports based on the data collected by sadc. The sar command is normally run by the sa2 script, which is also invoked by cron via the /etc/cron.d/sysstat file. By default, cron runs the sa2 script once a day at 23:53, allowing it to produce a report for the entire day’s data. Example:

# cat /etc/cron.d/sysstat

*/10 * * * * * root /usr/lib64/sa/sa1 ...

53 23 * * * root /usr/lib64/sa/sa2 ...

The sa1 script logs output into sysstat binary log file format, and the sa2 script reports it back in human-readable format. By default, the data is written to files in the /var/log/sa directory. The files are named sa<dd>, where <dd> is the current day’s two-digit date. Running the sarcommand without any options uses the current daily data file as the data source. Use the -f filename option to specify a different data source. Sample output from sar is shown here:

# sar

Linux 2.6.32-300.3.1.el6uek.x86_64 (host01.example.com)... (1 CPU)

11:00:01 AM CPU %user %nice %system %iowait %steal %idle

11:10:01 AM all 0.01 0.00 0.01 0.09 0.00 99.89

11:20:01 AM all 0.02 0.00 0.09 0.11 0.00 99.79

11:30:01 AM all 0.08 0.00 0.11 0.32 0.00 99.49

11:40:01 AM all 0.01 3.69 7.41 6.68 0.00 82.21

Average: all ...

Many options exists for the sar command including the following:

• -A: Display all the statistics saved in the current daily data file.

• -r: Display memory utilization statistics.

• -b: Report I/O and transfer rate statistics.

• -B: Report paging statistics.

• -d: Report activity for each block device.

• -S: Report swap statistics.

The sar command also accepts interval and count parameters. If the intervalparameter is set to zero, sar displays the average statistics for the time since the system was started. Reports are generated continuously if the interval parameter is specified without the count parameter.

Oracle Linux System Administration 22 - 18

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 223: D74508GC10_sg2

The top command provides an ongoing look at processor activity in real time. It displays a listing of the most CPU-intensive processes or tasks on the system and provides a limited interactive interface for manipulating processes. The following is a partial example of topoutput:

# top

top – 03:55:32 up 21 days, 21:11 3 users, load average: ...

Tasks: 151 total, 1 running, 149 sleeping, 0 stopped, 0 zombie

Cpu(s): 0.3%us, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si...

Mem: 2056632k total, 1339688k used, 716944k free, 204764k buf...

Swap: 4286460k total, 0k used, 4286460k free, 759712k ca...

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

1744 root 20 0 125m 23m 7872 S 0.3 0.2 1:57:94 Xorg

1 root 20 0 19448 1556 1244 S 0.0 0.1 0:03:54 init

16437 oracle 20 0 282m 13m 9408 S 0.3 0.1 0:24:55 gnom...

This sample listing is a point-in-time view of the output that top produces. The output is dynamic and refreshes every 3 seconds by default.

Oracle Linux System Administration 22 - 19

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

top Utility

• The top utility monitors system processes in real time.• The upper section of the top output displays load

averages, number of running and sleeping tasks, and overall CPU and memory usage.

• The lower section has a sorted list of processes, owner, running time, and CPU and memory usage.

• top sorts the list by most CPU-intensive tasks, and refreshes the list every three seconds by default.

• top provides an interactive interface for manipulating processes:– h or ?: Display the help screen.– f: Select the columns to display.– F or O: Select the sort field.– q: Quit.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 224: D74508GC10_sg2

The output is divided into two main sections. The upper section displays general information such as the load averages during the last 1, 5 and 15 minutes (same output as uptimecommand), number of running and sleeping tasks, and overall CPU and memory usage. The following keys change the output displayed in the upper section:

• l: Toggles load average and uptime on and off.

• m: Toggles memory and swap usage on and off.

• t: Toggles tasks and CPU states on and off.

The lower section displays a sorted list of processes (usually by CPU usage) and their PIDs (process ID number), the user who owns the process, running time, and CPU and memory that the processes uses. The following describes the columns in the lower section:

• PID: The task’s unique process ID

• USER: The effective username of the task’s owner

• PR: The priority of the task

• NI: The nice value of the task. A negative value means higher priority, a positive value means lower priority. Zero in this field means priority is not adjusted in determining a task’s dispatchability.

• VIRT: The total amount of virtual memory used by the task. It includes all code, data, and shared libraries, plus pages that have been swapped out.

• RES: The non-swapped physical memory (resident size) a task has used

• SHR: The amount of shared memory used by a task. This memory could potentially be shared with other processes.

• S: The status of the task, which can be one of: D (uninterruptible sleep), R (running), S(sleeping), T (traced or stopped), or Z (zombie)

• %CPU: The task’s share of the elapsed CPU time (CPU usage) since the last screen update, expressed as a percentage of total CPU time

• %MEM: The task’s currently used share of available physical memory (memory usage)

• TIME+: The total CPU time that the task has used since it started

• COMMAND: The command line or program name used to start a task

There are several keystroke commands that can be used while top is running. The following is a partial list:

• h or ?: Displays a list of available commands (help screen)

• f: Allows you to select different columns to display

• o: Allows you to change the order of the columns

• F or O: Allows you to select the sort field. CPU usage is the default

• d or s: Allows you to change the refresh interval

• c: Toggles the display of command line and program name

• i: Toggles the display of all tasks or just active tasks

• S: Toggles the cumulative time on and off. When on, each process is listed with the CPU time that it and its dead children have used. When off, programs that fork into many separate tasks appear less demanding.

• u: Allows you to display only those tasks owned by a specific user

• k: Allows you to kill a process

• q: Allows you to exit or quit the top utility

Oracle Linux System Administration 22 - 20

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 225: D74508GC10_sg2

The iotop command is a Python program. iotop has a user interface similar to top, but it is used for monitoring swap and disk I/O on a per-process basis. If you are getting more disk activity on your system than you would like, iotop can help identify which process or processes are responsible for the excessive I/O.

The iotop command requires a kernel version 2.6.20 or higher and Python 2.5 or higher. Run uname –r to obtain your kernel version and python –V to get the Python version.

The top of the output displays the sum of the DISK READ and DISK WRITE bandwidth in B/s (bytes per second). After this is a list of all processes running on the system. Each process has a column labeled DISK READ and DISK WRITE, as well as SWAPIN and IO. The COMMAND column displays the name of the process.

By default iotop monitors all users on the system and all processes. Several options are available. The following is a partial list of options to iotop:

• -h: Display help and a list of options.

• -o: Show only processes and threads actually doing I/O.

• -u USER: Show specific USER processes.

• -a: Show accumulated I/O instead of bandwidth.

Press the letter q to exit.

Oracle Linux System Administration 22 - 21

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

iotop Utility

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 226: D74508GC10_sg2

The strace command is a debugging tool which prints a list of all the system calls made by a another program or process. It displays the system calls which are called by a process and the signals which are received by a process. It is particularly useful in determining why a program continually crashes or does not behave as expected.

Each line in the trace contains the system call name, followed by its arguments in parentheses and its return value. Following is a partial output from stracing the ls command:

# strace ls

execve(“/bin/ls, [“ls”], [/* 29 vars */]) = 0

brk(0)...

mmap(NULL, 4096 ...

access(“/etc/ld.so.preload, R_OK)...

open(“/etc/ld.so.cache”, O_RDONLY)...

...

Errors typically return a value of -1 and have the errno symbol and error string appended. Signals are printed as a signal symbol and a signal string. Output is printed on standard error or to the file specified with the -o option.

Oracle Linux System Administration 22 - 22

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

strace Utility

• The strace utility is a debugging tool.

• It prints the system calls made by a another program or process.

• Each line contains the system call name, followed by its arguments in parentheses and its return value.

• Errors typically return a value of -1 and have the errnosymbol and error string appended.

• Signals are printed as a signal symbol and a signal string.

• Output is printed on standard error or to the file specified with the -o option.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 227: D74508GC10_sg2

The netstat command displays current TCP/IP network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. The ss command provides dump socket statistics but also shows information similar to netstat.

A number of command-line options and arguments exist, but netstat by itself displays a list of open sockets. Sockets are the interface between the user process and the network protocol stacks in the kernel. The protocol modules are grouped into protocol families such as AF_INET, AF_IPX, and AF_PACKET, and socket types such as SOCK_STREAM or SOCK_DGRAM. If you do not specify any address families, the active sockets of all configured address families are printed.

To specify the address families (low-level protocols) for which connections are to be shown, use the -A option followed by a comma-separated list of address family keywords. Possible address family keywords are inet, unix, ipx, ax25, netrom, and ddp. Example:

# netstat –A unix

Active UNIX domain sockets (w/o servers)

Proto RefCnt Flags Type State I-Node Path

unix 2 [ ] DGRAM 7137 @/org/kernel/udev/udevd

...

Oracle Linux System Administration 22 - 23

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

netstat Utility

• The netstat utility displays various network-related information.

• The netstat command without options displays a list of open sockets for each address family (AF).

• Several options exist:– -A: Specify the address family.

– -r: Display the route table.

– -i: Display network interface information.

– -s: Display summary statistics for each protocol.

– -g: Display multicast group membership information.

– -n: Display IP addresses instead of the resolved names.

– -c: Print information every second continuously.

– -e: Display additional information.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 228: D74508GC10_sg2

Some of the other options for netstat are listed:

• –r or --route: Display the kernel routing table:

# netstat –r

Destination Gateway Genmask Flags MSS Window irtt Iface

default 192.0.2.1 0.0.0.0 UG 0 0 0 eth0

...

• -i or -I=iface: Display a table of all network interfaces or the specified iface:

# netstat –I=eth0

Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-DRP TX-OV...

eth0 1500 0 1131204 0 16 0 174989 0 0...

• -s or --statistics: Display summary statistics for each protocol:

# netstat –s

Ip:

106564 total packets received

0 forwarded

0 incoming packets discarded

10427 incoming packets delivered

106069 requests sent out

Icmp:

...

-l or --listening: Display all ports that have a process currently listening for input.

# netstat -l

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State

tcp 0 0 *:pop3s *:* LISTEN

...

• -g or --groups: Display multicast group membership information for IPv4 and IPv6:

# netstat –g

Interface RefCnt Group

--------- ------ -----

lo 1 224.0.0.1

eth0 1 224.0.0.251

...

• -n or --numeric: Display IP addresses instead of the resolved names.

• -c or --continuous: Print information every second continuously.

• -e or --extend: Display additional information. Use this option twice for maximum detail.

• -p or --program: Show the PID and name of the program to which each socket belongs.

Any invalid option or argument displays a help screen listing usage and a brief description of available options.

Oracle Linux System Administration 22 - 24

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 229: D74508GC10_sg2

The tcpdump utility allows you to capture packets that flow within your network to assist in network troubleshooting. The following are several examples of using tcpdump with different options.

To print a list of network interfaces available on which tcpdump can capture packets:

# tcpdump –D

1.eth0

2.eth1

3.any (Pseudo-device that captures on all interfaces)

4.lo

For each network interface, a number and an interface name is printed. The interface name or the number can be supplied to the -i flag to specify an interface on which to capture.

# tcpdump –i 1

listening on eth0, link-type EN10MB (Ethernet), capture size...

03:57:25.845920 ARP, Request who-has host02.example.com tell...

03:57:25.846093 ARP, Reply host02.example.com is-at 00:16:3e...

In this example, output is continuous until terminated by pressing Ctrl + C.

Oracle Linux System Administration 22 - 25

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

tcpdump Utility

• The tcpdump utility is a packet-capture utility for network troubleshooting.

• Traffic is captured based on a specified filter.

• A variety of options exist, including:– –D: Print a list of network interfaces.

– -i: Specify an interface on which to capture.

– -c: Specify the number of packets to receive.

– -v, -vv, -vvv: Increase the level of detail (verbosity).

– -w: Write captured data to a file.

– -r: Read captured data from a file.

• You can also specify host, source, or destination of traffic, and a specific protocol to capture.

• Boolean operators (AND, OR, NOT) allow complex filters.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 230: D74508GC10_sg2

To exit tcpdump after receiving a specific number of packets, use the -c (count) option followed by the number of packets to receive. The following example captures two packets:

# tcpdump –i 1 –c2

...

2 packets captured

2 packets received by filter

0 packets dropped by kernel

As shown in this example, when tcpdump finishes capturing packets, it reports the following:

• packets captured: This is the number of packets that tcpdump has received and processed.

• packets received by filter: A filter can be specified on the command line and only those packets that match the defined filter are processed by tcpdump and counted.

• packets dropped by kernel: This is the number of packets that were dropped due to a lack of buffer space. Use the -B option to set the buffer size.

To increase the detail (verbosity) of the output, use the -v option, or -vv for even more verbose output, or -vvv for the most verbose level of output:

# tcpdump –i 1 –v

# tcpdump –i 1 -vv

# tcpdump –i 1 –vvv

Using the tcpdump utility with the -w option allows you to write captured data to a file. This allows the captured data to be read by other network analysis tools, such as Wireshark. The following example captures data to file named capture_file:

# tcpdump –i 1 –v –c2 –w capture_file

You can also read captured data from a file by using the –r option:

# tcpdump –r capture_file

Many other options and arguments can be used with tcpdump. The following are some specific examples of the power of the tcpdump utility.

To display all traffic between two hosts (represented by variables host1 and host2):

# tcpdump host host1 and host2

To display traffic from only a source (src) or destination (dst) host:

# tcpdump src host

# tcpdump dst host

Provide the protocol as an argument to display only traffic for a specific protocol, for example tcp, udp, icmp, arp:

# tcpdump protocol

To filter based on a source or destination port:

# tcpdump src port ftp

# tcpdump dst port http

The tcpdump utility also accepts Boolean operators (AND, NOT, OR) and grouping of operators, allowing you to create complex filters for capturing network data.

Oracle Linux System Administration 22 - 26

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 231: D74508GC10_sg2

The Oracle OSWatcher Black Box (OSWbb) product is a collection of shell scripts intended to collect and archive operating system and network metrics to aid in diagnosing performance issues. OSWbb operates as a set of background processes on the server and gathers data on a regular basis, invoking such UNIX utilities as vmstat, netstat, iostat, top, and others.

Beginning with release 4.0.0, OSWbb includes a built-in analyzer called OSWbba, which analyzes the data that OSWbb collects. It provides information on system slowdowns, hangs and other performance problems. It also provides the ability to graph vmstat and iostatdata.

OSWbb is particularly useful for Oracle Real Application Clusters (RAC) and Oracle Grid Infrastructure configurations. OSWbb is included in the RAC-DDT (Diagnostic Data Tool) script file, but is not installed by RAC-DDT.

Installing OSWbbYou must install OSWbb on each node where data is to be collected. For RAC or shared disk systems, each node requires an OSWbb installation into a unique directory (for example, /oswbb_node1 and /oswbb_node2). OSWbb is available through My Oracle Support (MOS) and can be downloaded as a tar file named oswbb403.tar. After downloading the tar file, copy the file to the directory where OSWbb is to be installed and run the following command:

# tar xvf oswbb403.tar

Oracle Linux System Administration 22 - 27

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

OSWatcher Black Box (OSWbb)

• OSWbb collects and archives operating system and network metrics to aid in diagnosing performance issues.

• OSWbb includes a built-in analyzer called OSWbba.

• Download the OSWbb tar file from My Oracle Support (MOS).

• To install OSWbb, use the tar command:– # tar xvf oswbb403.tar

• To start OSWbb, use the following command:– # ./startOSWbb.sh

• To stop OSWbb, use the following command:– # ./stopOSWbb.sh

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 232: D74508GC10_sg2

Extracting the TAR file creates a directory named oswbb, which contains all the files associated with OSWbb.

# ls oswbb

analysis/ htop.sh OSWatcherFM.sh oswlnxio.sh

profile/ stopOSWbb.sh vmsub.sh docs/

iosub.sh OSWatcher.sh oswnet.sh pssub.sh

tarupfiles.sh xtop.sh Exampleprivate.net locks/

oswbba.jar oswrds.sh src/ tmp/

gif/ mpsub.sh oswib.sh oswsub.sh

StartOSWbb.sh topaix.sh

Starting OSWbbTo start the OSWbb utility, execute the startOSWbb.sh shell script. This is a korn shell script that requires the ksh package to be installed:

# yum install ksh

Oracle Linux installs the ksh utility in /bin/ksh. However, the startOSWbb.sh script expects the utility to reside in /usr/bin. Therefore, create a symbolic link by using the following command:

# ln –s /bin/ksh /usr/bin/ksh

The startOSWbb.sh script accepts two optional arguments that control the frequency (in seconds) that data is collected and the number of hours worth of data to archive. If you do not enter any arguments, the script runs with default values of 30 and 48, meaning collect data every 30 seconds and store the last 48 hours of data in archive files.

The following example starts the tool and collects data at 60 second intervals and logs the last 10 hours of data to archive files. Some of the output produced when starting the tool is shown:

# ./startOSWbb.sh 60 10

Testing for discovery of OS Utilities...

VMSTAT found on your system.

IOSTAT found on your system.

MPSTAT found on your system.

NETSTAT found on your system.

TOP found on your system.

Testing for discovery of OS CPU COUNT

...

Starting Data Collection...

oswbb heartbeat: date/time

oswbb heartbeat: date/time (60 seconds later)

...

Stopping OSWbbTo stop OSWbb, execute the stopOSWbb.sh shell script. This terminates all processes associated with OSWbb and is the normal, graceful mechanism for stopping the tool.

Oracle Linux System Administration 22 - 28

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 233: D74508GC10_sg2

The OSWatcher.sh shell script is the main controlling script that spawns individual shell processes to collect specific kinds of data using UNIX operating system diagnostic utilities. Control is passed to individually spawned operating system data collector processes, which in turn collect specific data, time-stamp the data output, and append the data to files.

Data collectors exist for the top, vmstat, iostat, mpstat, netstat, and ps utilities, and for /proc/meminfo and /proc/slabinfo. There is also an optional collector for tracing private networks. The collected data files are stored in the archive subdirectory, which is created when OSWbb is started for the first time. The archive directory contains nine subdirectories, one for each data collector.

# ls archive

oswiostat/ oswmeminfo/ oswmpstat/ oswnetstat/ oswprvtnet/

oswps/ oswslabinfo/ oswtop/ oswvmstat/

The data is stored in hourly archive files during the time that OSWbb is running. Files are named using the following format:

<node_name>_<OS_utility>_YY.MM.DD.HH24.dat

Each entry in the file contains a time stamp prefixed by *** characters. The contents of each of the nine archive directories are described here:

Oracle Linux System Administration 22 - 29

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

OSWbb Diagnostic Data Output

• OSWatcher.sh is the main controlling script that spawns other scripts to collect diagnostic data.

• The data is stored in hourly archive files:– <node_name>_<OS_utility>_YY.MM.DD.HH24.dat

• Subdirectories are created in the archive directory.• oswiostat: Contains the output from the iostat utility• oswmeminfo: The contents of the /proc/meminfo file• oswmpstat: Contains the output from the mpstat utility• oswnetstat: Contains the output from the netstat

utility• oswprvtnet: Contains the status of RAC private

networks– Requires you to manually create executable file named

private.net, which runs traceroute commands

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 234: D74508GC10_sg2

oswiostat

OSWbb runs the iostat utility at the specified interval and stores the data in this directory. The default options and arguments for iostat are set in the oswlnxio.sh script. By default, iostat produces extended output (-x option). Look for average service times, svctm, greater than 20msec for long duration and high average wait times, await, as indicators of performance problems.

oswmeminfo

OSWbb reads the /proc/meminfo file at the specified interval and stores the data in this directory. Information about available memory, MemTotal, and swap, SwapTotal, is included in this file.

oswmpstat

OSWbb runs the mpstat utility at the specified interval and stores the data in this directory. Be aware of involuntary context switches and the number of times a CPU failed to obtain a mutex. Values consistently greater than 200 per CPU cause system time to increase.

oswnetstat

OSWbb runs the netstat utility at the specified interval and stores the data in this directory. Each protocol type has a specific set of measures associated with it. Network analysis requires evaluation of these measurements on an individual level and all together to examine the overall health of the network communications.

The information in the upper section of the report helps diagnose network problems when there is connectivity but response is slow. The lower section of the report contains protocol statistics. The TCP protocol is used more often than UDP in Oracle database and applications. Many performance problems associated with the network involve the retransmission of the TCP packets. Some implementations for RAC use UDP for the interconnect protocol, instead of TCP. The statistics cannot be divided up on a per-interface basis, so these should be compared to the interface statistics in the upper portion of the report.

oswprvtnet

Information about the status of RAC private networks is collected and stored in this directory only if you have configured private network tracing. This requires you to manually add entries for these private networks into an executable file named private.net file located in the oswbbdirectory.

An example of what this file should look like is named Exampleprivate.net with samples for each operating system: solaris, linux, aix, hp, etc. in the oswbb directory. This file can be edited and renamed private.net or a new file named private.net can be created. This file contains entries for running the traceroute command to verify RAC private networks. The following is an example of a private.net entry on Linux:

traceroute -r -F node1

traceroute -r -F node2

In this example, node1 and node2 are two nodes in addition to the hostnode of a three node RAC cluster. If the file private.net does not exist or is not executable, then no data is collected and stored under the oswprvtnet directory. Review the collected data to ensure that the network interface is up and responding and that the network is reachable. If tracerouteindicates that the target interface is not on a directly connected network, validate that the address is correct or the switch it is plugged in to is on the same VLAN.

Oracle Linux System Administration 22 - 30

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 235: D74508GC10_sg2

The remaining data collection directories are described.

oswps

OSWbb runs the ps command at the specified interval and stores the data in this directory. The ps command list all the processes currently running on the system and provides information about CPU consumption, process state, priority of the process, and other information. OSWbb runs the command with the -elf option.

The information in the ps command is helpful supporting information for RAC diagnostics. For example, the status of a process before a system crash may be important for root cause analysis. To discover the amount of memory that a process consumes is another example of how this data can be used.

oswslabinfo

OSWbb reads the /proc/slabinfo file at the specified interval and stores the data in this directory. Frequently used objects in the Linux kernel have their own cache. This file gives statistics on the kernel slab cache.

For each slab cache entry, the file includes the cache name, the number of currently active objects (memory blocks), the total number of available objects, the size of each object in bytes, the number of pages with at least one active object, the total number of allocated pages, and the number of pages per slab.

Oracle Linux System Administration 22 - 31

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

OSWbb Diagnostic Data Output

• oswps: Contains the output from the ps utility

• oswslabinfo: the contents of /proc/slabinfo file

– Contains statistics on the kernel slab cache

• oswtop: Contains the output from the top utility

• oswvmstat: Contains the output from the vmstat utility

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 236: D74508GC10_sg2

oswtop

OSWbb runs the top utility at the specified interval and stores the data in this directory.

The load average line displays the load averages over the last 1, 5 and 15 minutes. Load average is defined as the average number of processes in the run queue. A runnable UNIX process is one that is available right now to consume CPU resources and is not blocked on I/O or on a system call. The higher the load average, the more work your machine is doing.

The three numbers are the average of the depth of the run queue over the last 1, 5, and 15 minutes. It is important to determine what the average load of the system is through benchmarking and then look for deviations. A dramatic rise in the load average can indicate a serious performance problem.

The tasks line displays the total number of processes running at the time of the last update. It also indicates how many processes exist, how many are sleeping (blocked on I/O or a system call), how many are stopped (someone in a shell has suspended it), and how many are actually assigned to a CPU. Like load average, the total number of processes on a healthy machine usually varies just a small amount over time. Suddenly having a significantly larger or smaller number of processes could be a warning sign.

The memory line reflects how much real and swap memory your system has, and how much is free. Real memory is the amount of RAM installed in the system, or the physical memory. Swap is virtual memory stored on the machine’s disk. Performance deteriorates when a computer runs out of physical memory and starts using swap space.

Look for a large run queue. Large number of processes waiting in the run queue may be an indication that your system does not have sufficient CPU capacity. Also look for processes that are consuming lots of CPU, these processes can possibly be tuned.

oswvmstat

OSWbb runs the vmstat utility at the specified interval and stores the data in this directory. Again, when trying to determine the cause of performance problems, a large run queue can indicate CPU saturation. Also look at CPU usage to determine whether more CPUs are required. Memory bottlenecks are determined by the scan rate. If this rate is continuously high, then there is a memory shortage. Disk problems may exists if the number of processes blocked exceeds the number of processes on run queue.

Oracle Linux System Administration 22 - 32

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 237: D74508GC10_sg2

Oracle Enterprise Manager Ops Center provides management services for operating systems (including Oracle Linux), virtual machines, servers, storage, and networks. You can provision, update (patch), monitor, and manage the physical and virtual managed assets in one or more of your data centers from a single console, regardless of where the asset is located. It includes built-in integration with My Oracle Support, with automatic service request generation.

Key FeaturesThe software provides features tailored for administrating the data center infrastructure, including the following:• Dashboards: View assets including a graphical representation of the status and

membership.• Incident Management: Monitor assets according to rules and thresholds that you set.• Integration with Oracle Enterprise Manager Cloud Control: View configuration,

health, and performance information, and incidents of managed assets using either product.

• Profiles For Assets: Create software profiles and operational profiles that contain your custom executable scripts.

• Operational Plans: Deploy a single script as an operational profile. You can use the scripts to perform specific tasks in your environment, such as configuration options, or to assist in incident management.

Oracle Linux System Administration 22 - 33

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Enterprise Manager Ops Center

Enterprise Manager Ops Center:• Provides management services for operating systems,

virtual machine, servers, storage, and networks• Enables you to provision, update (patch), monitor, and

manage assets in one or more data centers from a single console

• Includes built-in integration with My Oracle Support, with automatic service request generation

• Has the following architecture components:– Enterprise Controller– Proxy Controller– Agent Controller– User Interface– Knowledge Base

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 238: D74508GC10_sg2

• Deployment Plans: Combine one or more profiles and scripts to create a multi-task plan that provisions operating systems or firmware efficiently and consistently.

• Plan Management: Use the provided default templates, profiles, and plans to create and deploy plans.

• Hardware Management: Update system component firmware and track hardware configuration changes over time.

• Virtualization Management: Manage virtual assets such as Oracle Solaris Zones, Oracle VM Servers for SPARC, Oracle VM Servers for x86, and their guests.

• Reports: Create reports for assets and activities and export the reports as files.

ArchitectureThe Enterprise Controller, Proxy Controller, Agent Controller, and user interface are the major architectural components, along with Knowledge Base, which is hosted by Oracle Corporation and accessed through the Internet.

• Enterprise Controller: This is the central server for Oracle Enterprise Manager Ops Center. All operations, or jobs, are initiated from the Enterprise Controller. It manages firmware and operating system images, plans, profiles, and policies. It connects to the Internet to get access to contract information, to create service requests, and to download updates. You can also operate the software in Disconnected mode if your site policy does not allow an Internet connection.

• Proxy Controller: These distribute the operation load and provides for fan-out capabilities to minimize network load. It links the managed assets to the Enterprise Controller and performs operations that must be located close to the managed assets, such as operating--system provisioning. You can install the Proxy Controller and Enterprise Controller software on the same system, but to enhance performance and scalability, the preferred method is to install the Proxy Controller on a separate machines.

• Agent Controllers: The Agent Controller is lightweight Java software that identifies the asset and responds to a Proxy Controller. When an operating system is agent-managed, the agent receives the command from its Proxy Controller, performs the required action, and notifies the Proxy Controller of the results. When an operating system is agentlessly managed, the Proxy Controller uses SSH to perform tasks and to monitor the operating system. You can use many of the monitoring and management features without installing an Agent Controller on the operating system. Hardware management does not require the Agent Controller. Instead, a Proxy Controller runs commands on the hardware system and reports the results to the Enterprise Controller.

• Knowledge Base and Package Repository: This stores metadata about Oracle Solaris and Linux operating system components. The metadata includes patch dependencies, standard patch compatibilities, withdrawn patches, and rules for download and deployment. Knowledge Base keeps track of the URLs for the operating systems and retrieves the components from the appropriate vendor download site.

The entire Ops Center product is included as a default part of all Systems support agreements. This means that every customer of Oracle’s servers, storage, network equipment, operating systems, and virtualization technology can add Ops Center to their data center management suite.

To see a demonstration of the product, http://www.youtube.com/watch?v=tRWTWDBUIQU.

Oracle Linux System Administration 22 - 34

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 239: D74508GC10_sg2

This slide displays the Oracle Enterprise Manager Ops Center browser interface. The format of the information is in text, tables, graphs, and charts, and the information is organized into hierarchies and tabs. You can view the information and perform the actions according to the role that you have been assigned.

The interface is consists of five panes:

• Masthead: The top pane displays the global functions and information about the Oracle Enterprise Manager Ops Center instance.

• Navigation Pane: The left pane consists of several drawers that displays assets and objects that are managed by Oracle Enterprise Manager Ops Center instance.

• Actions Pane: The right pane displays the actions that operate on the object currently selected in the Navigation pane. The actions of the Actions pane are enabled or disabled based on the state of the object or your role.

• Jobs Pane: The bottom pane displays the number of jobs in Oracle Enterprise Manager Ops Center, categorized by the status of respective jobs.

• The Center Pane: This pane displays detailed information of the object that is currently selected in the Navigation pane.

To learn more about an incident, place your cursor over the incident icons in the left-side corner of the user interface.

Oracle Linux System Administration 22 - 35

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Enterprise Manager Ops Center GUI

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 240: D74508GC10_sg2

Performance Counters for Linux (PCL) is a kernel-based subsystem that allows you to collect and analyze performance data. It keeps track of hardware events such as CPU cycles, instructions executed, cache misses, cache references, bus cycles, and others. It can also measure software events such as page faults and context switches.

Included with the PCL kernel subsystem is perf tool. The perf tool allows you to analyze the collected performance data. It abstracts away CPU hardware differences in Linux performance measurements and presents a simple command-line interface. The following is a partial list of perf commands:

• perf list: Lists the events available on a particular machine. These events vary based on the performance monitoring hardware and the software configuration of the system.

• perf stat: Provides overall statistics for performance events

• perf record: Records performance data into a file, which can be later analyzed

• perf report: Reads the performance data from a file and analyzes the recorded data

• perf annotate: Reads the performance data from a file and displays annotated code

• perf kmem: Trace/measure kernel memory (slab) properties

• perf top: System profiling tool

Oracle Linux System Administration 22 - 36

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

PCL and perf Tool

• PCL is a kernel-based subsystem that collects performance data.

• PCL keeps track of hardware and software events.– CPU cycles, instructions, cache references and misses, etc.

– Page faults, major and minor faults, context switches, etc.

• Use the perf tool to analyze the collected performance data.

• To list all events:– # perf list

• To list all perf commands:– # perf

• To get help on a specific command:– # perf command -h

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 241: D74508GC10_sg2

The perf tool offers a set of commands to collect and analyze performance and trace data. To list the available perf commands:

# perf

usage: perf [--version] [--help] COMMAND [ARGS]

The most commonly used perf commands are:

annotate Read perf.data and display annotated code

archive Create archive with object files with build...

bench General framework for benchmark suites

buildid-cache Manage <tt>build-id</tt> cache.

buildid-list List the buildids in a perf.data file

diff Read two perf.data files and display the ...

inject Filter to augment the events stream with ...

kmem Tool to trace/measure kernel memory(slab) ...

kvm Tool to trace/measure kvm guest os

list List all symbolic event types

lock Analyze lock events

probe Define new dynamic tracepoints

record Run a command and record its profile into ...

report Read perf.data (created by perf record) and ...

sched Tool to trace/measure scheduler properties ...

script Read perf.data (created by perf record) and ...

stat Run a command and gather performance counter ...

test Runs sanity tests.

timechart Tool to visualize total system behavior ...

top System profiling tool.

To list the options for each command, enter the command name followed by -h:

# perf kmem –h

usage: perf kmem [<options>] {record|stat}

-i, --input <file> input file name

--caller show per-callsite statistics

--alloc show per-allocation statistics

-s, --sort <key[,key2...]>

sort by keys: ptr, call_site, bytes, hit,...

-l, --line <num> show raw ip instead of symbol

For more information, see https://perf.wiki.kernel.org/.

A tutorial on using perf tools is available at https://perf.wiki.kernel.org/articles/t/u/t/Tutorial.html.

Oracle Linux System Administration 22 - 37

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 242: D74508GC10_sg2

Oracle Linux System Administration 22 - 38

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Quiz

Which of the following utilities allows you to collect system information for sending to Oracle support?a. sosreport

b. kdump

c. OSWbbd. perf

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 243: D74508GC10_sg2

Oracle Linux System Administration 22 - 39

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Summary

In this lesson, you should have learned how to:• Use the sosreport utility

• Set up kdump from the GUI and from the command line• Use the netdump utility

• Use the iostat, mpstat, vmstat, sar, top, iotop, and strace utilities

• Use the netstat and tcpdump utilities

• Use the OSWatcher Black Box (OSWbb) tool

• Describe Enterprise Manager Ops Center

• Describe Performance Counters for Linux (PCL) and the perf tool

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 244: D74508GC10_sg2

Oracle Linux System Administration 22 - 40

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Practice 22: Overview

The practices for this lesson cover the following topics:• Using sosreport

• Configuring kdump

• Installing and using OSWatcher

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 245: D74508GC10_sg2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Oracle on Oracle

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 246: D74508GC10_sg2

Oracle Linux System Administration 23 - 2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Objectives

After completing this lesson, you should be able to:• Prepare your Oracle Linux server for Oracle Database

installation

• Create Oracle software user and group accounts

• Set kernel parameters for Oracle Database

• Set Oracle database shell limits

• Configure HugePages

• Configure Oracle Database Smart Flash Cache (DBSFC)

• Use Oracle pre-install RPM

• Install and use ASMLib

• Install and use OCFS2

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 247: D74508GC10_sg2

The Oracle software installation requires a Linux user to be a designated Oracle software owner. The Oracle software owner runs the OUI (Oracle Universal Installer) to install Oracle Database and has full privileges to install, uninstall, and patch the Oracle software. The OUI cannot be run as the root user. The name of the Oracle software owner is commonly oracle, but you can use a different name.

The Oracle software installation also requires a low-privileged OS user to be the owner of the httpd process. This is usually provided by the nobody user.

Database operations require a few more users. A user who is a member of the OSOPER group can start, stop, back up, and recover the database. A user who is a member of the OSDBAgroup can create, drop database, and create other DBA privileged users, in addition to the privileges of the OSOPER.

Ordinary database users can have OS accounts on the database server, but it is not necessary. It is common for database users to connect to the database through a client or application server without any OS account. OS user accounts may be required by the database application for batch jobs or specialized external processes. The Oracle default installation does not require any ordinary database user to have OS accounts.

Oracle Linux System Administration 23 - 3

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Oracle Software User Accounts

• Oracle software owner:– Is commonly named oracle

– Runs the OUI and has full privileges to install, uninstall, and patch Oracle software

– Cannot be root

• The owner of the httpd process is:

– A low-privileged OS user– Usually provided by the nobody user

• Database operations require a few more users:– Members of OSOPER group can start, stop, back up, and

recover the database.– Members of OSDBA group has OSOPER privileges, can create

and drop database, and create other OSDBA members.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 248: D74508GC10_sg2

The Oracle Database Installation Guide names three group identifiers:

• OSDBA (dba): Identifies OS accounts that have database administration privileges (SYSDBA)

• OSOPER (oper): Identifies OS accounts that have limited database administration privileges (SYSOPER)

• Oracle Inventory group (oinstall): Identifies the owner of the Oracle software

An OSDBA group is the only group that must be created to manage the database files. By default, this group is dba, but can have a different group name. SYSDBA is a high-level administrative privilege much like that of the root user on Linux. The members of the OSDBAgroup own the database files and have the privilege to connect to the database without a password, using AS SYSDBA through OS authentication.

The OSOPER group members connect to the database using AS SYSOPER mechanism. This group has a restricted set of privileges. Each database can have its own OSDBA and OSOPERgroups.

During installation, one inventory is created per system and all Oracle software installed on a server is registered in this inventory. The inventory group name is oinstall, and the Oracle software owner (oracle) is a member of this group. This user is also a member of the OSDBAand OSOPER groups.

Oracle Linux System Administration 23 - 4

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Oracle Software Group Accounts

• OSDBA:– This is commonly named dba.

– Members of the OSDBA group have database administration privileges (SYSDBA).

• OSOPER:– This is commonly named oper.

– Members of the OSOPER group have limited database administration privileges (SYSOPER).

• Oracle Inventory group:– This is commonly named oinstall.

– All installed Oracle software is registered in this inventory.– Oracle software owner (oracle) is a member of this group.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 249: D74508GC10_sg2

The Oracle Database instance requires certain system resources. Kernel resources are controlled by kernel parameters. Shell limits are controlled by the settings in the shell configuration files.

Oracle uses SYSV UNIX shared memory. The kernel parameters for shared memory must be adjusted for database use. The shared memory system also uses semaphores to coordinate shared memory access. Every Oracle instance requires a set of semaphores.

The Oracle instance communicates via network connections. Each dedicated server process requires a network port. In a shared server environment, each dispatcher requires a port.

Oracle recommends that you change the network buffers to allow larger defaults for send and receive buffers and a larger maximum buffer size. These changes are helpful to optimize network performance when there are high-bandwidth applications, such as RAC and GigE network interfaces.

Because an Oracle database often has a large number of open files, the kernel default setting for the maximum number of open files per process is too small.

Shell limit settings are typically used to prevent any one user from consuming so many resources that it prevents other users from being able to work. The typical user settings are too low for the Oracle software owner. The oracle user may have hundreds of processes executing and thousands of files open.

Oracle Linux System Administration 23 - 5

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

System Resource Tuning

• An Oracle database instance requires certain system resources.

• Shared memory must be adjusted for database use.

• Shared memory system uses semaphores, which must be adjusted.

• Each dedicated server process requires a network port.

• Larger network buffers are recommended.

• The maximum number of open files per process must be increased.

• Shell limit settings must be increased.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 250: D74508GC10_sg2

The following are the memory-related kernel parameters:

• SHMMNI: The maximum number of systemwide shared memory segments.

• SHMMAX: The maximum size of each segment.

• SHMALL: The maximum number of shared memory pages system wide.

Shared memory is allocated in segments. A segment is not necessarily as large as the maximum size, it is only as big as is allocated. If a process needs a larger shared memory area than can be allocated in one segment, it allocates multiple segments. Database instances often allocate multiple segments to accommodate a large SGA (System Global Area).

For Oracle Database, the SHMMAX parameter limits the size of each of the shared memory segments on the system. It should be equal to or larger than the largest SGA on the system, otherwise the SGA is made up of multiple memory segments.

The memory-related kernel parameters are set in the /etc/sysctl.conf file:

• kernel.shmmni = 4096

• kernel.shmmax = 4398046511104

• kernel.shmall = 1073741824

Oracle Linux System Administration 23 - 6

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Linux Shared Memory

• Three shared memory-related kernel parameters:– SHMMNI: The maximum number of systemwide shared

memory segments– SHMMAX: The maximum size of each segment

– SHMALL: The maximum number of shared memory pages system wide

• For Oracle database, set SHMMAX >= the largest SGA.

• Shared memory kernel parameters are set in: /etc/sysctl.conf

• Parameters are viewable in:# ls /proc/sys/kernel/sh*

shmall shmmax shmmni

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 251: D74508GC10_sg2

Semaphores are a robust method of controlling access to critical resources. The Oracle instance uses semaphores primarily to control access to shared memory. Semaphores are allocated based on the PROCESSES initialization parameter. The PROCESSES initialization parameter determines the maximum number of operating system processes that can be connected to Oracle Database concurrently.

Each Oracle instance tries to allocate two semaphore sets at startup. Immediately after startup, the instance releases one set of semaphores. This method prevents exhaustion of the semaphore resources. Each set allocates at least as many semaphores as the value of PROCESSES. If it does not, the Oracle instance gets more sets to satisfy the number of semaphores that it needs. If the instance cannot allocate enough semaphores (either in one set or in multiple sets), then the instance does not start.

You can adjust the kernel parameters for semaphores. Semaphore settings are positional. All four of the semaphore parameters are set by a single kernel parameter, kernel.sem, in /etc/sysctl.conf and viewable in /proc/sys/kernel/sem. The four parameters are:

• semmsl: Maximum number of semaphores per set

• semmns: Total number of semaphores in the system

• semopm: Maximum number of operations per semop call

• semmni: Maximum number of semaphore sets

Oracle Linux System Administration 23 - 7

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Semaphores

• Semaphores are a method of controlling access to critical resources.

• The Oracle instance uses semaphores to control access to shared memory.

• Semaphores are allocated based on the PROCESSESinitialization parameter.

• All four semaphore parameters are set by a single kernel.sem parameter in /etc/sysctl.conf:– semmsl: Maximum number of semaphores per set

– semmns: Total number of semaphores in the system

– semopm: Maximum number of operations per semop call

– semmni: Maximum number of semaphore sets

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 252: D74508GC10_sg2

A semop call is a call to a function that actually uses the semaphores (for example, testing, setting, and clearing).

The following are general recommendations for the settings of the semaphore parameters on Oracle Linux. You must test and adjust these depending on your system:

• For semmsl: 250 or the largest PROCESSES parameter of an Oracle database plus 10.

• For semmns: 32000 or sum of the PROCESSES parameters for each Oracle database, adding the largest one twice, and adding an additional 10 for each database

• For semopm: 100

• For semmni: 128

Because these parameters are positional, the following illustrates setting the parameters as indicated in /etc/sysctl.conf:

kernel.sem = 250 32000 100 128

Parameters are viewable in:

# cat /proc/sys/kernel/sem

250 3200 100 128

Oracle Linux System Administration 23 - 8

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 253: D74508GC10_sg2

An IP port is assigned to a database-dedicated server process when it starts. The IP port is used to communicate with the user process. By default, the range available is 32768 through 61000. In some databases with a very large number of users, the default range of ports that are available to non-root processes might not be adequate. In the following example, the IP port range is set to be from port 9000 through 65500:

# cat /proc/sys/net/ipv4/ip_local_port_range

9000 65500

On systems that use a firewall, a shared server configuration, or connection multiplexing, the number of needed ports can be greatly reduced.

TCP/IP window size parameters define the read (rmem) and write (wmem) window sizes for a TCP/IP packet. These parameters set the default and maximum memory allocated for the network send and receive buffers. Defaults are defined, and because TCP/IP communications occur with other machines, which can have different settings, you can adjust the sizes upward to attain compatibility. You cannot adjust them beyond the specified maximum value.

# ls /proc/sys/net/core/[rw]mem*

rmem_default (262144) wmem_default (262144)

rmem_max (4194304) wmem_max (1048576)

Oracle Linux System Administration 23 - 9

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Network Tuning

• Socket parameters:– An IP port is assigned to a server process when it starts.

– An IP port is used to communicate with the user process.

– The default range is 32768 through 61000.# cat /proc/sys/net/ipv4/ip_local_port_range

9000 65500

• TCP/IP window size parameters:– Define read (rmem) and write (wmem) window sizes.

– Set the default and maximum memory allocated for the network send and receive buffers.

# ls /proc/sys/net/core/[rw]mem*

rmem_default wmem_default

rmem_max wmem_max

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 254: D74508GC10_sg2

The File Handles parameter (fs.file-max) determines the maximum number of file handles that the Linux kernel allocates. The Oracle database background processes open all the data files in addition to redo logs, the alert log, and other supporting files. Therefore fs.file-max must be high enough to include all the data files within your database and all supporting files.

This value is set in /etc/sysctl.conf and is viewable in /proc/sys/fs/file-max:

# cat /proc/sys/fs/file-max

6815744

Oracle Linux System Administration 23 - 10

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Setting the File Handles Parameter

• The File Handles parameter (fs.file-max) determines the maximum number of file handles that the Linux kernel allocates

• The Oracle database background processes open all data files, logs, and other supporting files.

• The parameter must be high enough to include all the data files within your database and all supporting files.

• Set the kernel parameter in /etc/sysctl.conf:fs.file-max = 6815744

• View the setting in:# cat /proc/sys/fs/file-max

6815744

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 255: D74508GC10_sg2

The Asynchronous IO (AIO) kernel subsystem is used to make system calls asynchronously in a generic fashion to ensure that Oracle databases run properly on Linux. The idea behind AIO is to allow a process to initiate several I/O operations without having to block or wait for any to complete. At some later time, or after being notified of I/O completion, the process can retrieve the results of the I/O.

The /proc/sys/fs/aio-max-nr file is the maximum number of allowable concurrent requests.

# cat /proc/sys/fs/aio-max-nr

1048576

Oracle Linux System Administration 23 - 11

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Asynchronous IO (AIO)

• AIO is the kernel subsystem used to ensure that Oracle databases run properly on Linux.

• AIO allows a process to initiate several I/O operations without having to block or wait for any to complete.

• The process can retrieve the results of the I/O later.

• Set the maximum number of allowable concurrent requests kernel parameter in /etc/sysctl.conf:fs.aio-max-nr = 1048576

• View the setting in:# cat /proc/sys/fs/aio-max-nr

1048576

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 256: D74508GC10_sg2

You must set two limits in order for an Oracle database to function properly. These apply to the oracle Linux user. You can typically set these limits to a high value.

The nofile limit is the maximum number of files that the user can have open at one time. The oracle user opens initialization files, data files, redo log files, and other files; therefore this limit needs to be set high enough to have all those files open simultaneously.

The nproc limit is the maximum number of processes a given user can run at once. The oracle Linux user owns and starts all the background processes, server processes, and possibly the parallel query and dispatcher processes. This number must be set high enough to accommodate that. The typical increase in process count comes from the number of sessions in the database. You must set this parameter high enough to manage the highest number of sessions, plus some for other processes.

For each of these settings, there is a soft limit and a hard limit. The hard limit can be changed only by the root user. The soft limit serves as the limit for the resource at any given time, which the user cannot exceed. But the user can change the soft limit, up to the value of the hard limit. The purpose of a limit is to prevent runaway situations where resources are being used up beyond what was intended by the processes running in the user space. Allowing the soft limit to be adjusted by the user, but never exceeding the root-defined hard limit, provides flexibility along with control.

Oracle Linux System Administration 23 - 12

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Oracle-Related Shell Limits

• Two shell limits must be set for the oracle user:– nofile: The maximum number of files the user can have

open at one time– nproc: The maximum number of processes a user can run

at one time

• Soft limit versus hard limit– A hard limit can be changed only by root.

– A soft limit can be changed by the user, up to the value of the hard limit.

• Define limits in the /etc/security/limits.conf file.

• Edit the /etc/pam.d/login file.

• A user can change a soft limit by using the ulimitcommand, for example: $ ulimit –Sn 50

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 257: D74508GC10_sg2

Setting Shell LimitsThe following example sets hard and soft limits for the oracle user. Two different files are modified:

1. Add the following to the /etc/security/limits.conf file:

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 1024

oracle hard nofile 65536

oracle soft stack 10240

oracle hard stack 32768

2. Add or edit the following lines in the /etc/pam.d/login file:

session required pam_limits.so

The pam_limits.so file is a Pluggable Authentication Module (PAM) that sets limits on the system resources that can be obtained in a user session. By default, limits are taken from the /etc/security/limits.conf file.

After a user has started a shell, the user can use the ulimit command to adjust the hard limit and soft limit for this specific shell. The hard limit cannot be increased after it is set, and the soft limit cannot be increased above the hard limit. In the following example, the ulimit command has no effect, it is setting the hard limit and soft limit to the same value that they have already been set to:

$ ulimit –u 16384 –n 65536

If the user issues the ulimit –Sn 50 command (which sets the soft limit for the number of open files to 50), then any attempt to open more than that results in an error. The user could still set it higher (for example, ulimit –Sn 100), which would result only in errors when the number of open file requests exceeds 100. However, the soft limit cannot be set higher than the hard limit.

Because a process inherits these settings from the shell (from which it is started) at the time that it is started, if you change the settings, any processes would have to be restarted for them to take effect. For example, if the shell limit values were changed, the Oracle database would have to be shut down and restarted.

Oracle Linux System Administration 23 - 13

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 258: D74508GC10_sg2

HugePages is a feature of the Linux kernel. HugePages allow larger pages to manage memory as the alternative to small 4 KB page sizes (16 K for IA64). HugePages are crucial for faster Oracle database performance on Linux if you have large RAM and SGA. If your combined database SGAs is large (for example, more than 8 GB—but HugePages can even be important for smaller databases), you need HugePages configured. The HugePages feature is useful in both 32- and 64-bit configurations and is integrated into the Linux kernel with release 2.6.

HugePages Facts/Features• The HugePages feature is back-ported to some 2.4 kernels. Kernel versions 2.4.21-*

have this feature, but it is implemented in a different way. The difference from the 2.6 implementation is the organization within the source code and the kernel parameters that are used for configuring HugePages.

• HugePages can be allocated dynamically, but they must be reserved during system startup. Otherwise the allocation might fail, because the memory is already paged in mostly 4 KB.

• HugePages are not subject to reservation/release after the system startup unless there is system administrator intervention (basically changing the HugePages configuration).

• HugePages are not swappable; therefore, there is no page-in/page-out mechanism overhead. HugePages are universally regarded as pinned (never swapped to secondary storage).

Oracle Linux System Administration 23 - 14

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

HugePages

• HugePages:– Allow larger pages to manage memory

– Are crucial for faster Oracle database performance

– Are useful in both 32- and 64-bit configurations

– Are integrated into the Linux kernel with release 2.6

– Have been back-ported to some 2.4 kernels (2.4.21), but is implemented differently

– Decrease page table overhead

– Provide faster overall memory performance

– Must be reserved during system startup

– Are not swappable—there is no page-in/page-out overhead

• HugePage sizes vary from 2 MB to 256 MB, based on the kernel version and the hardware architecture.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 259: D74508GC10_sg2

• No kswapd operations: The kernel swap daemon, kswapd, gets very busy if there is a very large area to be paged (13 million page table entries for 50 GB memory) and uses an incredible amount of CPU resource. When HugePages are used, kswapd is not involved in managing them.

• HugePages allows fewer translations to be loaded into the Translation Lookaside Buffer (TLB). A TLB is a buffer (or cache) in a CPU that contains parts of the page table. This is a fixed size buffer used for faster virtual address translation. A hugetlb is an entry in the TLB that points to a HugePage. HugePages are implemented via hugetlb entries (a HugePage is handled by a “hugetlb page entry”). The “hugetlb” term is also used synonymously with a HugePage.

• TLB entries cover a larger part of the address space when using HugePages. There are fewer TLB misses before the entire, or most of the, SGA is mapped in the TLB.

• Fewer TLB entries for the SGA also means more room for other parts of the address space.

• Decreased page table overhead: A page table is the data structure of a virtual memory system in an operating system to store the mapping between virtual addresses and physical addresses. This means that on a virtual memory system, the memory is accessed by first accessing a page table and then accessing the actual memory location implicitly.

• Eliminated page table lookup overhead: Because the pages are not subject to replacement, page table lookups are not required.

• Faster overall memory performance: On virtual memory systems, each memory operation is actually two abstract memory operations. Because there are fewer pages to work on, the possible bottleneck on page table access is clearly avoided.

• Oracle 11g Automatic Memory Management (AMM) and HugePages are not compatible. You must disable AMM on 11g to be able to use HugePages.

The Size of a HugePageHugePage sizes vary from 2 MB to 256 MB based on kernel version and hardware architecture. The following table shows the sizes of HugePages on different configurations:

Hardware Platform Source Code Tree Kernel 2.4 Kernel 2.6

Linux x86 (IA32) i386 4 MB 4 MB

Linux x86-64 (AMD64, EM64T) x86_64 2 MB 2 MB

Linux Itanium (IA64) ia64 256 MB 256 MB

IBM Power Based Linux (PPC64) ppc64/powerpc N/A 16 MB

IBM zSeries Based Linux s390 N/A N/A

IBM S/390 Based Linux s390 N/A N/A

Configuring HugePagesConfiguring your Linux OS for HugePages is a delicate process. If you do not configure properly, the system may experience serious problems such as:

• HugePages not used (HugePages_Total = HugePages_Free), wasting the amount of memory configured for HugePages

• Poor database performance

• System running out of memory or excessive swapping

• Some or any database instance cannot be started

• Crucial system services failing (for example, CRS)

Oracle Linux System Administration 23 - 15

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 260: D74508GC10_sg2

General guidelines exist to configure HugePages for more than one Oracle RDBMS instance. The following guidelines exist for the different OS versions and hardware architectures:

• “How to Configure RHEL 3.0 32-bit for Very Large Memory with ramfs and hugepages”

• “How to Configure Asianux 1.0 32-bit for Very Large Memory with ramfs and hugepages”

• “How to Configure RHEL 4 32-bit for Very Large Memory with ramfs and hugepages”

• “How to Configure SuSE SLES 9 32-bit for Very Large Memory with ramfs and hugepages”

• “HugePages on 64-bit Linux”

HugePages on 64-bit LinuxThe following are the configuration steps for configuring HugePages on 64-bit Linux. The configuration steps provided here are primarily for Oracle Linux, but the same concepts and configurations should apply to other Linux distributions. These configuration steps guide you to do a persistent system configuration, which requires a reboot of the system.Step 1: Have the memlock user limit set in /etc/security/limits.conf file. Set the value (in KB) slightly smaller than installed RAM. If you have 64 GB RAM installed, set:

soft memlock 60397977

hard memlock 60397977

Oracle Linux System Administration 23 - 16

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Configuring HugePages

• Guidelines exist for different OS versions and hardware architectures.

• Configuring HugePages on 64-bit Linux:– Set the memlock user limit in

/etc/security/limits.conf slightly smaller than installed RAM.

– Disable AMM by setting MEMORY_TARGET and MEMORY_MAX_TARGET to zero.

– Use the hugepages_settings.sh script to calculate the recommended value for the vm.nr_hugepages parameter.

– Edit /etc/sysctl.conf and set the vm.nr_hugepagesparameter.

– Reboot your system.

• To check: grep HugePages /proc/meminfo

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 261: D74508GC10_sg2

There is no harm in setting this value larger than your SGA requirements. The parameters are set by default on:• Oracle Linux with oracle-validated package installed• Oracle Exadata DB compute nodes

Step 2: Log on again to the Oracle product owner account (for example. oracle) and check the memlock limit:

$ ulimit -l

60397977

Step 3: If you have Oracle Database 11g or later, the default database created uses the Automatic Memory Management (AMM) feature which is incompatible with HugePages. Disable AMM before proceeding. To disable AMM, set the initialization parameters MEMORY_TARGETand MEMORY_MAX_TARGET to 0 (zero).

Step 4: Make sure that all your database instances are up (including ASM instances) as they would run on production. Use the script hugepages_settings.sh in Document 401749.1 to calculate the recommended value for the vm.nr_hugepages kernel parameter:

$ ./hugepages_settings.sh

...

Recommended setting: vm.nr_hugepages = 1496

You can also calculate a proper value for the parameter yourself but that is not advised if you do not have extensive experience with HugePages.Step 5: Edit the file /etc/sysctl.conf and set the vm.nr_hugepages parameter:

vm.nr_hugepages = 1496

This will cause the parameter to be set properly with each reboot.Step 6: Stop all the database instances and reboot the server.The performed configuration is basically based on the RAM installed and combined size of SGA of database instances that you are running. If any of the following changes occur, you should revise your HugePages configuration to make it suitable to the new memory framework:• Changes to the amount of RAM installed for the Linux OS• New database instance(s) introduced• Changes to SGA size or configuration for one or more database instances

Check and Validate the ConfigurationAfter the system is rebooted, make sure that your database instances (including the ASM instances) are started. Automatic startup via OS configuration or CRS, or manual startup (whichever method you use) should have been performed. Check the HugePages state from /proc/meminfo:

# grep HugePages /proc/meminfo

HugePages_Total: 1496

HugePages_Free: 485

HugePages_Rsvd: 446

HugePages_Surp: 0

The values in the output will vary. To make sure that the configuration is valid, the HugePages_Free value should be smaller than HugePages_Total and there should be some HugePages_Rsvd. The sum of Hugepages_Free and HugePages_Rsvd may be smaller than your total combined SGA as instances allocate pages dynamically and proactively as needed.

Oracle Linux System Administration 23 - 17

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 262: D74508GC10_sg2

The Oracle Database Smart Flash Cache (DBSFC) feature is available for both Oracle Solaris and Oracle Linux customers with the 11gR2 database. DBSFC allows you to extend the Oracle Buffer Cache in memory (SGA) by using secondary flash-based storage. This flash-based storage can be presented to the database through a file on a file system on flash storage, through a raw disk device (flash-based), or by adding flash storage to Oracle ASM and creating a region inside ASM. See http://www.oracle.com/technetwork/articles/servers-storage-admin/smart-flash-cache-oracle-perf-361527.html for more information.

DBSFC is a read-only cache extension that helps with read-only/read-mostly workloads. It contains clean blocks that are removed from the buffercache/sga and now first get placed in this extended cache. A subsequent read can then be from this fast storage instead of from the originating data files. When a block gets modified, it is modified in the standard database buffer cache, written to disk, and copied over into the flash cache.

The white paper referenced previously provides the details on how to use it and how to configure it in an Oracle Linux environment. But to summarize, you simply specify DB_FLASH_CACHE_FILE and DB_FLASH_CACHE_SIZE in the Oracle Initialization File, init.ora. Any Oracle Database customer using Oracle Linux can use this feature.

Oracle Linux System Administration 23 - 18

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Oracle Database Smart Flash Cache (DBSFC)

• DBSFC:– Is available for both Oracle Solaris and Oracle Linux

customers with the 11gR2 database

– Allows you to extend the Oracle Buffer Cache in memory (SGA) using secondary flash based storage

– Helps with read-only/read-mostly workloads

• When a block gets modified, it is modified in the standard database buffer cache, written to disk and copied over into the flash cache.

• A subsequent read can then be from this fast storage instead of from the originating data files.

• See http://www.oracle.com/technetwork/articles/servers-storage-admin/smart-flash-cache-oracle-perf-361527.html.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 263: D74508GC10_sg2

The Oracle RDBMS Pre-install RPM package (oracle-rdbms-server-11gR2-preinstall) is designed specifically for Oracle Linux 6 to aid in the installation of the Oracle Database. You can complete most pre-installation configuration tasks by using this package, which is now available from the Unbreakable Linux Network or from the Oracle Public Yum repository.

This package was formerly known as oracle-validated. For Oracle Linux 6 and newer, the name of the package was changed. There will not be an “oracle-validated” RPM for Oracle Linux 6, and there will not be an “oracle-rdbms-preinstall” RPM for Oracle Linux 5. The key difference between oracle-validated and the new pre-install RPM is that the new package sets the bare minimums for Oracle DB 11gR2 installations, instead of the testing maximums set with oracle-validated. The new pre-install RPM will configure an Oracle Linux 6 machine so that you can immediately run the OUI database installation.

The pre-install package is available for x86_64 only. Specifically, the package:

• Causes the download and installation of various software packages and specific versions needed for database installation, with package dependencies resolved via yum

• Creates the user oracle and the groups oinstall and dba, which are the defaults used during database installation

Oracle Linux System Administration 23 - 19

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Oracle Pre-Install RPM

Oracle RDBMS Pre-Install RPM for Oracle Linux 6:

• Completes most pre-installation configuration tasks

• Is different from Oracle Validated RPM for Oracle Linux 5

• Downloads and installs various software packages and specific versions needed for database installation

• Creates the user oracle and the groups oinstall and dba

• Modifies kernel parameters in /etc/sysctl.conf

• Sets hard and soft shell resource limits in /etc/security/limits.conf

• Sets numa=off in the kernel boot parameters for x86_64 machines

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 264: D74508GC10_sg2

• Modifies kernel parameters in /etc/sysctl.conf to change settings for shared memory, semaphores, the maximum number of file descriptors, and so on

• Sets hard and soft shell resource limits in /etc/security/limits.conf, such as the number of open files, the number of processes, and stack size to the minimum required based on the Oracle Database 11g Release 2 Server installation requirements

• Sets numa=off in the kernel boot parameters for x86_64 machines

Further details are available at http://oss.oracle.com/pipermail/el-errata/2012-March/002727.html.

Oracle Linux System Administration 23 - 20

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 265: D74508GC10_sg2

If you install stand-alone or Oracle RAC Databases, you must have space available on Oracle ASM for Oracle Clusterware files (voting disks and Oracle Cluster Registries), and for Oracle Database files. Creating Oracle Clusterware files on block or raw devices is no longer supported for new installations.

ASM consists of a specialized Oracle instance and a set of disk groups that are managed through the ASM instance. ASM performs the functions of a volume manager and a file system. ASM can be used for single instance or clustered databases. When using Oracle ASM for either the Oracle Clusterware files or Oracle Database files, Oracle creates one Oracle ASM instance on each node in the cluster, regardless of the number of databases.

The ASM instance manages disks in disk groups. An ASM instance must be configured and running before a database instance can access ASM files. This configuration is performed automatically if the Database Configuration Assistant is used for database creation.

A disk group is a set of disk devices that ASM manages as a single unit. Each disk device is a block device: a partition, logical volume, a RAID array, or a single disk. ASM spreads data evenly across all the devices in the disk group to optimize performance and usage. You can add or remove disk devices from a disk group without shutting down the database. When you add or remove devices, ASM rebalances the files across the disk group. You can create multiple disk groups to handle specific tasks, such as database backup and recovery operations, in addition to database file storage activities.

Oracle Linux System Administration 23 - 21

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Oracle ASM

• For stand-alone or Oracle RAC databases, you must have space available on Oracle ASM.– Creating Oracle Clusterware files on block or raw devices is

no longer supported.

• ASM performs the functions of a volume manager and a file system.

• ASM consists of a specialized Oracle instance and a set of disk groups that are managed through the ASM instance.

• A disk group is a set of disk devices that ASM manages.– Each disk device can be a partition, a logical volume, a RAID

array, or a single disk.

– ASM spreads data evenly across the disk group to optimize performance and usage.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 266: D74508GC10_sg2

Grid Installation Owner and ASMOPERDuring installation, in the Privileged Operating System Groups window, it is now optional to designate a group as the OSOPER for ASM group. If you choose to create an OSOPER for ASM group, then you can enter a group name configured on all cluster member nodes for the OSOPER for ASM group. In addition, the Oracle Grid Infrastructure installation owner no longer is required to be a member.

Oracle ASM Job Role Separation Option with SYSASMThe SYSASM privilege that was introduced in Oracle ASM 11g release 1 (11.1) is now fully separated from the SYSDBA privilege. If you choose to use this optional feature, and designate different operating system groups as the OSASM and the OSDBA groups, then the SYSASM administrative privilege is available only to members of the OSASM group. The SYSASM privilege also can be granted using password authentication on the Oracle ASM instance.

OSASM is an operating system group that is used exclusively for Oracle ASM. Members of the OSASM group can connect as SYSASM using operating system authentication and have full access to Oracle ASM.

You can designate OPERATOR privileges (a subset of the SYSASM privileges, including starting and stopping Oracle ASM) to members of the OSOPER for ASM group.

Providing system privileges for the storage tier by using the SYSASM privilege instead of the SYSDBA privilege provides a clearer division of responsibility between Oracle ASM administration and database administration, and helps to prevent different databases using the same storage from accidentally overwriting each other’s files.

Oracle Linux System Administration 23 - 22

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 267: D74508GC10_sg2

If you intend to use ASM for database storage for Linux, Oracle recommends that you install the ASMLib RPMs to simplify storage administration.

ASMLib is free, optional software for the ASM feature of Oracle Database. ASMLib simplifies the management and discovery of ASM disks and makes I/O processing and kernel resource usage with ASM storage more efficient. It provides persistent paths and permissions for storage devices used with ASM, eliminating the need for updating udev or devlabel files with storage device paths and permissions.

ASMLib also contains Linux data integrity features. To enable Oracle application-to-disk data integrity checking, ASMLib must be used. The ASMLib kernel driver is what connects the data integrity dots between Oracle database and ASM. See the following for more information: http://oss.oracle.com/~mkp/docs/data-integrity-webcast.pdf.

ASMLib updates are delivered via Unbreakable Linux Network (ULN) for both Oracle Linux or Red Hat Enterprise Linux installations. For Oracle Linux 6, to use ASMLib, you must replace any Red Hat kernel with Unbreakable Enterprise Kernel. For Oracle Linux 5, Oracle does provide ASMLib for the Red Hat compatible kernel. Refer to the following for more information: http://ovmjira.us.oracle.com/confluence/display/OLPM/Oracle+Linux+FAQ#OracleLinuxFAQ-ASMLib.

Oracle Linux System Administration 23 - 23

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

ASM Library Driver (ASMLib)

• ASMLib simplifies the management of ASM disks.

• ASMLib has three components:– oracleasm-support: Provides user space shell scripts,

and is included with the Oracle Linux distribution– oracleasmlib: Provides the user space library, and is

installed from Unbreakable Linux Network (ULN) – oracleasm: Is the kernel driver included in kernel-uek

• To configure ASMLib:– # oracleasm configure –i

• To mark disks as ASM disks:– # oracleasm createdisk ASM_DISK_NAME

candidate_disk

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 268: D74508GC10_sg2

ASMLib has three components:

• oracleasm-support: This package provides user space shell scripts.

• oracleasmlib: This package provides the user space library and is closed source.

• oracleasm: This is the kernel driver and is included in kernel-uek.

The oracleasm-support package is included with the Oracle Linux distribution. Install the oracleasmlib package from ULN. The oracleasm kernel driver is included in the UEK. You do not need to install any driver package when using this kernel.

The following web page describes getting ASMLib from ULN.

http://www.oracle.com/technetwork/server-storage/linux/uln-095759.html

The full installation guide is part of the Oracle Database Documentation.

Configuring ASMLibConfigure ASMLib by logging in as root and entering the following command:

# oracleasm configure –i

You are prompted to provide the following information:

• The default user to own the driver interface

• The default group to own the driver interface

• Whether to start Oracle ASM library driver on boot

• Whether to fix permissions of Oracle ASM disks on boot

The user who owns the driver interface should be the same user who owns the software installation, typically oracle. The group to own the driver interface should be the group used for DBAs, typically dba. You want ASMLib to start when the system boots and to fix permissions of ASM disks. If you enter the command oracleasm configure without the –i flag, then you are shown the current configuration. After it is configured, to load and initialize the ASMLib driver, run the oracleasm utility with the init option as shown:

# oracleasm init

Marking Disks as ASM DisksA disk that is configured for use with ASM is known as a candidate disk. For OUI to recognize partitions as Oracle ASM disk candidates, you must log in as root and mark the disk partitions that Oracle ASM can use. Disks are marked by using the createdisk option. Use the following syntax, where ASM_DISK_NAME is the name of the Oracle ASM disk group, and candidate_disk is the name of the disk device that you want to assign to that disk group:

# oracleasm createdisk ASM_DISK_NAME candidate_disk

Meaningful names can be assigned for each disk. You can create multiple disk groups. By providing descriptive names to each disk, you have an easier time assigning disks to disk groups when creating the ASM instance. When choosing names for drives, consider using the physical location of the drive in the name. Example:

# oracleasm createdisk VOL1 /dev/sda1

# oracleasm createdisk VOL2 /dev/sdb1

# oracleasm createdisk VOL3 /dev/sde1

To make the disks available, use the scandisks option as shown:

# /etc/init.d/oracleasm scandisks

Oracle Linux System Administration 23 - 24

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 269: D74508GC10_sg2

To administer the Automatic Storage Management library driver and disks, use the oracleasm initialization script with different options. The following summarizes the available options for the oracleasm script:

• configure: Use this to configure the Automatic Storage Management library driver.

• init/exit: Use this to change the behavior of the ASMLib when the system starts. The init option causes the ASMLib driver to load when the system starts.

• createdisk: Use this to mark a disk device for use with the ASMLib and give it a name.

• deletedisk: Use this to unmark a named disk device. Do not use this command to unmark disks that are being used by an ASM disk group. You must drop the disk from the disk group, before you unmark it. The syntax is as follows:

# oracleasm deletedisk DISKNAME

• querydisk: Use this to determine whether a disk device or disk name is being used by the ASMLib. The syntax is as follows:

# oracleasm querydisk {DISKNAME|devicename}

Oracle Linux System Administration 23 - 25

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Using ASMLib Commands

Available options for the oracleasm script:

• configure: Configure the ASM library driver.

• init/exit: Change the behavior of the ASMLib when the system starts.

• createdisk: Mark a disk device for use with ASM.

• deletedisk: Unmark a named disk device.

• querydisk: Determine whether a disk device or disk name is being used by the ASMLib.

• listdisks: List the disk names of marked disks.

• scandisks: Enable cluster nodes to identify which shared disks have been marked as ASMLib disks on another node.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 270: D74508GC10_sg2

• listdisks: Use this to list the disk names of marked ASMLib disks.

• scandisks: Use this to enable cluster nodes to identify which shared disks have been marked as ASMLib disks on another node.

ASM Rebalance OperationsASM attempts to use that same amount of space on all the disks of a disk group. The data is striped and mirrored across all the disks of a disk group at the file level. Even though the disk group has a default for mirroring and striping, each file can have its own stripe and mirror properties.

There are two modes of striping:

• 1 MB allocation units

• 128 KB units

The redundancy can be set to one of the following:

• Normal: Normal redundancy is two-way mirroring.

• High: High redundancy is three-way mirroring.

• External: External redundancy does no mirroring. It assumes that the disk volumes are mirrored by some external means, such as RAID 1 arrays.

When a disk is added to a disk group, a rebalance operation is started. ASM moves a set of data blocks (allocation units) from the existing disks to the new disk. The number of allocation units moved is proportional to the size of the new disk compared to the total size of the disk group. If a disk is dropped from the disk group, or fails, then the data is redistributed across the remaining disks to re-establish the redundancy requirements.

The rebalance operation is controlled through an ASM instance parameter or by a parameter associated with the operation. This parameter is named ASM_POWER_LIMIT and can be set from 0-11. A setting of 0 stops the rebalance, and 11 takes all the resources that can be effectively used to minimize the time to complete the operation. A setting of 1 is the default to prevent rebalance operations from interfering with normal database operations.

Whenever a disk group is altered by adding or dropping disks, a rebalance operation is triggered. If there is insufficient remaining disk space for a drop operation, the alter command fails. The alter disk group command does not complete until the rebalance operation is finished.

Oracle Linux System Administration 23 - 26

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 271: D74508GC10_sg2

Oracle has made the Oracle Cluster File System Version 2 (OCFS2) available under GNU General Public License. OCFS2 is a general purpose, POSIX-compliant, shared-disk cluster file system designed for use with Oracle database files in a Linux-based cluster environment.

OCFS2 can store data files as well as binaries and configuration files, and can be used with any application. Cluster-aware applications can make use of parallel I/O for higher performance. Other applications, if not able to benefit from parallel I/O, can make use of the file system to provide a failover setup to increase the availability of the application.

Apart from being used with Oracle’s RAC database product, OCFS2 is used to provide scalable web servers, file servers, failover mail servers, and for hosting virtual machine images.

Some of the features of the OCFS2 are:

• Variable block and cluster sizes

• Flexible allocations (extents, sparse, unwritten extents with the ability to punch holes)

• Journaling (ordered and writeback data journaling modes)

• Endian and architecture neutral (x86, x86_64, ia64, and ppc64)

• In-built clusterstack with a Distributed Lock Manager

• Support for buffered, direct, asynchronous, splice, and memory-mapped I/Os

Oracle Linux System Administration 23 - 27

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Oracle Cluster File System Version 2 (OCFS2)

• OCFS2 is:– A shared-disk cluster file system designed for use with

Oracle database files in a Linux environment

– Used with Oracle RAC database, web servers, file servers, mail servers, virtualization, and so on

• Features include:– Variable block and cluster sizes

– Flexible allocations

– Journaling

– Endian and architecture neutral

– In-built clusterstack with a Distributed Lock Manager

– Support for buffered, direct, asynchronous, splice, and memory-mapped I/Os

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 272: D74508GC10_sg2

The OCFS2 packages provide the utilities and documentation required to install and use the OCFS2 filesystem. The steps to install and use the OCFS2 file system are summarized:

1. Install the Unbreakable Enterprise Kernel (UEK)

2. Install the ocfs2-tools package and optionally, install the ocfs2console package.

3. Configure the cluster.

4. Configure O2CB to start on boot. This is the cluster service stack for OCFS2.

5. Format volumes.

6. Mount the cluster.

The kernel component of OCFS2 is bundled with the UEK, that is, it is provided as part of the kernel-uek RPM package. The user-space component includes two packages:

• ocfs2-tools: Command-line tools

• ocfs2console: GUI

These packages are included with the Oracle Linux distribution and are installed as follows:# yum install ocfs2-tools ocfs2console

Oracle Linux System Administration 23 - 28

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Using OCFS2

• The kernel component of OCFS2 is bundled with the UEK.

• The user space component is included in the distribution:– ocfs2-tools: Command-line tools

– ocfs2console: GUI

• Implementation steps include:1. Install the UEK and OCFS2 RPMS

2. Configure the cluster.

3. Configure O2CB (cluster service stack) to start at boot time.

4. Format volumes.

5. Mount the cluster.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 273: D74508GC10_sg2

Two sysctl values must be set for O2CB to function properly. The first parameter is panic_on_oops which must be enabled to turn a kernel oops into a panic. If a kernel thread required for O2CB to function crashes, the system must be reset to prevent a cluster hang.

The other related sysctl parameter is panic, which specifies the number of seconds after a panic that the system is auto-reset. Setting this parameter to zero disables autoreset, in which case the cluster requires manual intervention. This is not recommended in a cluster environment.

To manually enable panic_on_oops and set a 30 second timeout for reboot on panic:

# echo 1 > /proc/sys/kernel/panic_on_oops

# echo 30 > /proc/sys/kernel/panic

To enable the above on every reboot, add the following to /etc/sysctl.conf:

kernel.panic_on_oops = 1

kernel.panic = 30

Refer to the “System Configuration” lesson for information on /etc/sysctl.conf and modifying kernel settings.

Oracle Linux System Administration 23 - 29

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Kernel Configuration

• Two sysctl values must be set for O2CB to function properly:– panic_on_oops: Enable to turn a kernel oops into a panic.

– panic: Specify the number of seconds after a panic that the system is auto-reset.

• To manually enable panic_on_oops and set a 30 sec timeout for reboot on panic:– # echo 1 > /proc/sys/kernel/panic_on_oops

– # echo 30 > /proc/sys/kernel/panic

• Create entries in /etc/sysctl.conf to preserve the settings:– kernel.panic_on_oops = 1

– kernel.panic = 30

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 274: D74508GC10_sg2

Configuring the OCFS2 ClusterOCFS2 volumes can be mounted as clustered or local (single-node) volumes. If you only want to mount volumes locally, you can skip the cluster configuration and go straight to formatting. Otherwise, you must configure the O2CB cluster.

The O2CB cluster stack configuration consists of the cluster layout and the cluster timeouts. The cluster layout is specified in /etc/ocfs2/cluster.conf. All the nodes in the cluster are specified in this one configuration file. This file must be the same on all the nodes in the cluster. You can add new nodes to the cluster dynamically, but any other change, such as name and IP address, requires the cluster to be restarted for the changes to take effect. The default cluster name is ocfs2. The node name of each node in the cluster must be the same as the host name.

It is easy to populate the /etc/ocfs2/cluster.conf file and propagate using the GUI utility, ocfs2console. It can also be done manually as long you format the file correctly. Use the following command as the root user to start the OCFS2 console:

# ocfs2console

Propagating the OCFS2 Cluster ConfigurationThe OCFS2 configuration file must be the same on all the nodes. It is recommended that you use ocfs2console to propagate the file to all the nodes in the cluster.

Oracle Linux System Administration 23 - 30

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Using OCFS2

• The main configuration file is /etc/ocfs2/cluster.conf.– All the nodes in the cluster are specified in this file.

– The file must be the same on all the nodes in the cluster.

• Use GUI utility, ocfs2console, to populate and propagate the configuration file.

• Start the cluster service:– # service o2cb configure

• Use the GUI utility, ocfs2console, to format volumes.

• Command-line utilities also available:– mkfs.ocfs2: To create an OCFS2 file system

– tunefs.ocfs2: To change OCFS2 file system parameters

• Edit /etc/fstab to mount volumes at boot time.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 275: D74508GC10_sg2

The OCFS2 console uses ssh to transfer the files. If you want to avoid being prompted for a password, the ssh user equivalency must be set up for each node. Refer to the OpenSSH lesson to configure ssh to connect to a remote system without supplying a password.

Starting and Stopping the Cluster ServiceSet the configuration information for the O2CB cluster with the following command:

# service o2cb configure

The configure command prompts for the configuration information and starts the cluster. It does not set up the service to start automatically at boot time. To start the o2cb and ocfs2 services at boot time, use the chkconfig commands as follows:

# chkconfig o2cb on

# chkconfig ocfs2 on

Formatting OCFS2 VolumesUse the OCFS console to format the volumes with the OCFS2 file system. The OCFS2 console displays available devices in the format dialog box. The cluster must be online before formatting a volume. This ensures that some other node has not already mounted the volume.

The format utility, mkfs.ocfs2, can also be used. This utility allows a user to enable and disable specific features by using the --fs-features option. The features are provided as a comma-separated list. After formatting, you can toggle features by using the tune utility, tunefs.ocfs2. This is an offline operation. The volume must be umounted across the cluster.

The label is a must for ease of management in a cluster environment. Labels are used in the /etc/fstab file to make the volume independent of the physical device. The label can be changed after the formatting by using tunefs.ocfs2 or the console utility. You can also extend an OCFS2 file system by using the tunefs.ocfs2 utility. You cannot shrink an OCFS2 file system, however.

Mounting Volumes at Boot TimeOCFS2 volumes can be mounted at boot time. If the o2cb cluster service and ocfs2 service are started at boot and /etc/fstab is configured, then the ocfs2 volumes are mounted when the ocfs2 service starts. To mount the volumes, you must modify the /etc/fstab file to specify the volumes, mount points, and mount options. The entries are similar to the following:

/dev/sdf2 /u01 ocfs2 _netdev,datavolume,nointr 0 0

The _netdev option is required for OCFS2 volumes. It indicates that the volumes are mounted after network startup and dismounted before network shutdown. This implies that the start number of the network services in the rc files must be less than the start number of the ocfs2service. Any services that ocfs2 depends on must be started before the ocfs2 service.

Volumes can also be mounted by label:

LABEL=Oradata01 /u04/oradata ocfs2 _netdev,datavolume,nointr 0 0

If mounting clustered volumes, start the O2CB cluster service before attempting any mounts.

# service o2cb online

If the cluster service is disabled, the start and stop commands exit without doing anything. If the cluster is enabled, start loads the modules and places the cluster online.

With the ocfs2 service, use the start command to mount the OCFS2 volumes defined in /etc/fstab, and use stop to unmount the mounted OCFS2 volumes.

Oracle Linux System Administration 23 - 31

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 276: D74508GC10_sg2

The connectivity of the nodes and the storage devices must be assured to prevent file system corruption. When a volume is mounted by a node, a heartbeat is established. That is, each node that has a file system mounted writes every two seconds to its block in the heartbeat system file. Each node opens a TCP connection to every node that establishes a heartbeat. If the TCP connection is lost for more than 10 seconds, the node is considered dead, even if the heartbeat is continuing. If a node loses network connectivity to more than half of the heartbeating nodes, it has lost the quorum and fences itself off from the cluster. OCFS2 panics the node that is fenced off. A surviving node then replays the journal of the fenced node to ensure that all updates are on disk.

The heartbeat threshold determines how long the cluster waits for a node to reestablish communication before it is declared dead. The default is 7 cycles plus 2 cycles—that is, 9*2 seconds or 18 seconds. The default heartbeat threshold setting is not long enough for most multipath solutions. O2CB_HEARTBEAT_THRESHOLD should be set to the timeout value of the I/O layer. If the timeout is 60 seconds, set the O2CB_HEARTBEAT_THRESHOLD to 31; and if the timeout is 120 seconds, set it to 61. The heartbeat threshold is set in the /etc/sysconfig/o2cb file and must be the same on all nodes of the cluster.

O2CB also requires iptables (firewalling) to be either disabled or modified to allow network traffic on the private network interface. The port used by O2CB is specified in the cluster.conf file. Refer to the Security Administration lesson for using iptables.

Oracle Linux System Administration 23 - 32

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

OCFS2 Heartbeat

• The O2CB cluster stack uses a heartbeat to determine whether a node is dead or alive.– Connectivity must be assured to prevent file system

corruption.

• If a node loses network connectivity to more than half of the heartbeating nodes, it fences itself off from the cluster.– OCFS2 panics the node that is fenced off.

• The O2CB cluster heartbeat parameter is set in /etc/sysconfig/o2cb:– O2CB_HEARTBEAT_THRESHOLD:

• O2CB also requires iptables to be disabled or modified to allow network traffic on the private network interface.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 277: D74508GC10_sg2

Oracle Linux System Administration 23 - 33

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Quiz

Which of the following statements is true with regards to ASM?

a. ASMLib is required to use ASM.b. The oracleasm kernel driver is included in the Red Hat

Compatible Kernel (RHCK).

c. For Oracle Universal Installer (OUI) to recognize partitions as Oracle ASM disk candidates, you must mark the disk partitions that Oracle ASM can use.

d. A RAID array cannot be included in an ASM disk group.

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 278: D74508GC10_sg2

Oracle Linux System Administration 23 - 34

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Summary

In this lesson, you should have learned how to:

• Prepare your Oracle Linux server for Oracle Database installation

• Create Oracle software user and group accounts

• Set kernel parameters for Oracle Database

• Set Oracle database shell limits

• Configure HugePages

• Configure Oracle Database Smart Flash Cache (DBSFC)

• Use Oracle pre-install RPM

• Install and use ASMLib

• Install and use OCFS2

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 279: D74508GC10_sg2

Oracle Linux System Administration 23 - 35

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Practice 23: Overview

The practices for this lesson cover the following:

• Installing and running Oracle RDBMS Pre-Install RPM for Oracle Linux 6

• Installing and configuring ASMLib

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.

Page 280: D74508GC10_sg2

Ora

cle

Uni

vers

ity a

nd (O

racl

e C

orpo

ratio

n) u

se o

nly.

Thes

e eK

it m

ater

ials

are

to b

e us

ed O

NLY

by

you

for t

he e

xpre

ss p

urpo

se S

ELF

STU

DY.

SH

ARIN

G T

HE

FILE

IS S

TRIC

TLY

PRO

HIB

ITED

.