常用iptables命令

1
2
3
4
5
6
7
8
9
10
11
12
1、不让某个ip访问本机的80端口:
iptables -t filter -I INPUT -p tcp -s 192.168.222.163 --dport 80 -j DROP
 
2、实现把访问 10.0.0.8:80 的请求转到 172.16.1.17:80
iptables -t NAT -A PREROUTING -d 10.0.0.8:80 -p tcp -j DNAT --destination 172.16.1.17:80
 
3、实现 172.16.1.0/24 段所有主机通过 10.0.0.8 外网 IP 共享上网
iptables -t NAT -A PREROUTING -s 172.16.1.0/24 -o eth0 -j SNAT --to-source 10.0.0.8
 
4、写一个防火墙配置脚本,只允许远程主机访问本机的 80 端口
iptables -A INPUT -p tcp --dport 80 -j ACCEPT #允许80端口访问
iptables -P INPUT DROP #默认拒绝所有服务、端口访问

  

 

  

posted @   BigZero  阅读(290)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示