PF + squid transparent

Простые/общие вопросы по UNIX системам. Спросите здесь, если вы новичок

Модераторы: vadim64, terminus

Правила форума
Убедительная просьба юзать теги [cоde] при оформлении листингов.
Сообщения не оформленные должным образом имеют все шансы быть незамеченными.
jakaz
проходил мимо
Сообщения: 2
Зарегистрирован: 2014-11-27 18:15:52

PF + squid transparent

Непрочитанное сообщение jakaz » 2014-11-27 18:38:27

Добрый вечер!

Пытаюсь настроить связку pf + squid transparent на тестовой машине. Если прописывать руками настройки в браузере - всё работает. А вот в прозрачном режиме работать не хочет. Смотрел tcpdump' oм, запрос идет с клиентского IP напрямую, т.е. PF не редиректит запросы на 80 порту. Через ipfw все отрабатывает нормально. Уже 3 дня копаю, перелопатил всю литературу, но видимо что-то упустил :smile: Подскажите что делаю не так


Код: Выделить всё

uname -a
FreeBSD Testsq.test.domain 8.4-RELEASE FreeBSD 8.4-RELEASE #0: Tue Nov 25 13:14:35 EET 2014     vet@Testsq:/usr/src/sys/i386/compile/MYCONF  i386

Код: Выделить всё

Squid Cache: Version 3.3.13
configure options:  '--with-default-user=squid' '--bindir=/usr/local/sbin' '--sbindir=/usr/local/sbin' '--datadir=/usr/local/etc/squid' '--libexecdir=/usr/local/libexec/squid' '--localstatedir=/var' '--sysconfdir=/usr/local/etc/squid' '--with-logdir=/var/log/squid' '--with-pidfile=/var/run/squid/squid.pid' '--with-swapdir=/var/squid/cache/squid' '--enable-auth' '--enable-build-info' '--enable-loadable-modules' '--enable-removal-policies=lru heap' '--disable-epoll' '--disable-linux-netfilter' '--disable-linux-tproxy' '--disable-translation' '--disable-eui' '--disable-cache-digests' '--disable-delay-pools' '--disable-ecap' '--disable-esi' '--disable-follow-x-forwarded-for' '--enable-htcp' '--disable-icap-client' '--disable-icmp' '--enable-ident-lookups' '--disable-ipv6' '--enable-kqueue' '--without-large-files' '--disable-http-violations' '--enable-snmp' '--disable-ssl' '--disable-ssl-crtd' '--disable-stacktraces' '--disable-ipf-transparent' '--disable-ipfw-transparent' '--enable-pf-transparent' '--disable-forw-via-db' '--enable-wccp' '--enable-wccpv2' '--enable-auth-basic=DB MSNT MSNT-multi-domain NCSA PAM POP3 RADIUS fake getpwnam' '--enable-auth-digest=file' '--enable-external-acl-helpers=file_userip time_quota unix_group' '--enable-auth-negotiate=none' '--enable-auth-ntlm=fake smb_lm' '--enable-storeio=diskd rock ufs aufs' '--enable-disk-io=AIO Blocking DiskDaemon IpcIo Mmapped DiskThreads' '--enable-log-daemon-helpers=file' '--enable-url-rewrite-helpers=fake' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=i386-portbld-freebsd8.4' 'build_alias=i386-portbld-freebsd8.4' 'CC=cc' 'CFLAGS=-O2 -pipe -fno-strict-aliasing' 'LDFLAGS= -pthread' 'LIBS=' 'CPPFLAGS=' 'CXX=c++' 'CXXFLAGS=-O2 -pipe -fno-strict-aliasing' 'CPP=cpp' --enable-ltdl-convenience

Код: Выделить всё

squid.conf
#
# Recommended minimum configuration:
#

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8     # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.20.0/24        # RFC1918 possible internal network
acl localnet src       # RFC 4193 local private network range
acl localnet src      # RFC 4291 link-local (directly plugged) machines

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

#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost
visible_hostname test.local.domain
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access deny all

# Squid normally listens to port 3128
http_port 192.168.20.1:3128 intercept
http_port 3129

# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /var/squid/cache/squid 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/squid/cache/squid

#
# Add any of your own refresh_pattern entries above these.
#
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

Код: Выделить всё

/pf.conf
int_if="em1" 
ext_if="em0"

lan="192.168.20.0/24"

set block-policy return
set skip on lo0
set skip on $int_if
scrub in all

rdr pass on $int_if inet proto tcp from $lan to any port 80 -> 192.168.20.1 port 3128


pass in all
pass in all

Хостинговая компания Host-Food.ru
Хостинг HostFood.ru
 

Услуги хостинговой компании Host-Food.ru

Хостинг HostFood.ru

Тарифы на хостинг в России, от 12 рублей: https://www.host-food.ru/tariffs/hosting/
Тарифы на виртуальные сервера (VPS/VDS/KVM) в РФ, от 189 руб.: https://www.host-food.ru/tariffs/virtualny-server-vps/
Выделенные сервера, Россия, Москва, от 2000 рублей (HP Proliant G5, Intel Xeon E5430 (2.66GHz, Quad-Core, 12Mb), 8Gb RAM, 2x300Gb SAS HDD, P400i, 512Mb, BBU):
https://www.host-food.ru/tariffs/vydelennyi-server-ds/
Недорогие домены в популярных зонах: https://www.host-food.ru/domains/

jakaz
проходил мимо
Сообщения: 2
Зарегистрирован: 2014-11-27 18:15:52

Re: PF + squid transparent

Непрочитанное сообщение jakaz » 2014-11-28 11:42:56

Вот что говорит tcpdump при попытке зайти на ya.ru:

192.168.20.10 - клиен

Код: Выделить всё

root@Testsq:/usr/home/vet # tcpdump -i em1 -n
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on em1, link-type EN10MB (Ethernet), capture size 96 bytes
10:38:14.589021 ARP, Request who-has 192.168.20.1 tell 192.168.20.10, length 46
10:38:14.589371 ARP, Reply 192.168.20.1 is-at 00:0c:29:b2:1c:95, length 28
10:38:14.589457 IP 192.168.20.10.3995 > 213.180.204.3.80: Flags [S], seq 3095807992, win 64240, options [mss 1460,nop,nop,sackOK], length 0
10:38:14.847988 IP 192.168.20.10.3996 > 213.180.193.3.80: Flags [S], seq 2930896783, win 64240, options [mss 1460,nop,nop,sackOK], length 0
10:38:17.684248 IP 192.168.20.10.3995 > 213.180.204.3.80: Flags [S], seq 3095807992, win 64240, options [mss 1460,nop,nop,sackOK], length 0
10:38:18.024049 IP 192.168.20.10.3996 > 213.180.193.3.80: Flags [S], seq 2930896783, win 64240, options [mss 1460,nop,nop,sackOK], length 0
в access.log пусто