|
|
iptables配置问题 大家一起来啊
eth0 内网DMZ网卡 10.0.0.1
eth1 内网网卡 192.168.0.6
eth2
想实现目标
实现透明代理
内网可以访问外网
内网电脑不可访问代理服务器 防止内部有人恶意攻击
开放DMZ的web和ftp服务等外网可访问到!
DMZ电脑不可访问外网、不可以访问内网和代理服务器! DmZ的电脑是很容易被攻下的 ^_^
代理服务器不可上访问外网 防止有人取得一般用户权限后,通过网上下载exploit提权
允许远程ssh
管理员电脑可以随意访问所有
#!/bin/sh
echo "Enable IP Forwarding..."
echo 1 >/proc/sys/net/ipv4/ip_forward
echo "Starting iptables rules..."
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_nat
/sbin/modprobe ip_nat_ftp
#========================defresh all chains ==========================
/sbin/iptables -F -t nat
/sbin/iptables -F INPUT
/sbin/iptables -F OUTPUT
/sbin/iptables -F FORWARD
/sbin/iptables -Z
#======================= forbid forward alll packet==================
#禁止所有包通过 等下要通过的再放过
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
#对本地放行
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
#透明代理 内网可以访问外网 forward包全放行
#========================= nat =============================
iptables -t nat -A PREROUTING -i eth1 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o ppp0 -j MASQUERADE
iptables -A FORWARD -s 192.168.0.0/24 -i eth1 -j ACCEPT
#发布DMZ http服务器
#==================Publish internat web service =========================
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 80 -j DNAT --to-destination 10.0.0.2:80
iptables -t nat -A POSTROUTING -d 192.168.0.3 -p tcp --dport 80 -j SNAT --to 192.168.0.6
iptables -A FORWARD -p tcp -d 10.0.0.2 --dport 80 -j ACCEPT
#发布DMZ ftp服务器
#================FTP serivce============================
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 21 -j DNAT --to-destination 10.0.0.2:21
iptables -A FORWARD -p tcp -d 10.0.0.2 --dport 21 -j ACCEPT
iptables -t nat -I POSTROUTING -s 10.0.0.2 -p tcp --dport 21 -j SNAT --to 10.0.0.1
iptables -t nat -A PREROUTING -p tcp --dport 3000:3020 -i ppp0 -j to 192.168.0.3:3000-3020 #这句可不要
#DNS转发
#=====================================DNS========================
iptables -t nat -A PREROUTING -i eth1 -p udp --dport 53 -j DNAT --to-destination 202.96.128.86
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 53 -j DNAT --to-destination 202.96.128.86
#===================SSH==========================================
iptables -A INPUT -p tcp -i ppp0 --dport 22 -j ACCEPT
#对管理员的电脑的特权
#=============my computer======================
iptables -I INPUT -s 192.168.0.3 -j ACCEPT
iptables -I FORWARD -s 192.168.0.3 -j ACCEPT
iptables -I OUTPUT -s 192.168.0.3 -j ACCEPT
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere
LISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT all -- 192.168.0.3 anywhere
Chain FORWARD (policy DROP)
target prot opt source destination
ACCEPT all -- 192.168.0.0/24 anywhere
ACCEPT tcp -- anywhere 10.0.0.2 tcp dpt:http
ACCEPT tcp -- anywhere 10.0.0.2 tcp dpt:ftp
ACCEPT all -- 192.168.0.3 anywhere
Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- 192.168.0.3 anywhere
1.管理员电脑和代理服务器不能连接
其它就没试了
2.还有为什么INPUT和OUTPUT链都会有
ACCEPT all -- anywhere anywhere
3.发布ftp服务器那里
192.168.0.3:3000-3020 不能3000-3020这样写?那要怎么写?3000:3020也不行 |
|