Код: Выделить всё
#PF
device pf
device pflog
device pfsync
#PF-QOS
options ALTQ
options ALTQ_CBQ # Class Bases Queuing (CBQ)
options ALTQ_RED # Random Early Detection (RED)
options ALTQ_RIO # RED In/Out
options ALTQ_HFSC # Hierarchical Packet Scheduler (HFSC)
options ALTQ_PRIQ # Priority Queuing (PRIQ)
options ALTQ_NOPCC # Required for SMP build
Код: Выделить всё
SQUID_PF "Enable transparent proxying with PF" on \
pf.conf
Код: Выделить всё
ext_if="rl0"
int_if="re0"
nat on $ext_if proto { tcp udp icmp } from $int_if:network to any -> ($ext_if)
#nat on rl0 from re0:network to any -> (rl0) ###тоже пробовал
pass out
Код: Выделить всё
all tcp 192.168.1.1:53366 -> 192.168.1.2:3389 ESTABLISHED:ESTABLISHED
all udp 192.168.1.1:53 -> 192.168.1.205:55187 SINGLE:NO_TRAFFIC
all tcp 10.100.10.162:61539 -> 93.186.229.2:80 ESTABLISHED:ESTABLISHED
all tcp 10.100.10.162:64313 -> 194.186.121.35:80 TIME_WAIT:TIME_WAIT
all tcp 10.100.10.162:56816 -> 217.73.200.221:80 FIN_WAIT_2:FIN_WAIT_2
all tcp 10.100.10.162:65338 -> 194.186.121.35:80 TIME_WAIT:TIME_WAIT
all udp 192.168.1.1:53 -> 192.168.1.7:54163 SINGLE:NO_TRAFFIC
all icmp 192.168.1.1:31236 -> 192.168.1.1 0:0
all icmp 192.168.1.1:31236 -> 192.168.1.7 0:0
all icmp 192.168.1.1:31236 -> 192.168.1.50 0:0
all icmp 192.168.1.1:31236 -> 192.168.1.53 0:0
all icmp 192.168.1.1:31236 -> 192.168.1.55 0:0
all icmp 192.168.1.1:31236 -> 192.168.1.56 0:0
all tcp 10.100.10.162:51549 -> 217.69.128.41:80 FIN_WAIT_2:FIN_WAIT_2
all icmp 192.168.1.1:31236 -> 192.168.1.40 0:0
all icmp 192.168.1.1:31236 -> 192.168.1.57 0:0
all udp 192.168.1.1:53 -> 192.168.1.2:62017 SINGLE:NO_TRAFFIC
all udp 192.168.1.1:5555 -> 192.168.1.2:5555 MULTIPLE:MULTIPLE
all icmp 192.168.1.1:31236 -> 192.168.1.2 0:0
all icmp 192.168.1.1:31236 -> 192.168.1.120 0:0
all icmp 192.168.1.1:31236 -> 192.168.1.205 0:0
Код: Выделить всё
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=389b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_UCAST,WOL_MCAST,WOL_MAGIC>
ether 00:1b:b9:c9:88:6c
inet 192.168.1.1 netmask 0xffffff00 broadcast 192.168.1.255
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
rl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=8<VLAN_MTU>
ether 00:02:44:26:68:14
inet 10.100.10.162 netmask 0xfffffffc broadcast 10.100.10.163
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
plip0: flags=108810<POINTOPOINT,SIMPLEX,MULTICAST,NEEDSGIANT> metric 0 mtu 1500
pflog0: flags=141<UP,RUNNING,PROMISC> metric 0 mtu 33204
pfsync0: flags=0<> metric 0 mtu 1460
syncpeer: 224.0.0.240 maxupd: 128
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x6
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask 0xff000000
Код: Выделить всё
defaultrouter="10.100.10.161"
hostname="myhost.provader.ru"
ifconfig_re0="inet 192.168.1.1 netmask 255.255.255.0"
ifconfig_rl0="inet 10.100.10.162 netmask 255.255.255.252"
##########################################################
################
sshd_enable="YES"
font8x8="cp866-8x8"
font8x14="cp866-8x14"
font8x16="cp866b-8x16"
scrnmap="koi8-r2cp866"
keyrate="normal"
keymap="ru.koi8-r"
##
firewall_enable="YES"
firewall_script="/etc/myfw.fw"
firewall_loging="YES"
####
proftpd_enable="YES"
webmin_enable="YES"
###############
smbd_enable="YES"
nmbd_enable="YES"
###PF##
pf_enable="YES"
pf_rules="/etc/pf.conf"
pf_program="/sbin/pfctl"
pf_flags=""
pflog_enable="YES"
pflog_logfile="/var/log/pf.log"
pflog_program="/sbin/pflogd"
pflog_flags=""
pfsync_enable="NO"
pfsync_syncdev=""
pfsync_ifconfig=""
##
gateway_enable="YES"
############################
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
###########################
named_enable="YES"
rinetd_enable="YES"
mysql_enable="YES"
apache22_enable="YES"
squid_enable="YES"
Код: Выделить всё
#!/bin/sh -
###
inn='re0' #192.168.1.1
ipin='192.168.1.1'
innet='192.168.1.0/24'
###
out='rl0'
ipout='10.100.10.162'
#
ipfw="/sbin/ipfw -q"
#natdcmd="/sbin/natd"
####################
${ipfw} -f flush
${ipfw} add 100 deny ip from not 192.168.1.110 to me dst-port 3128 in via ${inn}
${ipfw} add 200 deny ip from 192.168.0.0/16 to any in via ${out}
${ipfw} add 400 deny icmp from any to any frag
${ipfw} add 500 deny ip from any to not me via ${out} in
${ipfw} add 510 deny ip from any to 192.168.0.0/16,10.0.0.0/16,172.16.0.0/12 out via ${out}
${ipfw} add 520 deny ip from 0.0.0.0/8,224.0.0.0/4,10.0.0.0/8,172.16.0.0/12 to any out via ${out}
${ipfw} add 530 deny ip from not ${innet} to any in via ${inn}
#################DIVERT!!! Отключил natd###########################
#${ipfw} add 700 divert natd ip4 from ${innet} to any out via ${out}
#${ipfw} add 700 divert natd ip4 from any to ${ipout} in via ${out}
#####################################################
${ipfw} add 710 check-state
${ipfw} add 720 allow ip from any to any via lo0
${ipfw} add 730 allow ip from me to any keep-state
##
${ipfw} add 740 deny all from any to 127.0.0.0/8
${ipfw} add 750 deny ip from 127.0.0.0/8 to any
########################################
${ipfw} add 780 allow tcp from any to me 27,25
#FTP
${ipfw} add 785 allow ip from any 20,21 to me keep-state
${ipfw} add 785 allow ip from any to me 20,21 keep-state
#####
${ipfw} add 800 allow ip from ${innet} to me 80,110,445,137-139,10000,5555,8080 in via ${inn}
${ipfw} add 810 allow icmp from any to me icmptypes 0,3,8
${ipfw} add 820 allow ip from any to me 53
##
# Allow access to our WWW
${ipfw} add 823 allow tcp from any to ${ipout} 80 via ${out}
#
${ipfw} add 65534 deny log ip from any to any
Код: Выделить всё
http_port 192.168.1.1:8080 #####- сейчас, временно юзеры ходят через этот прокси порт прописаный в браузере
http_port 127.0.0.1:3128 transparent
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
cache_mem 64 MB
#maximum_object_size 16384 KB
dns_nameservers localhost
#cache_dir ufs /usr/local/squid/cache 3000 16 256
cache_dir ufs /250/shares/squid/cache 50000 64 512
cache_access_log /usr/local/squid/logs/access.log
cache_log /usr/local/squid/logs/cache.log
#cache_store_log /usr/local/squid/logs/store.log
cache_store_log none
pid_filename /usr/local/squid/squid.pid
ftp_user admin@myhost.provader.ru
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
quick_abort_pct 70
negative_ttl 1 minute
positive_dns_ttl 6 hour
negative_dns_ttl 1 minute
#Recommended minimum configuration:
acl all src 0.0.0.0/0.0.0.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 20 # 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
no_cache deny QUERY localhost to_localhost
acl net src 192.168.1.0/24
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow net
icp_access allow all
cache_mgr admin@myhost.provader.ru
cache_effective_user squid
cache_effective_group squid
####
forwarded_for on
cachemgr_passwd passwd all
client_db on
error_directory /usr/local/etc/squid/errors/Russian-koi8-r
coredump_dir /usr/local/squid/cache
Код: Выделить всё
#!/usr/local/bin/bash
#Этот скрипт вызывается в момент, когда пользователь
#успешно прошел авторизацию на сервере. Задача скрипта - перестроить
#файрвол так, что бы пользователь получил доступ в интернет
# Login
LOGIN=$1
IP=$2
#cash
CASH=$3
#user ID
ID=$4
#Selected dirs to connect
DIRS=$5
ipfw="/sbin/ipfw"
inn='re0'
SG=`/usr/local/sbin/squid -k reconfigure`
test -x /var/stargazer/users/$LOGIN/OnConnect
if [ $? == 0 ]
then
echo $IP > /var/stargazer/users/$LOGIN/ip
echo $ID > /var/stargazer/users/$LOGIN/id
echo $LOGIN > /var/stargazer/users/$LOGIN/login
cd /var/stargazer/users/$LOGIN/ && ./OnConnect
$SG
exit 0
fi
echo "connect $LOGIN $IP" >> /usr/local/stargazer/var/log/connect.log