IPTables, NFS, Samba, Sendmail PDF
IPTables, NFS, Samba, Sendmail PDF
Version 3.1
RH302
-2-
RH302
-3-
RH302
RHCT skills
-4-
RH302
-5-
RH302
RHCE skills
-6-
RH302
The Red Hat exams are based on your knowledge of Red Hat
Enterprise Linux 5. When you take the RHCT exam, it is the
-7-
RH302
-8-
RH302
Section 1
-9-
RH302
- 10 -
RH302
-l Æ Long Listing
-r Æ In reverse Order
-s Æ With Size
-R Æ With Sub-contents
When you use the ls –l command you can see the long
listing. i.e
d Æ Direcotry
l Æ Link File
- 11 -
RH302
p Æ Named Pipe
s Æ Socket
r Æ Read
w Æ Write
x Æ Execute
- 12 -
RH302
-i Æ Interactive
-R Æ Recursive Copy
-F Æ Forcely Copy
mv : Move Command
-i Æ Interactive
-f Æ Forcely
- 13 -
RH302
-R Æ Recursively
- man command
- info command
- command --help
- 14 -
RH302
To Start vi:
- vi
or
- vi filename
Shortcuts Description
H Moves cursor to Left
J Moves cursor to Down
K Moves cursor to Up
L Moves cursor to right
W Moves cursor one word ahead
B Moves cursor one work back
( Moves cursor to one sentence
back
) Moves cursor to one sentence
forward
{ Moves cursor to one paragraph
above
} Moves cursor to one paragraph
below
- 15 -
RH302
Shortcuts Description
A Append after the Current
Cursor Position
I Insert before the Current
Cursor Position
O Append new blank line below
A Append to end of line
I Insert at the beginning of
line
O Append new blank line above
Shortcuts Description
X Deletes current Character
Nx Deletes n characters
Dd Deletes Current Line
Ndd Deletes n lines
Dw Deletes the current word
Ndw Deletes the n words
Shortcuts Description
- 16 -
RH302
Shortcuts Description
/text Search the text in forward
direction
?text Search the text in backward
direction
N Find Next in same direction
N Find Next in opposite
direction
Shortcuts Description
:wq Save and Exit
:w Write into Disk
- 17 -
RH302
- 18 -
RH302
Device Recognization
IDE Drive:
SCSI Disk:
/dev/sda, /dev/sdb
Mounting Floppy
or
mount /media/floppy
Mounting CD-ROM
- 19 -
RH302
or
mount /media/cdrom
i. mkdir /media/flash
ii. mount /dev/sda /media/flash
You can test the archive file by listing the all bundles
files.
- 20 -
RH302
- 21 -
RH302
EMPLOYEE_NAME=”ram”
Syntax: functionname()
command 1
command 2
command 3
- 22 -
RH302
Example:
- 23 -
RH302
Example:
Example:
lpq –Pprintername
Example:
- 24 -
RH302
lprm printqueueid
- 25 -
RH302
Now you can work with the most accurate command for
search.
Example:
- 26 -
RH302
See by example:
- 27 -
RH302
Example:
head /etc/passwd
head –n 5 /etc/passwd
Example:
tail /etc/passwd
tail –n 20 /etc/passwd
-r : Reverse Order
-f : Ignore case
- 28 -
RH302
-u : Unique Sort
-t : Field Separator
Example: wc filename
- 29 -
RH302
Section 2
- 30 -
RH302
• Installing Kernel
• About User, Group and Permission
• Managing Users
• Managing Groups
• Setting Permissions to user, group and others
• About Special Permissions
• Working with Startup Scripts
• NIS Client Configuration
• Installing Local and Networked Printer
• Managing Printer through HTTP
• Scheduling Cron Job
• X Window System
• Troubleshooting X Window System
• Configuring RAID Level 0/1/5/6
• Troubleshooting with RAID
• Configuring LVM
• Troubleshooting with LVM
• Quota Implementation
• Troubleshooting Linux boot process
- 31 -
RH302
Go by example:
1. mkdir /var/ftp/rhel4
2. 1st CD
3. mount /media/cdrom
4. cp –rf /media/cdrom/* /var/ftp/rhel4
5. umount /media/cdrom
6. 2nd , 3rd and 4th CD
- 32 -
RH302
7. mount /media/cdrom
8. cp –f /media/cdrom/RedHat/RPMS/*
/var/ftp/rhel4/RedHat/RPMS
9. umount /media/cdrom
10. chkconfig vsftpd on
11. service vsftpd restart | start
- 33 -
RH302
/data *.example.com(rw,sysnc)
trusted.cracker.org(ro,sysnc) : which line shares the /data
directory from the local server to all the member of
example.com domain as well as trusted.cracker.org host. All
member of example.com can access the shared data in read
and write access mode but the trusted.cracker.org host can
access only in read only mode.
Example:
/var/ftp/rhel4 *(ro,sync)
#chkconfig nfs on
Starting Installation:
- 34 -
RH302
Or
When you start the Installation using the boot.iso cd, you
will get the boot: prompt where you will get more options.
In boot prompt, type linux askmethod command, which will
ask you to select the different installation method. Select
the Language, Keyboard options, if RHEL is already
installed in your system, it will ask you either fresh
installation or upgrade.
- 35 -
RH302
Server: 192.168.0.254
- 36 -
RH302
- 37 -
RH302
- 38 -
RH302
Select the packages require to you When you get the package
selection dialog some default packages are selected, if you
require other then default packages select custom packages
selection option then select the packages required to you.
Kickstart Installation:
- 39 -
RH302
file. If you can modify that file, modify as per your needs
another way you have by using the GUI based kickstart
installation file preparation.
# system-config-kickstart
#System language
lang en_US
#Language modules to install
- 40 -
RH302
langsupport en_US
#System keyboard
keyboard us
#System mouse
mouse
#Sytem timezone
timezone Asia/Katmandu
#Root password
rootpw --iscrypted $1$YNZXHrUK$nIIlW5J5YcibwIcjwgcDM0
#Reboot after installation
reboot
#Install OS instead of upgrade
install
#Use Web installation
url --url ftp://192.168.0.75/pub
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr yes
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part / --fstype ext3 --size 1000
part /boot --fstype ext3 --size 500
part /home --fstype ext3 --size 1000
part /var --fstype ext3 --size 1000
part /usr --fstype ext3 --size 6000
part swap --size 256
#System authorization infomation
auth --useshadow --enablemd5
- 41 -
RH302
#Network information
network --bootproto=dhcp --device=eth0
#Firewall configuration
firewall --disabled
#XWindows configuration information
xconfig --depth=32 --resolution=800x600 --
defaultdesktop=GNOME
#Package install information
%packages --resolvedeps
@ base-x
@ gnome-desktop
@ editors
@ graphical-internet
@ text-internet
@ office
@ server-cfg
@ web-server
@ mail-server
@ smb-server
@ dns-server
@ ftp-server
@ network-server
@ admin-tools
@ system-tools
@ printing
%post
useradd student
passwd -d student
- 42 -
RH302
- 43 -
RH302
- 44 -
RH302
- 45 -
RH302
- 46 -
RH302
- 47 -
RH302
- 48 -
RH302
#grub-md5-crupt
Default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
- 49 -
RH302
/boot/grub/splash.xpm.gz.
hiddenmenu
title Red Hat Enterprise Linux WS (2.6.9-5.EL)
#password=redhat : Setting OS load password, when user try
to load Operating System, it will ask for the password, if
user will give correct then only Operating System will
load.
password --md5 output of grub-md5-crypt
root (hd0,0)
kernel /vmlinuz-2.6.9-5.EL ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.9-5.EL.img : Initial RAM disk file.
- 50 -
RH302
id:5:initdefault:
# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit
l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
- 51 -
RH302
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6
# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
- 52 -
RH302
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
0 - halt
1, s , single - Single user mode
2 – Multiuser
3 - Full multiuser mode
4 - unused
5 – Multi user with GUI (Graphical User Interface).
6 - reboot
id:5:initdefault:
The above line in /etc/inittab file defines the default
runlevel to boot system. If you left blank in the runlevel
value, System will boot in runlevel 9 that is undefinied.
- 53 -
RH302
- 54 -
RH302
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
8:2345:respawn:/sbin/mingetty tty8
After writing this line either reboot the system or use the
init q command to re-examine the /etc/inittab file.
- 55 -
RH302
Controlling Services:
i. Standalone
ii. Transient or controlled by xinetd
- 56 -
RH302
Dialog of ntsysv
- 57 -
RH302
Dialog of system-config-service
- 58 -
RH302
Transient Service:
- 59 -
RH302
- 60 -
RH302
- 61 -
RH302
Controlling Modules:
Command Description
Lsmod List all loaded modules
modprobe Program to add or remove
modules from Linux Kernel
Depmod Generates the module
dependencies file
Modinfo Displays the Module
information
Insmod Program Insert the module on
Kernel
- 62 -
RH302
- 63 -
RH302
Device Conventions:
- 64 -
RH302
- 65 -
RH302
Creating Filesystem
Syntax :
Mounting Filesystem:
- 66 -
RH302
Mount Options
Options Description
rw Mount on Read and Write mode
suid Mount with SUID bit
exec Can execute files on this
filesystem
auto Automount
nouser Other user can’t unmount or
remount the filesystem
async Mount on async mode
You can use other opposite mount options ro, nosuid,
noexec, nodev, noauto, user and sysnc.
Example:
Pattern of /etc/fstab
- 67 -
RH302
Example:
or
Example:
- 68 -
RH302
# showmount –e server
Samba Client:
- 69 -
RH302
- 70 -
RH302
Network Configuration
NETWORKING=yes | no
HOSTNAME=station?.example.com
GATEWAY=X.X.X.X
NISDOMAIN=example.com
- 71 -
RH302
DEVICE=devicename
ONBOOT=yes | no
BOOTPROTO=static | dhcp
IPADDR=X.X.X.X
NETMASK=X.X.X.X
GATEWAY=X.X.X.X
- 72 -
RH302
# vi /etc/sysconfig/network-scripts/ifcfg-eth0:0
IPADDR=x.x.x.x
NETMASK=x.x.x.x
# ifdown eth0
#ifup eth0
# vi /etc/sysconfig/network-scripts/ifcfg-eth0-rangeX
IPADDR_START=x.x.x.x
IPADDR_END=x.x.x.x
CLONENUM=x
#ifdown eth0
#ifup eth0
- 73 -
RH302
- 74 -
RH302
Static Routing:
# vi /etc/sysconfig/network-scripts/eth?.route
ADDRESS0=x.x.x.x
NETMASK0=x.x.x.x
GATEWAY0=x.x.x.x
- 75 -
RH302
Example: /etc/resolv.conf
nameserver x.x.x.x
nameserver x.x.x.x
Package Management
- 76 -
RH302
#rpm -q setup
setup-2.5.27-1
When you query for specific package if package is
installed on system it will display with package version
and full name from the local RPM database.
- 77 -
RH302
- 78 -
RH302
# system-config-packages
- 79 -
RH302
# system-config-packages --
tree=ftp://server1.example.com/pub
#system-config-packages --
tree=http://server1.example.com/rhel4
#system-config-packages --tree=/backup
Installing Kernel
- 80 -
RH302
- 81 -
RH302
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/etc/news:
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
- 82 -
RH302
root:$1$pPOCmMEL$GpUuTtSZUcFh0QQnbrNyS0:13352:0:99999:7:::
bin:*:13345:0:99999:7:::
daemon:*:13345:0:99999:7:::
adm:*:13345:0:99999:7:::
lp:*:13345:0:99999:7:::
sync:*:13345:0:99999:7:::
shutdown:*:13345:0:99999:7:::
halt:*:13345:0:99999:7:::
root:x:0:root
bin:x:1:root,bin,daemon
daemon:x:2:root,bin,daemon
sys:x:3:root,bin,adm
adm:x:4:root,adm,daemon
tty:x:5:
- 83 -
RH302
disk:x:6:root
lp:x:7:daemon,lp
mem:x:8:
kmem:x:9:
wheel:x:10:root
mail:x:12:mail
news:x:13:news
uucp:x:14:uucp
man:x:15:
games:x:20:
gopher:x:30:
dip:x:40:
Command Description
Id Displays user and Group ID
Groups Displays all belongs group name and ID
whoami Displays Logon name
w, who , Displays all logged on users name
users
Useradd Adds the user on System
Userdel Deletes the user from system
groupadd Adds the group on System
groupdel Deletes the group from System
- 84 -
RH302
Example:
# useradd user1
# passwd user1
#groupadd training
#groupdel training
When you create the user named user1, system adds the
record in /etc/passwd file, /etc/shadow file, /etc/group
file, /var/spool/mail/user1 file as well as creates the
home directory. By default it creates same group name with
user crates and make belongs that user primarily to that
group.
- 85 -
RH302
- 86 -
RH302
# *REQUIRED*
#QMAIL_DIR Maildir
- 87 -
RH302
MAIL_DIR /var/spool/mail
#MAIL_FILE .mail
PASS_MAX_DAYS 99999
PASS_MIN_DAYS 0
PASS_MIN_LEN 5
PASS_WARN_AGE 7
UID_MIN 500
- 88 -
RH302
UID_MAX 60000
GID_MIN 500
GID_MAX 60000
#USERDEL_CMD /usr/sbin/userdel_local
- 89 -
RH302
- 90 -
RH302
Changing Ownership
- 91 -
RH302
Changing Permission
# chmod u+rwx /data : Which set the read, write and execute
permission on /data directory to owner user.
#chmod g+rwx /data : Which set the read, write and execute
permission on /data to owner group member
Read : 4
Write : 2
Execute : 1
- 92 -
RH302
Total Permission is 7.
Special Permission:
- 93 -
RH302
When you set the SUIG and SGID bit you will get
Example:
- 94 -
RH302
When you set the SGID bit on directory, when user user1
creates the file in /data group owner will be admin.
3. Sticky Bit
- 95 -
RH302
- 96 -
RH302
For RHCT, you should know how to configure the NIS Client
in already server configured environment.
- 97 -
RH302
e. Click on ok
a. mkdir /nisusers
- 98 -
RH302
b. vi /etc/auto.master
c. vi /etc/auto.home
* -rw,soft,intr 192.168.0.254:/nisuers/&
- 99 -
RH302
Managing Printer
- Click on New
- Type Queue Name (Printer Name)
- Select Queue Type
- 100 -
RH302
- 101 -
RH302
- 102 -
RH302
- 103 -
RH302
Now you will get the main cups page from where you can
manage jobs, printer class, queues etc.
- 104 -
RH302
Example: http://server1.example.com/printers/printer1
- 105 -
RH302
Commands Description
lpr Sends Printing job to printer
Lpq Prints all printing queue of printer
lprm Removes the queue of printer
- 106 -
RH302
DISPLAYMANAGER=”KDE”
DESKTOP=”KDE”
- 107 -
RH302
#switchdesk “GNOME”
- 108 -
RH302
# init 5
#startx
# system-config-display command.
- 109 -
RH302
- 110 -
RH302
While you use the single disk to store data what will
happen if your disk crashed. You lose all data from your
disk. Yes, RAID is comes here for fault tolerance. If you
are storing the data in RAID device, data is available if
one disk become fail.
Disk 1 Disk 2
10GB 10 GB
Volume
Disks
20 GB
- 111 -
RH302
See on the above Figure that when you use two disks in
RAID Level 0, you will get new volume with combined size
of two disks.
- 112 -
RH302
Disk 1 Disk 2
10GB 10 GB
Volume
Disks
10 GB
Disk 1 Disk 2
10GB 10 GB Disk 3
10 GB
- 113 -
RH302
Volume
Disks
20 GB
using mdadm command can create the RAID device. The above
example creates the First RAID device md0 using /dev/hda1
and /dev/hdb1 devices.
- 114 -
RH302
Or
# mke2fs –j /dev/md0
# mkdir /data
- 115 -
RH302
- 116 -
RH302
- 117 -
RH302
- 118 -
RH302
- 119 -
RH302
Now to use the Logical Volume you need to create the file
system on Logical Volume.
- 120 -
RH302
# ext3online –d /dev/vol0/data1
Example:
#pvdisplay /dev/hda12
#vgdisplay vol0
#lvdisplay /dev/vol0/data1
- 121 -
RH302
Example:
- 122 -
RH302
- 123 -
RH302
- 124 -
RH302
#touch /home/aquota.user
#touch /home/aquota.group
Now set the policy for user and group using the edquota
command.
- 125 -
RH302
is the hard limit that user user1 can’t exceeds the hard
limit.
Similarly you can set the quota limit by using the number
of inodes. Just specify the hard limit and soft limit on
inodes.
- 126 -
RH302
Troubleshooting
NETWORKING=yes
HOSTNAME=?
GATEWAY=?
NISDOMAIN=?
/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static OR dhcp
IPADDR=x.x.x.x
NETMASK=x.x.x.x
GATEWAY=x.x.x.x
- 127 -
RH302
# route –n command
- 128 -
RH302
This is the most import and most give mind to solve the
boot related problem. You should which, which files used
at boot time and how to troubleshoot.
i. Boot loader
Grub>root (hd0,0)
- 129 -
RH302
- 130 -
RH302
# chroot /mnt/sysimage
# grub-install /dev/hda
- 131 -
RH302
- 132 -
RH302
Section 3
- 133 -
RH302
- 134 -
RH302
First you should know what DNS will do, I would like
to go through by example, when you try to access the
www.testking.com , it will work and easy to remember. But
system works on the basis of Logical Address called IP
Address but difficult to remember 202.2.2.2 etc. So there
will DNS comes, which converts the Name to IP and IP to
Name as well as define the Mail Exchanger of the Domain.
#vi /etc/named.conf
zone “example.com” IN {
type master;
- 135 -
RH302
file “example.com.zone”;
};
Figure of /etc/named.conf
- 136 -
RH302
ROOTDIR=/var/named/chrroot
#vi /var/named/chroot/var/named/example.com.zone
$TTL 3434
- 137 -
RH302
@ IN NS 192.168.0.1
@ IN NS 192.168.0.2
www IN A 192.168.0.3
ftp IN A 192.168.0.4
- 138 -
RH302
Now you need to specify the DNS Name server which specified
by NS record.
#vi /var/named/chroot/var/named/example.com.zone
- 139 -
RH302
$TTL 3434
@ IN NS 192.168.0.1
@ IN NS 192.168.0.2
www IN A 192.168.0.3
ftp IN A 192.168.0.4
mail IN A 192.168.0.5
mail1 IN A 192.168.0.6
@ IN MX 5 mail.example.com.
@ IN MX 10 mail1.example.com.
- 140 -
RH302
#named-checkzone example.com
/var/named/chroot/var/named/example.com.zone : which
checks the configuration of
/var/named/chroot/var/named/example.com.zone
configuration.
#vi /etc/resolv.conf
nameserver 192.168.0.1
nameserver 192.168.0.2
#host www.example.com
#nslookup ftp.example.com
#dig mail.example.com
- 141 -
RH302
#vi /var/named/chroot/var/named/example.com.zone
$TTL 3434
@ IN NS 192.168.0.1
@ IN NS 192.168.0.2
www 0 IN A 192.168.0.3
www 0 IN A 192.168.0.4
www 0 IN A 192.168.0.5
www 0 IN A 192.168.0.6
- 142 -
RH302
# vi /etc/named.conf
zone “0.168.192.in-addr.arpa” IN {
type master;
file “0.168.192.in-addr-arpa.zone”;
};
# vi /var/named/chroot/var/named/0.168.192.in-
addr.arpa.zone
$TTL 5454
@ IN SOA @ admin.testking.com. (
- 143 -
RH302
@ IN NS 192.168.0.1
@ IN NS 192.168.0.2
3 IN PTR www.example.com.
4 IN PTR ftp.example.com.
5 IN PTR mail.example.com.
# host 192.168.0.3
- 144 -
RH302
Example
options {
directory “/var/named”;
allow-query { Internal; };
forwarders { 202.2.2.2; };
allow-transfer { 192.168.0.2; };
- 145 -
RH302
# vi /etc/named.conf
zone “example.com” IN {
type slave;
masters { 192.168.0.1; };
file “example.com.zone”;
};
- 146 -
RH302
If you feel the need to secure your DNS server, you’ll want
to change this key. The following command automatically
sets up a new key in /etc/rndc.key, with a key size of 512
bits.
# rndc-confgen -a -b 512
zone "." {
type hint;
file "named.ca"
};
- 147 -
RH302
anonymous_enable=YES
If you want to deny anonymous you can write
anonymous_enable=no
Where # symbol is used comment
local_enable=YES
Whether login allow to real user or not ? I already wrote
that anonymous as well real users are allow to login.
write_enable=yes
- 148 -
RH302
Local_umask=022
What to set the default permission of uploaded files ? By
default settting 022 means
666
022
------
644
So this mask set the permission of
rw-r--r—on uploaded files.
You Know that by default Real users only can upload files
into FTP server anonymous can download only. There are
options either enable to upload to anonymous or not.
#anon_upload_enable=YES
#anon_mkdir_write_enable=YES
If you want to enable file upload by anonymous uncomment
anon_upload_enable=yes line. But remember that you need to
create a directory with ownership of ftp user as well as
write permission to ftp user.
- 149 -
RH302
dirmessage_enable=YES
To display directory message, you need to create file
.message and write message what you want to display.
xferlog_enable=YES
FTP service uses 20 and 21 Port, where 20 for ftp data and
21 for user authentication.
connect_from_port_20=YES
#chown_uploads=YES
#chown_username=whoever
Ownership change or not of uploaded file having no
ownership, example uploaded by anonymous.
Example:
Chown_uploads=yes
Chow_username=user1
Now Uploaded files ownership will be user user1.
- 150 -
RH302
User1
User2
User3
/etc/vsftpd.user_list file some time used to deny, some to
to allow. IF you use
userlist_enable=yes in vsftpd.conf file, this file is used
to deny, if userlist_enable=no then only the user written
in /etc/vsftpd.user_list are allowed to to access the ftp
service.
FTP Client
There are different ways of accessing the ftp sevice. One
way is using ftp or lftp client tools.
#ftp server
or
#lftp –u username server
When you connect to ftp server will get like this prompt
- 151 -
RH302
- 152 -
RH302
- 153 -
RH302
Example:
/pub *.example.com(rw,sync)
/public 192.168.0.0/255.255.255.0(rw,sync)
192.168.1.0/255.255.255.0(ro,sync)
Options in NFS:
ro : Shared permission Read only
rw : Shared permission Read and Write
sync : Shared permission in sync mode
no_root_squash : Remote root user gets permission as local
root user
all_squash : All remote user mapped as anonymous user
- 154 -
RH302
Once you've modified /etc/exports, you need to do more. First, this file is simply the
default set of exported directories. You need to activate them with the exportfs -a
command. exportfs –r refresh /etc/exports shares. As well as exportfs –v list all shared
directories from local computer.
Using GUI tool, you can configure the NFS server using system-config-nfs command
Click on Add
- 155 -
RH302
NFS is the RPC service so you need to start portmap with nfs.
Similarly you can check what data are shared from the remote host using showmount
command.
#showmount –e server
You can use the shared directory from the server using mount command as well as using
Autofs feature.
- 156 -
RH302
SMB helps
• Sharing Data
• Sharing Printers
• Authentication and Authorization
• Name Resolution with WINS server
Samba Server Installation
#rpm –ivh samba-*
#rpm –ivh samba-client-*
samba package provides the server configuration interface
and samba-client provides the samba client tool to connect
to Microsoft shares.
- 157 -
RH302
- 158 -
RH302
1. Sharing Data
#vi /etc/samba/smb.conf
[global]
netbios name=linuxserver
workgroup=mygroup
server string=sharing from linux server
security=share
[data]
path=/data
browsable=yes
writable=yes
public=yes
- 159 -
RH302
- 160 -
RH302
[data]
path=/data
browsable=yes
writable=yes
public=yes
- 161 -
RH302
#vi /etc/samba/smb.conf
[global]
netbios name=linuxserver
workgroup=mygroup
server string=sharing from linux server
security=user
smb passwd file=/etc/samba/smbpasswd
encrypt passwords=yes
[data]
path=/data
browsable=yes
writable=yes
public=yes
- 162 -
RH302
iii. read only : Whether share the data read only mode or
not
- 163 -
RH302
Example:
#vi /etc/samba/smb.conf
[global]
netbios name=linuxserver
workgroup=mygroup
server string=sharing from linux server
security=user
smb passwd file=/etc/samba/smbpasswd
encrypt passwords=yes
hosts allow= 172.24. 192.168.0.
[data]
path=/data
browsable=yes
writable=yes
public=yes
valid users=user1
[data1]
path=/data1
browsable=yes
writable=no
write list=user2 @training
[data2]
path=/data2
browsable=yes
writable=no
hosts allow=172.24
- 164 -
RH302
- 165 -
RH302
Example
#vi /etc/samba/smb.conf
[global]
netbios name=linuxserver
workgroup=mygroup
server string=sharing from linux server
security=user
smb passwd file=/etc/samba/smbpasswd
encrypt passwords=yes
[homes]
public=no
browsable=yes
writable=yes
#useradd user1
#useradd user2
#useradd user3
#smbpaswd –a user1
#smbpasswd –a user2
#smbpasswd –a user3
- 166 -
RH302
#vi /etc/samba/smb.conf
[global]
netbios name=linuxserver
workgroup=mygroup
security=share
printing=cups
printcap name=/etc/printcap
load printers=yes
[printes]
path=/var/spool/samba
public=yes
browsable=yes
writable=no
printable=yes
- 167 -
RH302
- 168 -
RH302
- 169 -
RH302
Sendmail Server
ISP’s MTA
Domain MTA
- 170 -
RH302
- 171 -
RH302
ii. vi /etc/mail/sendmail.mc
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')
iii. m4 /etc/mail/sendmail.mc >/etc/mail/sendmail.cf
iv. vi /etc/mail/access
- 172 -
RH302
192.168.0 ACCEPT
v. vi /etc/dovecot.conf
protocols = imap imaps pop3 pop3s
v. service sendmail start
vi. service dovecot start
- 173 -
RH302
# vi /etc/dovecot.conf
protocols = imap imaps pop3 pop3s
#service dovecot start | restart
- 174 -
RH302
- 175 -
RH302
#telnet mail.example.com 25
helo mail.example.com
mail from: [email protected]
rcpt to: [email protected]
data
Hello user2
.
quit
- 176 -
RH302
include(`/usr/share/sendmail-cf/m4/cf.m4')dnl
OSTYPE(`linux')dnl
dnl define(`SMART_HOST',`smtp.your.provider')
- 177 -
RH302
FEATURE(`access_db',`hash -T<TMPF> -
o/etc/mail/access.db')dnl
FEATURE(`blacklist_recipients')dnl
- 178 -
RH302
dnl MASQUERADE_DOMAIN(localhost)dnl
dnl MASQUERADE_DOMAIN(localhost.localdomain)dnl
dnl MASQUERADE_DOMAIN(abc.com)dnl
dnl MASQUERADE_DOMAIN(example.com)dnl
- 179 -
RH302
Apache overview
Apache web server is the most widely used http daemon
based web server. Which provides the secure as well as
non-secure contents transfer between client and server
using http or https protocols. Apache loads lots of
modules dynamically to interpret the CGI, Perl, PHP etc
scripts on browser.
- 180 -
RH302
- 181 -
RH302
User apache
Group apache
# Change this to Listen on specific IP addresses as shown
below to
# prevent Apache from glomming onto all bound IP addresses
(0.0.0.0)
#
#Listen 12.34.56.78:80
Listen 80
- 182 -
RH302
<Directory "/var/www/html">
in /etc/httpd/conf/httpd.conf file.
AccessFileName .htaccess
- 183 -
RH302
Now Open the browser and type http://localhost you will get
you index.html page.
- 184 -
RH302
We can Configure the apache web server for web site either
one site one ip or by sharing the IP Address means multiple
web site on single IP Address.
# vi /etc/httpd/conf/httpd.conf
<VirtualHost 192.168.0.3>
ServerName www.example.com
DocumentRoot /var/www/example
ServerAdmin [email protected]
DirectoryIndex index.html index.php
</VirtualHost>
#service httpd restart | start
#links http://www.example.com
You can Access the web site either using GUI browser or
console browser.
Links is the console based browser.
- 185 -
RH302
#vi /etc/httpd/conf/httpd.conf
NameVirtualHost 192.168.0.3
<VirtualHost www.example.com>
ServerName www.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/example
DirectoryIndex index.html index.htm index.php
</VirutalHost>
<VirtualHost www.abc.com>
ServerName www.abc.com
ServerAdmin [email protected]
DocumentRoot /var/www/abc
DirectoryIndex index.html index.htm index.php
</VirutalHost>
- 186 -
RH302
# vi /etc/httpd/conf/httpd.conf
<VirtualHost 192.168.0.3>
ServerName www.example.com
DocumentRoot /var/www/example
<Directory /var/www/example>
AllowOverride Authconfig
</Directory>
ServerAdmin [email protected]
DirectoryIndex index.html index.htm index.php
</VirtualHost>
#cd /var/www/example
- 187 -
RH302
#vi .htaccess
AuthName “Only to Authorized Users”
AuthType basic
AuthUserFile /etc/httpd/conf/mypasswd
Require valid-user
- 188 -
RH302
# vi /etc/httpd/conf/httpd.conf
<VirtualHost 192.168.0.3>
ServerName www.example.com
DocumentRoot /var/www/example
ServerAdmin [email protected]
<Directory /var/www/example>
Order Allow, Deny
Allow from .example.com
</Directory>
DirectoryIndex index.html index.htm index.php
</VirtualHost>
- 189 -
RH302
# vi /etc/httpd/conf/httpd.conf
<VirtualHost 192.168.0.3>
ServerName www.example.com
DocumentRoot /var/www/example
ServerAdmin [email protected]
DirectoryIndex index.html index.htm index.php
ScriptAlias /cgi-bin/ /var/www/example/cgi-bin/
</VirtualHost>
# mkdir /var/www/example/cgi-bin
#cd /var/www/example/cgi-bin
- 190 -
RH302
#vi test.sh
#!/bin/bash
echo Content-Type: text/html
echo “Hello RHCE Guys”
#chmod a+x test.sh
#service httpd restart
- 191 -
RH302
# vi /etc/httpd/conf.d/ssl.conf
<VirtualHost 192.168.0.3>
ServerName www.example.com
DocumentRoot /var/www/example
DirectoryIndex index.html
serverAdmin [email protected]
SSLEngine on
SSLcertificateFile
/etc/httpd/conf/ssl.crt/server.crt
SSLcertificateKeyFile
/etc/httpd/conf/ssl.key/server.key
</VirtualHost>
Now you need to create the certificate file and key file.
In Redhat Enterprise Linux already pre-configured MakeFile
is stored in /etc/httpd/conf or /usr/share/ssl/certs
directory. Now you need to just use the make command.
#cd /etc/httpd/conf
#make testcert
#service httpd restart
- 192 -
RH302
#system-config-httpd
- 193 -
RH302
Squid Server
Squid is the internet cache proxy server for FTP, HTTP and
other clients request. Squid supports FTP, HTTP as well as
SSL and other protocols.
Installing Squid
/etc/squid/squid.conf is the main squid configuration file
provides by squid rpm package.
- 194 -
RH302
- 195 -
RH302
• Click on EditÆPreferences
• Click on General
• Click Connection Settings
• Select Manual Proxy Configuration
o Type Proxy address and port number running on.
- 196 -
RH302
- 197 -
RH302
#domainname example.com
#vi /etc/sysconfig/network
NISDOMAIN=example.com
You know domainname command displays or sets the domain
for current session. If you would like to set permanently
use the NISDOMAIN directives in /etc/sysconfig/network
file.
2. vi /var/yp/MakeFile
- 198 -
RH302
3. cd /var/yp
# make
After successfully running make command check in /var/yp/
there you will get the directory same name as domain.
- 199 -
RH302
2. /usr/lib/yp/ypinit –s nis1.example.com
#vi /etc/exports
/rhome *.example.com(rw,sync)
- 200 -
RH302
NIS Client
In client machine :
- 201 -
RH302
i. Click on ok
a. mkdir /rhome
b. vi /etc/auto.master
c. vi /etc/auto.home
* -rw,soft,intr 192.168.0.254:/rhome/&
- 202 -
RH302
- 203 -
RH302
System Security
What will checks this ?? PAM yes PAM’s modules checks this
all things you can modify the configuration as per you
needs.
Pam_nologin.so modules check whether /etc/nologin file is
created or not, pam_securetty.so module checks which
terminal are available to login to root user.
- 204 -
RH302
Control Values
Required : If the module works, the command proceeds. If it fails, go to the next
command in the configuration file but result is already determined that should fail.
Requisite: Same as Required but It stops of checking other modules when one return fail
result.
- 205 -
RH302
PAM has the capabilities to control the users to login at any time. Using PAM can define
the time for user to allow login.
For this you need to configure /etc/security/time.conf file, this file is checks by
pam_times.so module.
/etc/security/time.conf the main configuration file for time based authentication using
PAM.
Services:terminals:users:times
Generally services represent the pam services, terminals represents the name of terminal,
users means name of user and times allowed time to run program.
Time can write Su, Mo, Tu, We, Th, Fr, Sa, Wk, Wd, Al
login;*;user1;Al0900-1730
Login;*;user2;SuMo1200-1400
Time.conf file is reads by pam_time.so but you need to call either in login or system-auth
pam file.
#vi /etc/pam.d/login
- 206 -
RH302
permission:users:origins
- 207 -
RH302
#vi /etc/pam.d/login
account required /lib/security/pam_access.so
# vi /etc/security/limits.conf
user1 hard nproc 5
@training – maxlogins 10
user2 - maxlogins 1
# vi /etc/pam.d/system-auth
session required /lib/security/pam_limits.so
- 208 -
RH302
- 209 -
RH302
But some services mail, ftp, sshd etc doesn’t have it’s own
security mechanism to control hosts. So These services can
control by TCP Wrappers.
- 210 -
RH302
Syntax: services:clients:options
Example:
/etc/hosts.deny
You can use the ALL, EXCEPT operator to allow or deny the
services. First Example vsftpd allowed to access only from
example.com domain, second example allowed to access nfs
and portmap from example.com domain and trusted.cracker.org
host. Third example deny to login using ssh from any host.
- 211 -
RH302
Example:
Sshd: ALL :spawn echo “Someone trying to attack
through ssh to %s from %c” | mail –s “Danger” admin
- 212 -
RH302
Controlling Telnet
Here is the output of /etc/xinetd.d/telnet file
Service telnet
{
- 213 -
RH302
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd Æserver program
name
log_on_failure +=USERID
instances = 20
per_source = 1
Access_from = 192.168.0.0/24
No_access = 192.168.0.100
Access_times = 09:39-17:30
- 214 -
RH302
Introduction to iptables
- 215 -
RH302
Example:
#iptables –t filter –A INPUT –s 192.168.0.100 –p
tcp --dport 8080 –j DROP
- 216 -
RH302
After applying your own rules and chain policy you need to
save into files to apply automatically at next reboot.
#service iptables save
it will save your rules and policy configuration into
/etc/sysconfig/iptables file.
- 217 -
RH302
- 218 -
RH302
DNAT
Destination NAT Allows to change the destination address.
ISP
Private IP eth1
:202.2.2.2
Example.com domain
- 219 -
RH302
*Good Luck
- 220 -