Wednesday, August 28, 2013

How to configure LDAP client on RHEL 6.x


First we have to make sure, that we have LDAP client group installed.

#yum -y groupinstall directory-client

After installing package group, we can configure LDAP client either using GUI tool or using CLI tool:

#system-config-authentication &

GUI Tool for configuration of ldap

                    -OR-


#authconfig  --enableldap  --enableldapauth
--ldapserver=ldapsrv.ynetwork.org  
--ldapbasedn="dc=ynetwork,dc=org"
--enableldaptls 
--ldaploadcacert=http://ldapsrv.ynetwork.org/pub/ynetwork-ca.crt 
--enablesssd 
--enablesssdauth 
--update 

CLI Tool to configure LDAP client

#getent passwd user1        

Assuming you have 'user1' created in LDAP server

#ssh user1@localhost

Test using ssh or su in your local system with ldap user account

Now its not possible to create home directory of all ldap based users in all hosts, so we shall use NFS to automatically mount their home directory with they log in.

#vim /etc/auto.master 

/home/remote /etc/auto.remote

(Assuming /home/remote/user1 is the home directory for 'user1')

#showmount -e ldapsrv.ynetwork.org

Our ldap server can also be a NFS server, hosting home directories for all users, so determine NFS shares using above command.

#vim /etc/auto.remote

user1   -rw   ldapsrv.ynetwork.org:/home/remote/user1

(SYNTAX: username  -options    nfsserver.fqdn:/home/dir)

#service autofs reload

Reload all indirect maps

#ssh user1@localhost

Test again with user1

How to configure LDAP client using kerberos authentication

#yum -y install krb5-workstation openldap-clients

Install required packages for kerberos authentication(Assuming you already have all required ldap packages)

#authconfig  --enableldap  --disableldapauth
--ldapserver=ldapsrv.ynetwork.org  
--ldapbasedn="dc=ynetwork,dc=org"
--enableldaptls 
--ldaploadcacert=http://ldapsrv.ynetwork.org/pub/ynetwork-ca.crt 
--enablekrb5 
--krb5kdc=ldapsrv.ynetwork.org 
--krb5adminserver=ldapsrv.ynetwork.org 
--krb5realm=YNETWORK.ORG 
--enablesssd 
--enablesssdauth 
--update 

(Configuring LDAP with kerberos using cli tool of 'authconfig')

#getent passwd user1

Test your communication using one of the user.

#ssh user1@localhost

Use kerberos password instead of ldap password.

Thursday, February 14, 2013

Iptables basic configurations on RHEL 6.x

IPtables on Redhat Enterprise Linux 6.x

Here we will learn iptables packet filtering tool ships along with most RHEL distros. We will concentrate on Filter chain of iptables.

#mkdir -p /root/bin

#cd /root/bin

#vim firewallconf.sh

#!/bin/bash

iptables -F

## Clears all previous rules

iptables -A INPUT -i lo -j ACCEPT

## Allowing all localhost (Local loopback) traffic

iptables -I INPUT -m state --state ESTABLISHED,RELATED -s 192.168.0.0/24 -j ACCEPT

## Allowing all Established and related packets for local network (192.168.0.0 in our case)

iptables -I INPUT -m state --state NEW -s 192.168.0.0/24 -p tcp --dport 22 -j ACCEPT

## Allowing SSH traffic for all new connection 'made' to your local system, only for your local Lan

iptables -A INPUT -j REJECT

## Rejecting all other traffic which is initiated to your local host

<save and exit>

#chmod 755 firewallconf.sh

#./firewallconf.sh

# service iptables save

# iptables -L

<List all written rules in Filter Chain>

# iptables -nvL --line-numbers

<Lists all rules along with all dropped/rejected and accepted packets>