Think before you type.
With great power comes great responsibility.
IF you don´t take control of your data, someone else Will.
The only Way to Stop a Hacker is to think like One
To gain knowledge there is no shortcut
26 April 2010
OpenBSD With Squid|Named
Enable Forwarding:
~# sysctl net.inet.ip.forwarding=1
~# grep -v ^# /etc/sysctl.conf
net.inet.ip.forwarding=1
Enable PF:
~# cat /etc/rc.conf.local
pf=YES # Packet filter / NAT
pf_rules=/etc/pf.conf # Packet filter rules file
~# cat /etc/pf.conf
# pf rulez!
#
# macros
ext_if="pcn0"
int_if="pcn1"
tcp_services="{ 3389, 10023 }"
icmp_types="echoreq"
WTS="192.168.56.1"
# options
set block-policy return
set loginterface $ext_if
set skip on lo
# scrub
match in all scrub (no-df)
# nat/rdr
nat on $ext_if from !($ext_if) -> ($ext_if:0)
nat-anchor "ftp-proxy/*"
rdr-anchor "ftp-proxy/*"
rdr pass on $int_if proto tcp to port 21 -> 127.0.0.1 port 8021
rdr pass on $int_if proto tcp to port 80 -> 127.0.0.1 port 3128
rdr pass on $int_if proto { tcp, udp } to port 53 -> 127.0.0.1 port 53
rdr on $ext_if proto tcp from any to any port 3389 -> $WTS
no rdr all
# filter rules
block in
pass out keep state
anchor "ftp-proxy/*"
antispoof quick for { lo $int_if }
pass in on $ext_if inet proto tcp from any to ($ext_if) \
port $tcp_services flags S/SA keep state
pass in on $ext_if inet proto tcp from any to $WTS port 3389 \
flags S/SA synproxy state
pass in inet proto icmp all icmp-type $icmp_types keep state
pass in quick on $int_if
Install The Squid-Cache:
~# cd /usr/ports/www/squid ; make install clean
~# chgrp _squid /dev/pf
~# chmod g+rw /dev/pf
~# tail /etc/devfs.conf
# Allow Squid read access to /dev/pf
own pf root:squid
perm pf 0640
Just a simple example:
~# cat /etc/squid/squid.conf
# ======= BEGIN ==================================
http_port 127.0.0.1:3128 transparent
hierarchy_stoplist cgi-bin ?
access_log /var/squid/logs/access.log squid
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
acl all src all
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
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
acl shoutcast rep_header X-HTTP09-First-Line ^ICY.[0-9]
upgrade_http0.9 deny shoutcast
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
acl localnet src YOUR-LAN-NET
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localnet
http_access deny all
icp_access allow localnet
icp_access deny all
coredump_dir /var/squid/cache
# ======= END ==================================
~# squid -z ; squid
~# cat /etc/rc.local
...
if [ -x /usr/local/sbin/squid ]; then
echo -n '[*] squid'; /usr/local/sbin/squid
fi
Configure Named:
zur named \>ls -l /var/named/
total 12
drwxr-xr-x 2 root wheel 512 Jul 10 2009 dev
drwxr-x--- 2 root named 512 Apr 8 07:34 etc
drwxr-xr-x 2 root wheel 512 Jul 10 2009 master
drwxrwxr-x 2 root named 512 Jul 10 2009 slave
drwxr-xr-x 2 root wheel 512 Jul 10 2009 standard
drwxrwxr-x 2 root named 512 Jul 10 2009 tmp
~# cat /etc/resolv.conf
search d0.l1
nameserver 127.0.0.1
~# cat /var/named/etc/named.conf
// $OpenBSD: named-simple.conf,v 1.9 2008/08/09
// Example file for a simple named configuration, processing both
// recursive and authoritative queries using one cache.
// Update this list to include only the networks for which you want
// to execute recursive queries. The default setting allows all hosts
// on any IPv4 networks for which the system has an interface, and
// the IPv6 localhost address.
acl clients {
YOUR-LAN-NET-HERE; 127.0.0.1; ::1;
};
options {
version "2w"; // remove this to allow version queries
forward first;
forwarders { FORWARDS-IPS; FORWARDS-IPS; };
listen-on { ::1; 127.0.0.1; };
listen-on-v6 { ::1; };
empty-zones-enable yes;
allow-recursion { clients; };
};
logging {
category lame-servers { null; };
};
// Standard zones
//
zone "." {
type hint;
file "etc/root.hint";
};
zone "localhost" {
type master;
file "standard/localhost";
allow-transfer { localhost; };
};
zone "127.in-addr.arpa" {
type master;
file "standard/loopback";
allow-transfer { localhost; };
};
zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa"
{
type master;
file "standard/loopback6.arpa";
allow-transfer { localhost; };
};
Add to /etc/rc.conf.local:
named_flags="" # note use two double-quotes
named_user=named # note to leave this as per standard setting
named_chroot=/var/named # note to leave this as per standard setting
To test your settings without having to restart your machine
you can use the following command-line to perform the same
things as specified in the above configuration settings:
~# named-checkconf /var/named/etc/named.conf
~# named -t /var/named -u named
~# tcpdump port 53
tcpdump: listening on pcn0, link-type EN10MB
13:19:42.506425 zur.d0.l1.23790 > dns.d0.l1.domain: 20203+% [1au] A? www.terra.com.br. (45)
13:19:42.506829 dns.d0.l1.domain > zur.d0.l1.23790: 20203 1/0/1 A www.terra.com.br (61)
13:19:42.564249 zur.d0.l1.26599 > dns.d0.l1.domain: 40795+% [1au] PTR? 80.56.154.200.in-addr.arpa. (55)
13:19:42.664319 dns.d0.l1.domain > zur.d0.l1.26599: 40795 1/2/3 PTR www.terra.com.br. (153)
13:19:42.864608 zur.d0.l1.9091 > dns.d0.l1.domain: 60382+ PTR? 2.13.168.192.in-addr.arpa. (43)
13:19:42.864776 dns.d0.l1.domain > zur.d0.l1.9091: 60382* 1/0/0 PTR dns.d0.l1. (74)
13:19:42.872191 zur.d0.l1.27466 > dns.d0.l1.domain: 52455+ PTR? 80.56.154.200.in-addr.arpa. (44)
13:19:42.872343 dns.d0.l1.domain > zur.d0.l1.27466: 52455 1/0/0 PTR www.terra.com.br. (74)
It Works!! =)
[1]
[2]
[3]
biOos
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment