由 cfs2 在 11-05-2002 15:04 发表:
请大家看看,我这样的应用环境该怎样配置透明网关防火墙,谢谢!
我的环境是这样的:一台linux服务器,他的一块网卡eth1接外置的adsl modem,提供上网服务;
另一块网卡eth0接内网.
服务器上运行ftp,http mail这3个服务.
服务器用的是iptables,
请问,我该怎样配置他可以做到一下2点:
第一:可以保护服务器,最大限度的防止各种攻击;
第二:可以为内网用户提供透明代理上网服务(因用户少,不需要缓存功能),而且,起网可以支持netmeeting的视频会议功能.
请大家多多帮助,本人才疏学浅,请大家尽量给出详细的方案
万分感激!
由 北南南北 在 12-03-2002 19:45 发表:
用squid来实现,这个看来不太难。
我找一点资料。。。。。不知有没有用。我没有试过呢。。。。。
如何在Linux中设置透明代理
蓝森林 http://www.lslnet.com 2001年1月9日 22:00
1.什么是透明代理?
如果你问:我如何才能使得用户的浏览器不需要任何代理设置就能使用我的Squid cache代理服务器上网?,此时你就需要使用透明代理。透明代理让你的客户端不需设置任何代理,当包经过透时代理服务器时实际上被重定向到squid代理服务器的代理端口(如8080),即由本地代理服务器向外请求所需数据然后拷贝给客户端。
2.我需要什么样的环境才能实现透明代理?
a.客户端的windows PC的网关必须设成Squid代理服务器,因为既然你的browser中没有任何代理设置,你要访问某个站点时,包必须经经过squid代理服务器才能被重定向,故这是最基本的条件。
b.客户端必须正确设置DNS服务器。因为既然现在不用设置任何代理。则DNS必须由browser来解析,也就是要由客户端的PC中TCP/IP中设置的DNS服务器来正确解析出某个站点的IP地址来
c.服务器端可以安装squid代理服务器,1.x or 2.x版本均可。
3.配置Squid代理,启动透明代理功能
Squid-2
加下面的行到你的/etc/squid/squid.conf中
http_port 8080
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
Squid-1.1
加下面的行到/etc/squid.conf
http_port 8080
httpd_accel virtual 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
4. 重启动squid. 用下面的命令:
#/usr/sbin/squid -k reconfigure
如提示内核不支持透明代理。则你需要重新编译内核,enable 透明代理的支持。
下面是你需要启动的内核项目:
[*] Network firewalls
[ ] Socket Filtering
[*] Unix domain sockets
[*] TCP/IP networking
[ ] IP: multicasting
[ ] IP: advanced router
[ ] IP: kernel level autoconfiguration
[*] IP: firewalling
[ ] IP: firewall packet netlink device
[*] IP: always defragment (required for masquerading)
[*] IP: transparent proxy support
5. 下面的命令针对Linux 2.2.x内核:
Accept all on lookback
/sbin/ipchains -A input -j ACCEPT -i lo
#Accept my own IP, to prevent loops (repeat for each interface/alias)
/sbin/ipchains -A input -j ACCEPT -p tcp -d 192.168.11.1/32 80
#Send all traffic destined to port 80 to Squid on port 80
/sbin/ipchains -A input -j REDIRECT 8080 -p tcp -s 192.168.11.0/24 -d 0/0 80
下面的命令针对Linux 2.0.x内核:
Accept all on loopback
ipfwadm -I -a accept -W lo
Accept my own IP, to prevent loops (repeat for each interface/alias)
ipfwadm -I -a accept -P tcp -D 192.168.11.1/32 80
Send all traffic destined to port 80 to Squid on port 3128
ipfwadm -I -a accept -P tcp -S 192.168.11.0/24 -D 0/0 80 -r 8080
6.应注意的问题:
a. 这种透明代理只能针对http协议,不能针对FTP协议
b. PC的默认网关应设成squid 代理服务器
c. 防火墙重定向规则在其它的input规则的前面,注意顺序。
如:
/etc/rc.d/rc.firewall:
#!/bin/sh
rc.firewall Linux kernel firewalling rules
FW=/sbin/ipfwadm
Flush rules, for testing purposes
for i in I O F # A # If we enabled accounting too
do
${FW} -$i -f
done
Default policies:
${FW} -I -p rej # Incoming policy: reject (quick error)
${FW} -O -p acc # Output policy: accept
${FW} -F -p den # Forwarding policy: deny
Input Rules:
Loopback-interface (local access, eg, to local nameserver):
${FW} -I -a acc -S localhost/32 -D localhost/32
Local Ethernet-interface:
Redirect to Squid proxy server:
${FW} -I -a acc -P tcp -D default/0 80 -r 8080
Accept packets from local network:
${FW} -I -a acc -P all -S localnet/8 -D default/0 -W eth0
Only required for other types of traffic (FTP, Telnet):
Forward localnet with masquerading (udp and tcp, no icmp!):
${FW} -F -a m -P tcp -S localnet/8 -D default/0
${FW} -F -a m -P udp -S localnet/8 -D default/0
Here all traffic from the local LAN with any destination gets redirected to the
local port 8080. Rules can be viewed like this:
IP firewall input rules, default policy: reject
type prot source destination ports
acc all 127.0.0.1 127.0.0.1 n/a
acc/r tcp 10.0.0.0/8 0.0.0.0/0 * -> 80 => 8080
acc all 10.0.0.0/8 0.0.0.0/0 n/a
acc tcp 0.0.0.0/0 0.0.0.0/0 * -> *
[ 关闭窗口
===========================
请弟兄们发帖时要写个好标题,多谢!
===========================
每天以1000KM/H的速度在跑,感觉还是时间不够:(
“西学东渐,洋为中用” + 创造 = ?
linux ppc
由 Snoopy 在 03-16-2003 10:05 发表:
我的显示老是skiping,,,我看了一下我那内核,你上面的
该选的我有选,不该选都没选,,,,,怎么办??
And then in the ev