LINUX.ORG.RU
ФорумAdmin

Не работает Squid в связке с Strongswan.

 , ,


0

2

Здравствуйте! Помогите решить проблему. Есть VPN сервер под управлением CentOS 6. На нем уже подняты и работают службы squid, openvpn, pptp. Squid работает в режиме прозрачного прокси и пользователи подключившиеся к серверу ходят через него. Сейчас пытаюсь настроить ipsec (strongswan), но в процессе настройки возникла проблема. Если в iptables включен просто nat, без перенаправления 80 порта на squid, сайты по http и https открываются, а если я заворачиваю 80 порт то http не работает только https. Проблема как я предполагаю в squid, только найти ее самостоятельно у меня не получилось, поэтому прошу вашей помощи.

Linux vpn 2.6.32-504.8.1.el6.i686 #1 SMP Wed Jan 28 18:25:26 UTC 2015 i686 i686 i386 GNU/Linux
Squid Cache: Version 3.4.10
configure options:  '--build=i686-redhat-linux-gnu' '--host=i686-redhat-linux-gnu' '--target=i686-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--exec_prefix=/usr' '--libexecdir=/usr/lib/squid' '--localstatedir=/var' '--datadir=/usr/share/squid' '--sysconfdir=/etc/squid' '--with-logdir=$(localstatedir)/log/squid' '--with-pidfile=$(localstatedir)/run/squid.pid' '--disable-dependency-tracking' '--enable-follow-x-forwarded-for' '--enable-auth' '--enable-auth-basic=DB,LDAP,NCSA,NIS,PAM,POP3,RADIUS,SASL,SMB,getpwnam' '--enable-auth-ntlm=smb_lm,fake' '--enable-auth-digest=file,LDAP,eDirectory' '--enable-auth-negotiate=kerberos,wrapper' '--enable-external-acl-helpers=wbinfo_group,kerberos_ldap_group,AD_group' '--enable-cache-digests' '--enable-cachemgr-hostname=localhost' '--enable-delay-pools' '--enable-epoll' '--enable-icap-client' '--enable-ident-lookups' '--with-large-files' '--enable-linux-netfilter' '--enable-removal-policies=heap,lru' '--enable-snmp' '--enable-storeio=aufs,diskd,ufs,rock' '--enable-wccpv2' '--enable-esi' '--enable-ssl' '--enable-ssl-crtd' '--enable-icmp' '--with-aio' '--with-default-user=squid' '--with-filedescriptors=16384' '--with-dl' '--with-openssl' '--with-pthreads' '--with-included-ltdl' '--disable-arch-native' '--without-nettle' 'build_alias=i686-redhat-linux-gnu' 'host_alias=i686-redhat-linux-gnu' 'target_alias=i686-redhat-linux-gnu' 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables' 'CXXFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -fPIC' 'PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/share/pkgconfig' --enable-ltdl-convenience

iptables

-A PREROUTING -s 10.9.0.0/24 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3127
-A POSTROUTING -s 10.9.0.0/24 -o eth0 -j SNAT --to-source xxx.xxx.xxx.xxx

-A INPUT -p tcp -m tcp --dport 22 -j fail2ban-SSH
-A INPUT -i lo -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 0 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A INPUT -p esp -j ACCEPT
-A INPUT -p ah -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 22 -m comment --comment "SSH" -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 80 -m comment --comment "HTTP" -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 443 -m comment --comment "HTTPs" -j ACCEPT
-A INPUT -p tcp -m tcp --dport 1194 -m comment --comment "OpenVPN" -j ACCEPT
-A INPUT -i ppp+ -p tcp -m tcp --dport 3128 -m comment --comment "Squid" -j ACCEPT
-A INPUT -i tun0 -p tcp -m tcp --dport 3128 -m comment --comment "Squid" -j ACCEPT
-A INPUT -i ipsec+ -p tcp -m tcp --dport 3128 -m comment --comment "Squid" -j ACCEPT
-A INPUT -i ppp+ -p tcp -m tcp --dport 3127 -m comment --comment "Squid-Transparent" -j ACCEPT
-A INPUT -i tun0 -p tcp -m tcp --dport 3127 -m comment --comment "Squid-Transparent" -j ACCEPT
-A INPUT -i ipsec+ -p tcp -m tcp --dport 3127 -m comment --comment "Squid-Transparent" -j ACCEPT
-A INPUT -p tcp -m tcp --dport 1723 -m comment --comment "PPTP" -j ACCEPT
-A INPUT -p udp -m udp --dport 1194 -m comment --comment "OpenVPN" -j ACCEPT
-A INPUT -p udp -m udp --dport 500 -m comment --comment "IPSec" -j ACCEPT
-A INPUT -p udp -m udp --dport 4500 -m comment --comment "IPSec" -j ACCEPT
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -p icmp -j ACCEPT
-A FORWARD -i ppp+ -o eth0 -j ACCEPT
-A FORWARD -i eth0 -o ppp+ -j ACCEPT
-A FORWARD -i tun0 -o eth0 -j ACCEPT
-A FORWARD -i eth0 -o tun0 -j ACCEPT
-A FORWARD -i tun0 -o ppp+ -j ACCEPT
-A FORWARD -i ppp+ -o tun0 -j ACCEPT
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
-A OUTPUT -p icmp -j ACCEPT
-A OUTPUT -p esp -j ACCEPT
-A OUTPUT -p ah -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 22 -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 80 -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 443 -j ACCEPT
-A OUTPUT -p udp -m udp --sport 500 -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 1194 -j ACCEPT
-A OUTPUT -p udp -m udp --sport 1194 -j ACCEPT
-A OUTPUT -p udp -m udp --sport 4500 -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 32768:61000 -j ACCEPT
-A OUTPUT -p udp -m udp --sport 32768:61000 -j ACCEPT

squid.conf

#----------------------------------------------------------------
acl localnet src 10.9.0.0/24
acl office_hours        time            00:00-24:00
#----------------------------------------------------------------
acl SSL_ports port 443          # https
acl SSL_ports port 563          # snews
acl SSL_ports port 873          # rsync
#----------------------------------------------------------------
acl Safe_ports port 21          # ftp
acl Safe_ports port 25          # smtp
acl Safe_ports port 70          # gopher
acl Safe_ports port 80          # http
acl Safe_ports port 210         # wais
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 443         # https
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 631         # cups
acl Safe_ports port 777         # multiling http
acl Safe_ports port 873         # rsync
acl Safe_ports port 901         # SWAT
acl Safe_ports port 1025-65535  # unregistered ports
acl purge method PURGE
acl CONNECT method CONNECT
#----------------------------------------------------------------
http_port 10.9.0.1:3127 intercept
http_port 10.9.0.1:3128
#----------------------------------------------------------------
always_direct allow all
#----------------------------------------------------------------
acl adblock url_regex "/etc/squid/adblock.acl"
acl adblock-android dstdomain "/etc/squid/adblock-android.conf"
#acl goodsites   dstdomain "/etc/squid/allowed-sites.conf"
#acl blockfiles  urlpath_regex "/etc/squid/blocks.files.acl"
#----------------------------------------------------------------
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
#http_access allow localnet Safe_ports
#----------------------------------------------------------------
#http_access deny  pptp badsites
#http_access allow pptp goodsites
#http_access deny  pptp
http_access allow localnet CONNECT
http_access deny  localnet adblock
http_access deny  localnet adblock-android
http_access allow localnet office_hours
#----------------------------------------------------------------
http_access deny all
icp_access allow localnet
icp_access deny all
#----------------------------------------------------------------
hierarchy_stoplist cgi-bin ?
#----------------------------------------------------------------
access_log stdio:/var/log/squid/access.log squid
cache_log /var/log/squid/cache.log
cache_store_log stdio:/var/log/squid/store.log
pid_filename /var/run/squid.pid
debug_options ALL,1
#----------------------------------------------------------------
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern (Release|Package(.gz)*)$        0       20%     2880
refresh_pattern .               0       20%     4320
acl shoutcast rep_header X-HTTP09-First-Line ^ICY\s[0-9]
acl apache rep_header Server ^Apache
#----------------------------------------------------------------
hosts_file /etc/hosts
coredump_dir /var/spool/squid
error_directory /usr/share/squid/errors/ru-ru
cache_dir ufs /var/spool/squid 100 16 256
shutdown_lifetime 5 seconds

ipsec.conf

# ipsec.conf - strongSwan IPsec configuration file

# basic configuration

config setup
        # strictcrlpolicy=yes
        # uniqueids = no

# Add connections here.

# Sample VPN connections

conn %default
    dpdaction=clear
    dpddelay=35s
    dpdtimeout=200s

    fragmentation=yes

    # left - local (server) side
    left=%any
    leftauth=pubkey
    leftcert=vpn.crt
    leftsendcert=always
    leftsubnet=0.0.0.0/0

    # right - remote (client) side
    right=%any
    rightauth=pubkey
    rightsourceip=10.9.0.128/25
    rightdns=77.88.8.88,8.8.8.8

conn ikev2-pubkey
    keyexchange=ikev2
    auto=add

conn ikev1
    keyexchange=ikev1
    rightauth2=xauth
    auto=add

conn ikev2-eap-tls
    also="ikev2-pubkey"
    rightauth=eap-tls
    eap_identity=%identity



Последнее исправление: wmlex (всего исправлений: 1)

Ответ на: комментарий от wmlex

Тогда не пойму, а где в правилах фаервола редирект на 3128, и как определяется кто куда пойдет или у вас юзеры ходят через интерцепт порт? Что выдает squid3 -k check?

julixs ★★★
()
Ответ на: комментарий от julixs

У меня в приоритете прозрачное проксирование

-A PREROUTING -s 10.9.0.0/24 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3127

squid -k check

ничего не выдает

wmlex
() автор топика
Ответ на: комментарий от julixs

вот лог tcpdump при попытке перейти на сайт по протоколу http

~# tcpdump -i ipsec0
tcpdump: WARNING: ipsec0: no IPv4 address assigned
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ipsec0, link-type RAW (Raw IP), capture size 65535 bytes
16:04:53.682422 IP 10.9.0.130.47622 > la-in-f94.1e100.net.https: UDP, length 506
16:04:53.682475 IP 10.9.0.130.47622 > la-in-f94.1e100.net.https: UDP, length 29
16:04:53.723221 IP la-in-f94.1e100.net.https > 10.9.0.130.47622: UDP, length 43
16:04:53.730685 IP la-in-f94.1e100.net.https > 10.9.0.130.47622: UDP, length 328
16:04:53.761467 IP 10.9.0.130.60272 > leaseweb.front.habrahabr.ru.http: Flags [S], seq 3225655749, win 27200, options [mss 1360,sackOK,TS val 4093403 ecr 0,nop,wscale 5], length 0
16:04:53.891616 IP 10.9.0.130.47622 > la-in-f94.1e100.net.https: UDP, length 40
16:04:53.932522 IP la-in-f94.1e100.net.https > 10.9.0.130.47622: UDP, length 1350
16:04:53.932633 IP la-in-f94.1e100.net.https > 10.9.0.130.47622: UDP, length 1350
16:04:53.932745 IP la-in-f94.1e100.net.https > 10.9.0.130.47622: UDP, length 1350
16:04:54.051324 IP 10.9.0.130.47622 > la-in-f94.1e100.net.https: UDP, length 37
16:04:54.071181 IP 10.9.0.130.47622 > la-in-f94.1e100.net.https: UDP, length 40
16:04:54.761548 IP 10.9.0.130.60272 > leaseweb.front.habrahabr.ru.http: Flags [S], seq 3225655749, win 27200, options [mss 1360,sackOK,TS val 4093503 ecr 0,nop,wscale 5], length 0
16:04:56.761534 IP 10.9.0.130.60272 > leaseweb.front.habrahabr.ru.http: Flags [S], seq 3225655749, win 27200, options [mss 1360,sackOK,TS val 4093703 ecr 0,nop,wscale 5], length 0
16:04:57.333327 IP 10.9.0.130.60271 > leaseweb.front.habrahabr.ru.http: Flags [S], seq 1804578623, win 27200, options [mss 1360,sackOK,TS val 4093760 ecr 0,nop,wscale 5], length 0
16:05:00.771580 IP 10.9.0.130.60272 > leaseweb.front.habrahabr.ru.http: Flags [S], seq 3225655749, win 27200, options [mss 1360,sackOK,TS val 4094104 ecr 0,nop,wscale 5], length 0
16:05:01.811659 IP 10.9.0.130.39327 > dsde448-2.fornex.org.http: Flags [S], seq 2784251450, win 27200, options [mss 1360,sackOK,TS val 4094208 ecr 0,nop,wscale 5], length 0
16:05:08.792178 IP 10.9.0.130.60272 > leaseweb.front.habrahabr.ru.http: Flags [S], seq 3225655749, win 27200, options [mss 1360,sackOK,TS val 4094906 ecr 0,nop,wscale 5], length 0
16:05:09.491891 IP 10.9.0.130.39325 > dsde448-2.fornex.org.http: Flags [S], seq 2931413352, win 27200, options [mss 1360,sackOK,TS val 4094976 ecr 0,nop,wscale 5], length 0
16:05:11.731988 IP 10.9.0.130.39328 > dsde448-2.fornex.org.http: Flags [S], seq 1238581013, win 27200, options [mss 1360,sackOK,TS val 4095200 ecr 0,nop,wscale 5], length 0
^C
19 packets captured
19 packets received by filter
0 packets dropped by kernel

вот тоже но только по https

~# tcpdump -i ipsec0
tcpdump: WARNING: ipsec0: no IPv4 address assigned
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ipsec0, link-type RAW (Raw IP), capture size 65535 bytes
16:07:46.969646 IP 10.9.0.130.39325 > dsde448-2.fornex.org.http: Flags [S], seq 2931413352, win 27200, options [mss 1360,sackOK,TS val 4100992 ecr 0,nop,wscale 5], length 0
16:07:48.331299 IP 10.9.0.130.46365 > 64.233.161.94.https: UDP, length 574
16:07:48.331354 IP 10.9.0.130.46365 > 64.233.161.94.https: UDP, length 29
16:07:48.382506 IP 64.233.161.94.https > 10.9.0.130.46365: UDP, length 43
16:07:48.391149 IP 64.233.161.94.https > 10.9.0.130.46365: UDP, length 363
16:07:48.409565 IP 10.9.0.130.56884 > mail.ru.https: Flags [S], seq 4009856178, win 27200, options [mss 1360,sackOK,TS val 4101139 ecr 0,nop,wscale 5], length 0
16:07:48.440716 IP mail.ru.https > 10.9.0.130.56884: Flags [S.], seq 2664794072, ack 4009856179, win 5592, options [mss 1410,sackOK,TS val 3616869970 ecr 4101139], length 0
16:07:48.549708 IP 10.9.0.130.46365 > 64.233.161.94.https: UDP, length 40
16:07:48.641178 IP 10.9.0.130.56884 > mail.ru.https: Flags [.], ack 1, win 27200, options [nop,nop,TS val 4101158 ecr 3616869970], length 0
16:07:48.641245 IP 10.9.0.130.56884 > mail.ru.https: Flags [P.], seq 1:206, ack 1, win 27200, options [nop,nop,TS val 4101159 ecr 3616869970], length 205
16:07:48.672564 IP mail.ru.https > 10.9.0.130.56884: Flags [.], ack 206, win 6432, options [nop,nop,TS val 3616870202 ecr 4101159], length 0
16:07:48.678456 IP mail.ru.https > 10.9.0.130.56884: Flags [.], seq 1:1349, ack 206, win 6432, options [nop,nop,TS val 3616870208 ecr 4101159], length 1348
16:07:48.678572 IP mail.ru.https > 10.9.0.130.56884: Flags [.], seq 1349:2697, ack 206, win 6432, options [nop,nop,TS val 3616870208 ecr 4101159], length 1348
16:07:48.678654 IP mail.ru.https > 10.9.0.130.56884: Flags [P.], seq 2697:3711, ack 206, win 6432, options [nop,nop,TS val 3616870208 ecr 4101159], length 1014
16:07:48.849524 IP 10.9.0.130.56884 > mail.ru.https: Flags [.], ack 1349, win 29656, options [nop,nop,TS val 4101180 ecr 3616870208], length 0
16:07:48.869859 IP 10.9.0.130.56884 > mail.ru.https: Flags [.], ack 2697, win 32352, options [nop,nop,TS val 4101180 ecr 3616870208], length 0
16:07:48.889478 IP 10.9.0.130.56884 > mail.ru.https: Flags [.], ack 3711, win 35048, options [nop,nop,TS val 4101180 ecr 3616870208], length 0
16:07:48.929729 IP 10.9.0.130.56884 > mail.ru.https: Flags [P.], seq 206:397, ack 3711, win 35048, options [nop,nop,TS val 4101183 ecr 3616870208], length 191
16:07:48.959776 IP 10.9.0.130.56884 > mail.ru.https: Flags [P.], seq 397:847, ack 3711, win 35048, options [nop,nop,TS val 4101186 ecr 3616870208], length 450
16:07:48.961902 IP mail.ru.https > 10.9.0.130.56884: Flags [P.], seq 3711:3969, ack 397, win 7504, options [nop,nop,TS val 3616870492 ecr 4101183], length 258
16:07:49.011969 IP mail.ru.https > 10.9.0.130.56884: Flags [.], seq 3969:5317, ack 847, win 8576, options [nop,nop,TS val 3616870541 ecr 4101186], length 1348
16:07:49.012084 IP mail.ru.https > 10.9.0.130.56884: Flags [.], seq 5317:6665, ack 847, win 8576, options [nop,nop,TS val 3616870541 ecr 4101186], length 1348
16:07:49.012197 IP mail.ru.https > 10.9.0.130.56884: Flags [.], seq 6665:8013, ack 847, win 8576, options [nop,nop,TS val 3616870541 ecr 4101186], length 1348
16:07:49.189595 IP 10.9.0.130.56884 > mail.ru.https: Flags [.], ack 3969, win 37744, options [nop,nop,TS val 4101212 ecr 3616870492], length 0
16:07:49.220932 IP mail.ru.https > 10.9.0.130.56884: Flags [.], seq 8013:9361, ack 847, win 8576, options [nop,nop,TS val 3616870750 ecr 4101212], length 1348
16:07:49.221056 IP mail.ru.https > 10.9.0.130.56884: Flags [.], seq 9361:10709, ack 847, win 8576, options [nop,nop,TS val 3616870750 ecr 4101212], length 1348

В acess.log сквида новых записей не появляется, складывается токое ощущение что запросы до него просто не доходят.

wmlex
() автор топика
Ответ на: комментарий от wmlex

А сквид вообще запущен? В процессах висит? У меня сквид ругнулся только на hierarchy_stoplist cgi-bin ? мол устаревшая директива, сквид 3.5, у вас клиенты точно через 3127 ходят, пинги тоже не идут? Возможно затык в FORWARD цепочках.

julixs ★★★
()
Ответ на: комментарий от julixs

Сквад запущен. Я же говорю что уже есть openvpn и pptp там все работает, сайты ненужные режутся. проблема только со strongswan. Честно сказать не знаю уже куда копать :(.

wmlex
() автор топика
Ответ на: комментарий от julixs

Через ipsec тунель пингуется как внешка, по ip и доменным именам, так и вн. ресурсы. но вод через браузер открывается только по https.

wmlex
() автор топика
Ответ на: комментарий от wmlex
~# iptables -t nat -vnL
Chain PREROUTING (policy ACCEPT 605 packets, 41042 bytes)
 pkts bytes target     prot opt in     out     source               destination
  244 14640 REDIRECT   tcp  --  *      *       10.9.0.0/24          0.0.0.0/0           tcp dpt:80 redir ports 3127

Chain POSTROUTING (policy ACCEPT 169 packets, 12164 bytes)
 pkts bytes target     prot opt in     out     source               destination
  126 14683 SNAT       all  --  *      eth0    10.9.0.0/24          0.0.0.0/0           to:1x5.xxx.194.xxx

Chain OUTPUT (policy ACCEPT 169 packets, 12164 bytes)
 pkts bytes target     prot opt in     out     source               destination
wmlex
() автор топика
Ответ на: комментарий от julixs

Решение проблемы

-A PREROUTING -s 10.9.0.0/24 -p tcp --dport 80 -j DNAT --to 10.9.0.1:3127

wmlex
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.