Help me: Use iptablesdhcpsquid To implement transparent proxy for multiple network segments
Source: Internet
Author: User
For more information, see iptablesdhcpsquid. Squid is installed on a linux (fc6) and transparent proxy is implemented using dhcp and iptables.
The eth0 address is 192.168.8.100, and eth1 is an Internet interface.
Eth0: 1, eth0: 2 ,............ eth0: five sub-interfaces are five network segments: 201.0, 202.0 ,........ 205.0 Dynamic Address Allocation
Configuration file for eth0: 1
DEVICE = eth0: 1
BOOTPROTO = none
BROADCAST = 192.168.201.15
HWADDR = **********
IPADDR = 192.168..1 .1
NETMASK = 255.255.255.255.240
NETWORK = 192.168.201.0
ONBOOT = yes
TYPE = Ethernet
Other similar
Dhcp configuration is
Subnet 192.168.201.0 netmask 255.255.255.248 {
Default-lease-time 86400;
Max-lease-time 259200;
Option routers 192.168..1 .1;
Option subnet-mask quota limit 248;
Option nis-domain "domain.org ";
Option domain-name "domain.org ";
Option time-offset-18000;
Option domain-name-servers: Public Network dns Server
Host pc1 {hardware ethernet :........
Fixed-address:...}. Other network segments are similar.
Iptables implements transparent proxy statement
Echo "1">/proc/sys/net/ipv4/ip_forward
Iptables-t nat-a postrouting-j MASQUERADE
Iptables-t nat-a prerouting-I eth0-p tcp-s 192.168.8.0/24 -- dport 80-j DNAT -- to 192.168.8.100: 3128
Iptables-t nat-a prerouting-I eth0-p tcp-s 192.168..0 .0/29 -- dport 80-j DNAT -- to 192.168..1 .1: 3128
Other CIDR blocks are similar.
Result:
Dhcp allocation is normal
Everything works normally when testing in the eth0 subnet 8.0
However, when testing in the subnet allocated by sub-interfaces such as eth0: 1
You can ping a common IP address, but you cannot connect to the dns when you ping the dns address.
It took a long time to reach this point, and I felt that it was a step worse than success...
Depressing... please take a look
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.