Twitter
RSS

Filtering URL's of sex through Dansguardian with Transparent Squid Proxy

0

After running successfully Transparent proxy of Squid in Intranet or LAN, How to block Illegal sites through Dansguardian:

1) Need to check Transparent squid proxy running in LAN if running well go through below procedure:

2)Get Dansguadian file from http://rpmfind.net and search Dansguardian, get "dansguardian-2.8.0.6-1.2.el4.rpm" save to /opt.

3) Go to CD /opt : install Dansguardian software

"rpm -ivh dansguardian-2.8.0.6-1.2.el4.rpm"
after success install of Dansguardian file......

4) Copy the file "Dansguardian.pl" from /var/www/dansguardian to /var/www/cgi-bin

5)Edit below file:

Vi /etc/dansguardian/dansguardian.conf
============================================

Filter port = 8080
Proxy ip = 192.168.0.1 (eth1 IP)
Proxy port = 3128
============================================

6)Edit another file like below:

Vi /etc/httpd/conf.d/dansguardian.conf

==================================================
Script Alias /dansguardian/ /var/www/danguardian/

DirectoryIndex dansguardian.pl
Options ExecCGI
Order allow, deny
Allow from all

Allow from 127.0.0.1

=================================================

7) In browser of LAN or INTRANET put proxy IP AND PORT :

Proxy IP: 192.168.0.1 Port: 8080

8) All Illegal url blocked, can't access withthis proxy.

9) Need to enable Dansguarian from Boot: "ntsysv" and check Dansguardian, OK.

10) service dansguardian start

11) service network restart

12) service iptables restart

Credits: nsharif.blogspot.com


Squid & Transparent proxy Configuration in Redhat ES 4

0
1) Need to check in linux Squid install or not fist....

In terminal type: "rpm -q squid"

2) If not install software, please get rpm file from http://rpmfind.net and search "squid" and get the file "squid-2.5.STABLE6-3.i386.rpm" for Redhat ES4 & save to /opt then cd /opt

3)Install squid in cd /opt: "rpm -ivh squid-2.5.STABLE6-3.i386.rpm"

4) After install success need to edit squid.conf like below:
vi /etc/squid.conf
=================================================
http_port 192.168.0.1:3128
heirarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
cache_mem 32 # use 32MB of memory only
cache_swap_low 80 # set cache sensitivity
cache_swap_high 100 # set cache sensitivity
maximum_object_size 1024 KB # if objects are too large, dont cache
cache_dir ufs /var/spool/squid 512 16 256 # use 512mb disk space for cache only
cache_access_log /var/log/squid/access.log (none in Future) # disable logs access
cache_log none # disable the object cache logs
cache_store_log none # disable the store cache logs
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
half_closed_clients off # don't monitor browser status
acl all src 0.0.0.0/0.0.0.0
acl full_host src 192.168.0.0/255.255.255.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https, snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow full_host
http_access deny all
http_reply_access allow all
# Transparent Proxy setting
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on /for tran.should be on add that four lines
=================================================
save the file: Esc, Shift+:wq (save and quit)

5) After squid configure need to add command in IPtables:
"iptables –t nat –A PREROUTING –p tcp –m tcp --dport 80 –j DNAT --to–destination 192.168.0.1:3128"

6) Save in Iptables : "iptables-save > /etc/sysconfig/iptables"

7) Need to start squid service: "service squid start"

8) Squid start auto during boot service: Go to "ntsysv" check 'squid' option and OK

9) You can interactively see the squid logs using the
command: "tail –f /var/log/squid/access.log"

10) If not working....restart services "Network / Squid / iptables"
service network restart / service squid restart / service iptables restart


Credits: nsharif.blogspot.com

Bash Scripting for squid and Cron job autmation in linux

2

CRON has several options but we’ll discuss it generally by assuming you are root user. The default root script of cron can be found in /var/spool/cron/root where “root” is the user and the file contains command or scripts to execute at a given time.

CRON has the follow syntax:

[root@server01 ~]# vi /var/spool/cron/root

30 15 * * * sh /root/scripts/clear_squid.sh

This means every on 3:30pm, it will run clear_squid.sh. if you want to add more scripts, simply add it under the last schedule.

[root@server01 ~]# mkdir scripts
[root@server01 ~]# cd scripts
[root@scripts ]# vi clear_squid.sh

Bash scripting:
#!/bin/bash
rm /var/log/squid/* -Rf
rm /var/spool/squid/* -RF
/sbin/service squid restart
exit 0

The first line tells the script is bash and it tells where to find the interpreter / second line tells the command to delete all squid logs / third line tells the command to delete all squid cache / fourth line tells the command to restart squid / fifth line tells the command to exit properly with status 0 After making the script you have to change the file properties so it will be executable

[root@scripts ]# chmod 744 clear_squid.sh

You can either run the file manual or have it scheduled will do the same.
U needs to restart Crond:
[root@scripts ]# service crond restart

You can list active cron task with the following command:
[root@scripts ]# crontab –u root –l


Credits: nsharif.blogspot.com


Nat or Sharing enable between two lan cards in Redhat Linux ES4

0
1)Two Lan cards details:
Eth0 : (WAN)
IP address: 66.178.43.4
Subnet mask: 255.255.255.128
Defaut Gateway: 66.178.43.1

Eth1: (LAN)
IP address 192.168.0.1
Subnet mask: 255.255.255.0
Default Gatway: 66.178.43.4 (eth0)

2) Packet forwarding from Eth0 – Eth1:

Vi /etc/sysctl.conf
==============================================
# Controls IP packet forwarding
net.ipv4.ip_forward = 0 [Change to "1"]
==============================================
save file: Esc, Shift+: wq (save and quit)

3) How to enable IPtables between two lan cards to pass data:
"iptables –t nat –A POSTROUTING –o eth0 –j SNAT –-to–source 66.178.43.4"

then save IPtables : "iptables-save > /etc/sysconfig/iptables"

service network restart...........

4) Should be enable iptables from boot " ntsysv" clik iptables

Credits: nsharif.blogspot.com




DHCP Enable in Redhat Enterprise 4

0

I) Need to check in Linux DHCP installed or not first ?

2) In teminal type : "rpm -q dhcp" like below


[root@iccserver ~]# rpm -q dhcp
package dhcp is not installed


3) if not install software -
please get rpm file from http://rpmfind.net search 'dhcp' and get this
file "dhcp-3-0.EL.i386.rpm" for Redhat ES4 & save to /opt then cd /opt


4) then install "rpm -ivh dhcp-3-0.EL.i386.rpm" enter like below

[root@iccserver opt]# rpm -ivh dhcp-3.0.5-3.el5.i386.rpm
warning: dhcp-3.0.5-3.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:dhcp ########################################### [100%]
[root@iccserver opt]#


5) After install success need to edit dhcpd.conf like below:

Vi /etc/dhcpd.conf
=============================================================
ddns-update-style interim;
ignore client-updates;

subnet 192.168.0.0 netmask 255.255.255.0 {
authoritative;
deny unknown-clients;
# --- default gateway
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option domain-name "www.nsharif.com,";
option domain-name-servers 66.178.2.25, 66.178.2.16;
option time-offset -18000;
range dynamic-bootp 192.168.0.5 192.168.0.253;
default-lease-time 51600;
max-lease-time 93200;
#}

# through mac address assigned ip address without aquiring like below
host sharif {
ddns-updates on;
hardware ethernet 00:00:E2:47:12:75;
fixed-address 192.168.0.150;
}
host xxx {
ddns-updates on;
hardware ethernet 00:00:E2:47:12:75;
fixed-address 192.168.0.131;
}
}
=================================================================
save command : Esc, shift+: wq (will save and quit from dhcpd.conf)

6) Assign which interface want to get dhcp range and edit below file:
Vi /etc/sysconfig/dhcpd
=============================
DHCPDARGS=eth0 or eth1
=============================
save command : Esc, shift+: wq (will save and quit from dhcpd.conf)
7) service dhcpd start - ( it will show success [ok] if not check file any mistakes in dhcpd.conf)

8) service network restart

9) If need start by auto during boot : go to "ntsysv" check the option "dhcpd" then clik save.

10) For checking dhcp lease :
touch /var/lib/dhcp/dhcpd.leases ( it will result dhcp client list).............