Clean shell history when logging out

Hello,

There is a simple way of deleting bash's history at the logout. First create a file called .bash_logout in your user home directory and use the clear-command to clear the screen and the history-command to remove the history. Here is how it's done:

open file:
# vim ~/.bash_logout

add this to the file:
rm -f ~/.bash_history
clear
history -c

Save and exit the file. Done 😉

The -c parameter deletes all history. If you want to delete the session hisotry only use -r instead.

Fight spam with sendmail (CentOS5/RHEL5)

Hello,

Sendmail is a very often used MTA (Mail Transfer Agent) on unix platforms. It implements configurations to do realtime blocklist checks with lists from spamhaus.org or spamcop.net or any other blocklist. Open your /etc/mail/sendmail.mc and add following two lines to it:

FEATURE(`enhdnsbl', `sbl.spamhaus.org', `"554 Rejected " $&{client_addr} " – see http://www.spamhaus.org/sbl/"')dnl
FEATURE(`enhdnsbl', `bl.spamcop.net', `"554 Rejected " $&{client_addr} " – see http://www.spamcop.net/bl.shtml"')dnl

Please remember to put them after this line:
include(`/usr/lib/opcenter/sendmail/install/popauth.m4')

If you do not, the sendmail.cf compilation will fail with an error. Well now it's time to compile our config file, so type this:

# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

and restart the mail server with

# service sendmail restart

The advantage of this method is that the email is rejected before it enters the server so it saves bandwidth and cpu ressources. I personnally disabled the blocklist checking in MailScanner after using this because i found no need for it anymore.

There are also a few config options i found useful:

throttle connections to servers which sent out email to more than 10 invalid adresses:
define(`confBAD_RCPT_THROTTLE', `10')dnl

replace smtp welcome message with a custom string (hides sendmail verison):
define(`confSMTP_LOGIN_MSG', `<Your custom string here> MTA, local time is $b')dnl

Enable NFS Share on CentOS/RHEL 6

Hello,

NFS (Network File System) is the equivalent to SMB (Samba/CIFS) from the Windows world in the Unix world. Over NFS you can share folders on the network. Building a NFS share is quite easy but the configuration a bit tricky if you plan the usage of a firewall, for example iptables.

You need following ports open:

TCP/UDP 111 (RPC portmapper)
TCP/UDP 2049 (NFSD server)
TCP/UDP 32803 (*)
TCP/UDP 32769 (*)
TCP/UDP 892 (*)
TCP/UDP 875 (*)
TCP/UDP 662 (*)
TCP/UDP 2020 (*)

(*) Because NFS choses random ports every time it's started we need to fix several ports in the config file /etc/sysconfig/nfs. Without these fixed ports we can't do firewalling on a nfs server. So, to activate these ports uncomment the following lines in the mentioned config file:

LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
RQUOTAD_PORT=875
STATD_PORT=662
STATD_OUTGOING_PORT=2020

Afterwards restart all daemons needed for the nfs server:

# /etc/init.d/rpcbind restart
# /etc/init.d/nfs restart
# /etc/init.d/rpcsvcgssd restart

Now that the server is running you only need to add the ports to your iptables config. Open /etc/sysconfig/iptables and repeat the following 2 lines for each port:

-A INPUT -m state –state NEW -p tcp –dport <port> -j ACCEPT
-A INPUT -m state –state NEW -p udp –dport <port> -j ACCEPT

Now we have to export a folder. First open the file /etc/exports and add the export, here an example line:

/home/BACKUP    192.168.0.0/24(rw,sync,root_squash)

Short explanation:
/home/BACKUP – That's the folder you want to export
192.168.0.0/24 – That's the host part which has access to the share (here the whole mentioned network)
(rw,sync,root_squash) – That's the option part (here read/write, sync and act as root)

For more explanations on the options you can consult the manpages (# man exports)

After you have created the share and saved the file, push it online with
# exportfs -a

I also restart the nfs server every time after the exportfs command but i don't know if it's really needed.