Thursday, January 31, 2008

Compare Directory Contents on Linux computer

#/bin/bash

DIR_1=$1
DIR_2=$2

#check dir diffs

ls -1 $DIR_1 >/tmp/diff.1
ls -1 $DIR_2 >/tmp/diff.2


echo "Check Dir differences:"
diff /tmp/diff.1 /tmp/diff.2 && echo "Dir's have the same files"

#check files differences

echo "check files differences:"
for file in `cat /tmp/diff.1 /tmp/diff.2|uniq`; do
diff $DIR_1/$file $DIR_2/$file 2>/dev/null
done

rm /tmp/diff.1 /tmp/diff.2
posted by Stephen Reese at 4 Comments

NFS howto with static ports

First I'm going to edit the /etc/sysconfig/nfs to specify the ports I want to run on.

STATD_PORT=4000
STATD_OUTGOING_PORT=4004

LOCKD_TCPPORT=4001
LOCKD_UDPPORT=4001
MOUNTD_PORT=4002


Next I want to edit the /etc/hosts.allow to only allow specific hosts to access the resource.

nfs:192.168.1.

Finally lets allow some stuff to come in through our IP tables rules at /etc/sysconfig/iptables

*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
#-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 137:139 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 4000:4004 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 55443 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-port-unreachable
COMMIT

Labels: ,

posted by Stephen Reese at 0 Comments