Selasa, 28 September 2010

fw.proxy scripts

#!/bin/sh
# squid server IP
SQUID_SERVER="192.168.1.1"
# Interface connected to Internet
INTERNET="eth0"
# Interface connected to LAN
LAN_IN="eth1"
# Squid port
SQUID_PORT="3128"
# DO NOT MODIFY BELOW
# Clean old firewall
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
# Load IPTABLES modules for NAT and IP conntrack support
modprobe ip_conntrack
modprobe ip_conntrack_ftp
# For win xp ftp client
#modprobe ip_nat_ftp
echo 1 > /proc/sys/net/ipv4/ip_forward
# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
# Unlimited access to loop back
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# Allow UDP, DNS and Passive FTP
iptables -A INPUT -i $INTERNET -m state --state ESTABLISHED,RELATED -j ACCEPT
# set this system as a router for Rest of LAN
iptables --table nat --append POSTROUTING --out-interface $INTERNET -j MASQUERADE
iptables --append FORWARD --in-interface $LAN_IN -j ACCEPT
# unlimited access to LAN
iptables -A INPUT -i $LAN_IN -j ACCEPT
iptables -A OUTPUT -o $LAN_IN -j ACCEPT
# DNAT port 80 request comming from LAN systems to squid 3128 ($SQUID_PORT) aka transparent proxy
iptables -t nat -A PREROUTING -i $LAN_IN -p tcp --dport 80 -j DNAT --to $SQUID_SERVER:$SQUID_PORT
# if it is same system
iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j REDIRECT --to-port $SQUID_PORT
# DROP everything and Log it
iptables -A INPUT -j LOG
iptables -A INPUT -j DROP

Isnin, 27 September 2010

Squid hostname error

[root@sawi squid]# less /var/log/squid/squid.out
[root@sawi squid]# vim squid.conf
[root@sawi squid]# service squid start
init_cache_dir /var/spool/squid... /etc/init.d/squid: line 62: 13530 Aborted $SQUID -z -F -D >> /var/log/squid/squid.out 2>&1
Starting squid: /etc/init.d/squid: line 42: 13532 Aborted $SQUID $SQUID_OPTS >> /var/log/squid/squid.out 2>&1
[FAILED]
---------------------------------------------------------------------
#add below line for above error

visible_hostname [your_hostname]

Jumaat, 17 September 2010

Informix DB backup into tape - shell script

Maaf lama menyepi tanpa sebarang update kerana saya baru sahaja joint syarikat baru. Banyak projek yang terpaksa saya laksanakan hinggakan tidak berkesempatan utk update isirung.

Di syarikat baru saya mengguna DB informix version 10 sebagai DB engine bagi applikasi disini. Jadi 1st day saya disini ialah menulis script seperti bagi tujuan backup dimana sebelum ini mereka melakukan backup secara manual.

DB engine: IBM Informix v10
OS: RHEL 4

------------------------------------------------------

#!/bin/bash

LEVEL=0
ontape -s <&1 >> /tmp/logfile
$LEVEL
read Return
EOF
exit

------------------------------------------------------