From owner-freebsd-ports@freebsd.org Tue Jun 30 16:48:20 2015 Return-Path: Delivered-To: freebsd-ports@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 86B5B9902C1 for ; Tue, 30 Jun 2015 16:48:20 +0000 (UTC) (envelope-from ncrogers@gmail.com) Received: from mail-yk0-x22c.google.com (mail-yk0-x22c.google.com [IPv6:2607:f8b0:4002:c07::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 486941F1B for ; Tue, 30 Jun 2015 16:48:20 +0000 (UTC) (envelope-from ncrogers@gmail.com) Received: by ykfy125 with SMTP id y125so14371893ykf.1 for ; Tue, 30 Jun 2015 09:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=DYOqZbA6CH71fQolBsk15POO5uDxoY1CfF2GiVNuyQk=; b=bus78XPU68geNrfGCVHRDnKSyxQi/qyxLeQWc+bE+si0nnGecGhH98KywtAZi7TWcB vPpRUOb/da18KjQfi/FjaFXm2r3QzUw/tBV9Xyfjd4hLC0U3IMYEvMvER3SCwFPO/Prp qjkwSGnC7eVX+D2pFFwC3dWdXNmxopORjoefStLmFmKmQlAUZbbQDiJZ+Xoj5JZ37Jlc CYldVlIkE9vv4jTZ9SRtWgHPfHHdjqebNFL0dlb8jufZrz2/4X7nLPiFIxMlFrytWqtE hlTNlnsnquI33aDhdmupZlQXMFrtLfLFT2H9I7e0XmgX6PCNLo8WbfqShF8aKWqRLpRs uX+A== MIME-Version: 1.0 X-Received: by 10.129.35.6 with SMTP id j6mr25224864ywj.37.1435682899290; Tue, 30 Jun 2015 09:48:19 -0700 (PDT) Received: by 10.37.203.211 with HTTP; Tue, 30 Jun 2015 09:48:19 -0700 (PDT) Date: Tue, 30 Jun 2015 09:48:19 -0700 Message-ID: Subject: www/squid: tcp_outgoing_address binds to wrong interface From: Nick Rogers To: "freebsd-ports@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jun 2015 16:48:20 -0000 Hello, I am experiencing an issue with squid 3.5.5 and FreeBSD 10.1 where tcp_outgoing_address correctly rewrites the source address of outgoing packets, but fails to bind the socket to the correct interface. I've been using this kind of setup/configuration for quite some time (since the squid 2.7 days), so I believe something between FreeBSD 9.x and 10.1 has broken this behavior. FWIW squid 3.3.3 on FreeBSD 9.x behaves correctly with the same config. My understanding is that squid merely changes the source address as a hint to the kernel routing stack, which makes me believe the problem lies outside of squid. I've already sought out help from the squid-users mailing list and been told the same thing. I've been able to replicate this on a non-production VM with a simple config. For example, I have two WAN interfaces: WAN1 (em0/192.168.92.246) and WAN2 (em1/10.8.8.10), and a LAN interface (em2/192.168.5.1/24). My default route points to the gateway for WAN1/em0. I have configured a tcp_outgoing_address for a single host on the LAN (192.168.5.2) to use outgoing address 10.8.8.10 (WAN2/em1). HTTP request packets from squid end up going out em0 (the default route interface) with an ip of 10.8.8.10. The source IP is correct but the packets egress the wrong interface, so they are obviously dropped by the upstream router on that incorrect interface. This is evident by tcpdump on em0. The following is my test squid.conf and some basic network config. While I normally use squid as a transparent proxy in conjunction with PF+ALTQ for NAT/firewall and routing enabled, for the purposes of replicating the issue in my VM test environment I have disabled PF, routing, and connected directly to squid via my browser's proxy config. Attempts to load webpages time out unless I remove use of the tcp_outgoing_address directive. # begin test squid.conf 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 localhost manager http_access deny manager http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access allow all acl wan2 src 192.168.5.2 tcp_outgoing_address 10.8.8.10 wan2 follow_x_forwarded_for allow localhost acl_uses_indirect_client on log_uses_indirect_client on http_port 3129 cache_replacement_policy heap LFUDA maximum_object_size 768 MB cache_dir aufs /squid/cache 2048 32 512 access_log daemon:/squid/logs/access.log squid cache_log /squid/logs/cache.log cache_store_log none logfile_rotate 0 pid_filename /var/run/squid.pid # end test squid.conf em0: flags=8843 metric 0 mtu 1500 options=9b ether 00:0c:29:a3:33:93 inet 192.168.92.246 netmask 0xffffff00 broadcast 192.168.92.255 nd6 options=9 media: Ethernet autoselect (1000baseT ) status: active em1: flags=8843 metric 0 mtu 1500 options=9b ether 00:0c:29:a3:33:7f inet 10.8.8.10 netmask 0xffffff00 broadcast 10.8.8.255 inet 10.8.8.11 netmask 0xffffff00 broadcast 10.8.8.255 inet 10.8.8.12 netmask 0xffffff00 broadcast 10.8.8.255 inet 10.8.8.13 netmask 0xffffff00 broadcast 10.8.8.255 inet 10.8.8.14 netmask 0xffffff00 broadcast 10.8.8.255 nd6 options=9 media: Ethernet autoselect (1000baseT ) status: active root# netstat -rn | grep default default 192.168.92.2 UGS em0 I am hoping someone can shed some light on this issue. Thank you. -Nick