Saturday, December 17, 2011

How to configure linux nfs server step by step guide Example and Implementation

NFS, or Network File System, is a server-client protocol for sharing files between computers on a common network. NFS enables you to mount a file system on a remote computer as if it were local to your own system. You can then directly access any of the files on that remote file system. The server and client do not have to use the same operating system. The client system just needs to be running an NFS client compatible with the NFS server.
For example NFS server could be a Linux system and Unix could be a client. But it can’t be a window system because window is not NFS compatible. The NFS server exports one or more directories to the client systems, and the client systems mount one or more of the shared directories to local directories called mount points. After the share is mounted, all I/O operations are written back to the server, and all clients notice the change as if it occurred on the local filesystem.
A manual refresh is not needed because the client accesses the remote filesystem as if it were local.because access is granted by IP address, a username and password are not required. However, there are security risks to consider because the NFS server knows nothing about the users on the client system.
Exam question 1 Some users home directory is shared from your system. Using showmount -e localhost command, the shared directory is not shown. Make access the shared users home directory
Exam question 2 The System you are using is for NFS (Network File Services). Some important data are shared from your system. Make automatically start the nfs and portmap services at boot time
Exam question 3 Share /data directory using NFS only to 192.168.0.0/24 members. These hosts should get read and write access on shared directory.

Configure nfs server

In this example we will configure a nfs server and will mount shared directory from client side.
For this example we are using two systems one linux server one linux clients . To complete these per quest of nfs server Follow this link
  • A linux server with ip address 192.168.0.254 and hostname Server
  • A linux client with ip address 192.168.0.1 and hostname Client1
  • Updated /etc/hosts file on both linux system
  • Running portmap and xinetd services
  • Firewall should be off on server
We have configured all these steps in our pervious article.
We suggest you to review that article before start configuration of nfs server. Once you have completed the necessary steps follow this guide.
Three rpm are required to configure nfs server. nfs, portmap, xinetd check them if not found then install
rpm
Now check nfs, portmap, xinetd service in system service it should be on

#setup
Select System service from list
[*]portmap
[*]xinetd
[*]nfs
Now restart xinetd and portmap service
service restart
To keep on these services after reboot on then via chkconfig command
chkconfig
After reboot verify their status. It must be in running condition
service status
now create a /data directory and grant full permission to it
mkdir
now open /etc/exports file
vi exports
share data folder for the network of 192.168.0.254/24 with read and write access
editing in exports
save file with :wq and exit
now restart the nfs service and also on it with chkconfig
service nfs restart
also restart nfs daemons with expotfs
exportfs
verify with showmount command that you have successfully shared data folder
showmount

configure client system

ping form nfs server and check the share folder
showmount
now mount this share folder on mnt mount point. To test this share folder change directory to mnt and create a test file
mount server directory
After use you should always unmount from mnt mount point
unmount
In this way you can use shared folder. But this share folder will be available till system is up. It will not be available after reboot. To keep it available after reboot make its entry in fstab
create a mount point, by making a directory
mkdir
now open /etc/fstab file
vi fstab
make entry for nfs shared directory and define /temp to mount point
file fstab
save the with :wq and exit reboot the system with reboot -f command

#reboot -f
after reboot check /temp directory it should show all the shared data
cd temp

Friday, December 16, 2011

Configure linux nis server step by step guide example and implementation

NIS, or Network Information Systems, is a network service that allows authentication and login information to be stored on a centrally located server. This includes the username and password database for login authentication, database of user groups, and the locations of home directories.

RHCE exam questions

One NIS Domain named rhce is configured in your lab, server is 192.168.0.254. nis1, nis2,nis3 user are created on domain server. Make your system as a member of rhce domain. Make sure that when nis user login in your system home directory should get by them. Home directory is shared on server /rhome/nis1.
RHCE exam doesn't ask candidate to configure NIS server. It test only NIS client side configuration. As you can see in example questions. But here in this article we will configure both server and client side for testing purpose so you can get more depth knowledge of nis server

Configure NIS server

In this example we will configure a NIS server and a user nis1 will login from client side.
For this example we are using two systems one linux server one linux clients . To complete these per quest of ssh server Follow this link
  • A linux server with ip address 192.168.0.254 and hostname Server
  • A linux client with ip address 192.168.0.1 and hostname Client1
  • Updated /etc/hosts file on both linux system
  • Running portmap and xinetd services
  • Firewall should be off on server
We have configured all these steps in our pervious article.
We suggest you to review that article before start configuration of nis server. Once you have completed the necessary steps follow this guide.
Seven rpm are required to configure nis server. ypserv, cach, nfs, make, ypbind, portmap, xinetd check them if not found then install
rpm
Now check nfs,ypserv,yppasswdd,ypbind, portmap, xinetd service in system service it should be on

#setup
Select System service from list
[*]portmap
[*]xinetd
[*]nfs
[*]ypserv
[*]yppasswdd
[*]ypbind
Now open /etc/sysconfig/network file
network
Set hostname and NIS domain name as shown here and save file
change hostname
Now create a user named nis1 and give his home directory on /rhome with full permission
useradd
Now open /etc/exports file
exportfs
share /rhome/nis1 directory for network
exportfs
save this with :wq and exit
now open /var/yp/Makefile file
Makefile
and locate line number 109 [ use ESC + : +set nu command to show hidden lines or read our vi editor article to know more about vi command line option ]
Makefile
Now remove other entry from this line excepts passwd group hosts netid \ [as shown here]
Makefile
save this with :wq and exit
Now restart these service

#service portmap restart
#service xinetd restart
#service nfs restart
#service ypserv restart
#service yppasswdd restart
Don't restart ypbind service at this time as we haven't updated our database
Now change directory to /var/yp and run make command to create database
make
now update this database by running this commands [ first add server and then add all client machine one by one. After adding press CTRL+D to save, confirm by pressing y]
ypinit
Now once again restart all these service this time there should be no error

#service portmap restart
#service xinetd restart
#service nfs restart
#service ypserv restart
#service yppasswdd restart
#service ypbind restart
Now set all these service to on with chkconfig so these could be on after restart

#chkconfig portmap on
#chkconfig xinetd on
#chkconfig nfs on
#chkconfig ypserv on
#chkconfig yppasswdd on
#chkconfig ypbind on

Client configuration

Before you start client configuration we suggest you to check proper connectivity between server and client. First try to login on NIS server from telnet. If you can successfully login via telnet then try to mount /rhome/nis1 directory via nfs server. If you get any error in telnet or nfs then remove those error first. You can read our pervious article for configuration related help.
To know how configure telnet server read
How to configure linux telnet server step by step guide
To know how configure nfs server read
How to configure linux nfs server step by step guide
Once you successfully completed necessary test then start configuration of client sides.
Two rpm are required to configure clients yp-tools and ypbind check them for install
rpm
now open /etc/sysconfig/network file
vi network
and make change as shown here
network
save the file with :wq and exit
now run setup command and select authentication configuration from list
#setup
select authenications
now check mark on NIS and enter on next
setup
Set domain name to rhce and server to 192.168.0.254 and click on ok
set nis domain name
No error should be occurred here if you see any error then check all configuration.
no open /etc/auto.master file
auto.master
in the end of file do editing of /rhome as shown here
editing in auto.master
save the file with :wq and exit
now open /etc/auto.misc file
auto.misc
in the end of file do editing of user nis1 as shown here
auto.misc
save the file with :wq and exit
now restart autofs and ypbind service
service restart
set these service on via chkconfig commands

#chkconfig autofs on
#chkconfig ypbind on
now restart the system

#reboot -f
login from nis1 user on client system
user login

Thursday, December 15, 2011

How to configure linux syslog server step by step guide Example and Implementation

Sample Exam question:- You are a System administrator. Using Log files very easy to monitor the system. Now there are 40 servers running as Mail, Web, Proxy, DNS services etc. Your task is to centralize the logs from all servers into on LOG Server. How will you configure the LOG Server to accept logs from remote host ?

Answer with Explanation

An important part of maintaining a secure system is keeping track of the activities that take place on the system. If you know what usually happens, such as understanding when users log into your system, you can use log files to spot unusual activity. You can configure what syslogd records through the /etc/syslog.conf configuration file.
The syslogd daemon manages all the logs on your system and coordinates with any of the logging operations of other systems on your network. Configuration information for syslogd is held in the /etc/syslog.conf file, which contains the names and locations for your system log files.
By Default system accept the logs only generated from local host. In this example we will configure a log server and will accept logs from client side.
For this example we are using two systems one linux server one linux clients . To complete these per quest of log server Follow this link
  • A linux server with ip address 192.168.0.254 and hostname Server
  • A linux client with ip address 192.168.0.1 and hostname Client1
  • Updated /etc/hosts file on both linux system
  • Running portmap and xinetd services
  • Firewall should be off on server
We have configured all these steps in our pervious article.
We suggest you to review that article before start configuration of log server. Once you have completed the necessary steps follow this guide.
Check syslog, portmap, xinetd service in system service it should be on

#setup
Select System service from list
[*]portmap
[*]xinetd
[*]syslog
Now restart xinetd and portmap service
service restart
To keep on these services after reboot on then via chkconfig command
chkconfig
After reboot verify their status. It must be in running condition
service status
Now open the /etc/sysconfig/syslog file
vi syslog
and locate SYSLOGD_OPTIONS tag
syslog
add -r option in this tag to accepts logs from clients
syslog editing
-m 0 disables 'MARK' messages.
-r enables logging from remote machines
-x disables DNS lookups on messages recieved with -r
After saving file restart service with service syslog restart command
service syslog restat

On Linux client

ping from log server and open /etc/syslog.conf file
syslog.conf
Now go to the end of file and do entry for serve as user.* @ [ server IP] as shown in image
syslog.conf editing
After saving file restart service with service syslog restart command
service syslog restart
Now restart the client so it can send log entry to server. ( Note that these logs will generate when client boot, so do it restart not shutdown)
reboot

Check clients log on Log server

To check the message of client on server open
less messages
In the end of this file you can check the log from clients
messages file