Home > Database > Mysql Tutorial > 接近500台机器上网,使用Rehl 4 +squid+iptables透明代理上网

接近500台机器上网,使用Rehl 4 +squid+iptables透明代理上网

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:30:28
Original
1232 people have browsed it

http_port 3128 cache_mem 512 M cache_swap_low 75 cache_swap_high 95 maximum_object_size 1024 KB cache_dir ufs /usr/local/squid/cache 60000 16 256 cache_access_log /var/squid/logs/access.log cache_log /dev/null cache_store_log none acl net1

http_port 3128


cache_mem 512 M
cache_swap_low 75
cache_swap_high 95
maximum_object_size 1024 KB
cache_dir ufs /usr/local/squid/cache 60000 16 256
cache_access_log /var/squid/logs/access.log
cache_log /dev/null
cache_store_log none


acl net1 src 192.168.1.0/24
acl net2 src 192.168.2.0/24
acl net4 src 192.168.4.0/24
acl net5 src 192.168.5.0/24
acl net13 src 192.168.13.0/24
acl net16 src 192.168.16.0/24




# And finally deny all other access to this proxy
http_access allow localhost
http_access allow net1
http_access allow net2
http_access allow net4
http_access allow net5
http_access allow net13
http_access allow net16
http_access deny all

visible_hostname proxy

httpd_accel_port 80
httpd_accel_host virtual
httpd_accel_with_proxy on
httpd_accel_uses_host_header on


#acl acl_type_deny urlpath_regex -i \.rm$
#acl acl_type_deny urlpath_regex -i \.mp3$
#acl acl_type_deny urlpath_regex -i \.wma$
#acl acl_type_deny urlpath_regex -i \.asf$
#acl acl_type_deny urlpath_regex -i \.avi$
#acl acl_type_deny urlpath_regex -i \.ram$
#acl acl_type_deny urlpath_regex -i \.mpeg$
#acl acl_type_deny urlpath_regex -i \.torrent$

#禁止下载以上类型文件
IPtables配置:

QUOTE:
# /etc/sysconfig/iptables 文件
IPtables配置:
# /etc/sysconfig/iptables 文件
#
#======================= 开始 =======================

#
# mangle 段
*mangle
REROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT
#


#
# nat 段
*nat
REROUTING ACCEPT [0:0]
OSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
#
# 为使用 SQUID 作“透明代理”而设定!

#开放DNS
#[0:0] -A FORWARD -p udp --dport 53 -j ACCEPT
#允许TELNET
#[0:0] -A INPUT -i eth0 -s 192.168.16.254 -d 192.168.2.253 -p tcp --dport 23 -j ACCEPT

# 没有指定 网卡、地址:
#[0:0] -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128

# 指定 网卡、地址:
[0:0] -A PREROUTING -s 192.168.0.0/255.255.0.0 -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128

[0:0] -A POSTROUTING -s 192.168.0.0/255.255.0.0 -o eth0 -j SNAT --to 211.57.143.190
[0:0] -A PREROUTING -i eth0 -p tcp -s 192.168.0.0/255.255.0.0 --sport 443 -j REDIRECT --to-port 3128

# 将 对于 80、443 端口的访问 重定向到 3128 端口。
#

# 这些机器可以走这个机器做网关上 Internet 网。
# 需要在 /etc/sysctl.conf 文件里面修改成 net.ipv4.ip_forward = 1
# 或者 echo 1 > /proc/sys/net/ipv4/ip_forward
# 由于利用 SQUID 实现了“透明代理”,Masq 取消相应的客户地址。

# 若你的 公网的 IP 地址是固定的,使用这个语句似乎更好些:
#[0:0] -A POSTROUTING -s 192.168.0.0/255.255.0.0 -j SNAT --to 211.57.143.190
COMMIT
#

#
# filter 段
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]

#
#
# 防止IP欺骗:
# 所谓的IP欺骗就是指在IP包中存在着不可能的IP源地址或目标地址。
# eth1是一个与外部Internet相连,而192.168.0.0则是内部网的网络号,
# 也就是说,如果有一个包从eth1进入主机,而说自己的源地址是属于
# 192.168.0.0网络,或者说它的目标地址是属于这个网络的,那么这显
# 然是一种IP欺骗,所以我们使用DROP将这个包丢弃。
#[0:0] -A INPUT -d 192.168.0.0/255.255.0.0 -i eth1 -j DROP
#[0:0] -A INPUT -s 192.168.0.0/255.255.0.0 -i eth1 -j DROP
#
# 同样的,如果有包要通过eth1向Internet,而且它的源地址或目标地址是属于
# 网络192.168.0.0,那么显然也是不可能的。我们仍然使用DROP将它丢弃。
[0:0] -A OUTPUT -d 192.168.0.0/255.255.0.0 -o eth1 -j DROP
[0:0] -A OUTPUT -s 192.168.0.0/255.255.0.0 -o eth1 -j DROP
#

# 防止广播包从IP代理服务器进入局域网:
[0:0] -A INPUT -s 255.255.255.255 -i eth0 -j DROP
[0:0] -A INPUT -s 224.0.0.0/224.0.0.0 -i eth0 -j DROP
[0:0] -A INPUT -d 0.0.0.0 -i eth0 -j DROP
# 当包的源地址是255.255.255.255或目标地址是0.0.0.0,则说明它是一个
# 广播包,当广播包想进入eth0时,我们就应该DENY,丢弃它。而240.0.0.0/3
# 则是国际标准的多目广播地址,当有一个源地址是属于多目广播地址的包,
# 我们将用DROP策略,丢弃它。

#
# 屏蔽 windows xp 的 5000 端口(这个端口是莫名其妙的 !)
[0:0] -A INPUT -p tcp -m tcp --sport 5000 -j DROP
[0:0] -A INPUT -p udp -m udp --sport 5000 -j DROP
[0:0] -A OUTPUT -p tcp -m tcp --dport 5000 -j DROP
[0:0] -A OUTPUT -p udp -m udp --dport 5000 -j DROP
#
# 防止 Internet 网的用户访问 SAMBA 服务器:
[0:0] -A INPUT -s 211.57.143.177 -i eth1 -p tcp -m tcp --dport 137:139 -j DROP
[0:0] -A INPUT -s 211.57.143.177 -i eth1 -p udp -m udp --dport 137:139 -j DROP
[0:0] -A INPUT -s 211.57.3.177/255.255.255.240 -i eth1 -p tcp -m tcp --dport 137:139 -j DROP
[0:0] -A INPUT -s 211.57.143.177/255.255.255.240 -i eth1 -p udp -m udp --dport 137:139 -j DROP
[0:0] -A INPUT -p tcp -m tcp --dport 137:139 -j DROP
[0:0] -A INPUT -p udp -m udp --dport 137:139 -j DROP
#
# 允许本地网的用户访问 SAMBA 服务器:
[0:0] -A INPUT -s 192.168.0.0/255.255.255.0 -i eth0 -p tcp -m tcp --dport 137:139 -j ACCEPT
[0:0] -A INPUT -s 192.168.0.0/255.255.255.0 -i eth0 -p udp -m udp --dport 137:139 -j ACCEPT

#
# 对于本局域网用户不拒绝访问:
[0:0] -A INPUT -s 192.168.0.0/255.255.0.0 -i eth0 -p tcp -j ACCEPT
[0:0] -A INPUT -s 192.168.0.0/255.255.0.0 -i eth0 -p udp -j ACCEPT
#

#
[0:0] -A INPUT -i eth1 -p udp -m udp --dport 3 -j DROP
[0:0] -A INPUT -i eth1 -p tcp -m tcp --dport 3 -j DROP
[0:0] -A INPUT -i eth1 -p tcp -m tcp --dport 111 -j DROP
[0:0] -A INPUT -i eth1 -p udp -m udp --dport 111 -j DROP
#


[0:0] -A INPUT -i eth1 -p udp -m udp --dport 587 -j DROP
[0:0] -A INPUT -i eth1 -p tcp -m tcp --dport 587 -j DROP
#

# 防止 Internet 用户访问 SQUID 的 3128 端口:
[0:0] -A INPUT -s 211.57.143.177 -i eth1 -p tcp -m tcp --dport 3128 -j DROP
[0:0] -A INPUT -s 192.168.0.0/255.255.0.0 -i eth0 -p tcp -m tcp --dport 3128 -j ACCEPT

[0:0] -A INPUT -s 211.57.143.177/255.255.255.240 -i eth1 -p tcp -m tcp --dport 3128 -j ACCEPT
[0:0] -A INPUT -p tcp -m tcp --dport 3128 -j DROP
#

# 让人家 ping 不通我 !
[0:0] -A INPUT -i eth1 -s 192.168.0.0/16 -p icmp -m icmp --icmp-type 8 -j ACCEPT
[0:0] -A INPUT -i eth1 -s 211.57.143.177/28 -p icmp -m icmp --icmp-type 8 -j ACCEPT
[0:0] -A INPUT -i eth1 -p icmp -m icmp --icmp-type 8 -j DROP
#

COMMIT
# ======================= 结束 =======================# ======================= 结束 =======================

 

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template