SQUID TPROXY 모드가 동작을 안합니다..!!

ovsm의 이미지

제가 지금 squid를 사용해서 투명 프록시를 구성할려고 합니다
구성환경은
- squid 3.1.20
- Centos6.2
- 커널 2.6.32
- IPTABLE 1.4.7

squid
|
|
스위치-----Web server
|
|
PC

pc ip : 192.168.0.143
squid ip : 192.168.0.240(eth4)
web server ip: 192.168.0.197

이렇게 구성해서 모두 웹캐싱돼는것 까지는 전부 확인하였는데.

pc에서 squid를 거쳐 Web server에 접속한다음 웹서버 쪽에서
tcpdump 사용하여 80포트의 내용을 보니깐
PC의 IP가 찍혀있지 않고 squid가 있는 장비의 ip가 찍혀 있습니다.
그럼 tproxy 모드가 작동 하지 않는것 같은데...
어떤 것 때문에 그런지 모르겠습니다.
도와주세요.!!

squid.conf************************************
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

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.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # 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

http_access allow all
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports

http_access allow localnet
http_access allow localhost

http_port 3129 transparent
http_port 80 vhost

cache_dir ufs /usr/local/squid/var/cache 500 16 256
coredump_dir /usr/local/squid/var/cache

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

always_direct allow all
cache_effective_user squid
cache_effective_group squid
visible_hostname ns
visible_hostname ns
dns_nameservers 168.126.63.1

hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \? ## asp jsp php
cache deny QUERY
acl apache rep_header Server ^Apache
access_log /usr/local/squid/var/logs/access.log squid
cache_log /usr/local/squid/var/logs/cache.log
cache_store_log /usr/local/squid/var/logs/store.log
hosts_file /etc/hosts
*************************************************************

iptables 설정****************************************************
# Generated by iptables-save v1.4.7 on Wed Jul 18 11:51:57 2012
*nat
:PREROUTING ACCEPT [932:83166]
:POSTROUTING ACCEPT [188:12883]
:OUTPUT ACCEPT [188:12883]
-A PREROUTING -i eth4 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3129

COMMIT
# Completed on Wed Jul 18 11:51:57 2012
# Generated by iptables-save v1.4.7 on Wed Jul 18 11:51:57 2012
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [1251:418871]
-A INPUT -p tcp -m tcp --dport 3129 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 3128 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3128 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3129 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type any -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -i lo -j ACCEPT
COMMIT
# Completed on Wed Jul 18 11:51:57 2012
# Generated by iptables-save v1.4.7 on Wed Jul 18 11:51:57 2012
*mangle
:PREROUTING ACCEPT [3686:805682]
:INPUT ACCEPT [3686:805682]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [2892:797404]
:POSTROUTING ACCEPT [2892:797404]
#-A PREROUTING -i eth4 -p tcp -m tcp --dport 80 -j TPROXY --on-port 3128 --on-ip 0.0.0.0 --tproxy-mark 0x1/0x1
-A PREROUTING -i eth4 -p tcp -m tcp --dport 80 -j TPROXY --on-port 3129 --on-ip 0.0.0.0 --tproxy-mark 0x1/0x1
-A PREROUTING -i eth4 -p tcp -m tcp --dport 80 -j TPROXY --on-port 3129 --on-ip 192.168.0.240 --tproxy-mark 0x1/0x1

COMMIT
# Completed on Wed Jul 18 11:51:57 2012

sunbee의 이미지

궁금하네요~

bacon의 이미지

테스트를 할수 없어서 정확하게는 모르겠으나 몇가지 의심스러운게 보입니다.

- TRPOXY만 사용하려면 nat/PREROUTING에 REDIRECT는 불필요.
- mangle/PREROUTING에 있는 두번째 TROXY룰도 그다지 중요해 보이진 않음. (아님 반대로 첫번째가 안 중요 할수도..
- squid설정중에 http_port 3129 transparent를 http_port 3129 tproxy로 바꿀필요가 있어 보임.

참고로 프로그래밍적인 이야기를 좀 하자면..., PC주소가 아니고 장비IP가 보여진다는것은 현재 squid가 REDIRECT를 통해서 들어오는 패킷을 getsockopt (... SO_ORIGINAL_DST ...)로 원래 destination을 찾아서 처리하고 있다는 것을 말해주는 겁니다. 이경우에 getsockname()은 로컬주소를 돌려줍니다. TRPOXY를 사용하고 socket에 IP_TRANSPARENT가 설정되어 있으면, getsockname()이나 SO_ORIGINAL_DST나 모두 원래 destination을 돌려줍니다. squid도 이런 방법으로 처리를 하는걸로 알고 있습니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.