IPTABLES
1.关闭firewall:
安装iptables防火墙
yum -y install iptables-services
编辑防火墙配置
通过service iptables save保存。
重新启动防火墙
关闭selinux
netfilter的5个表
IPTABLES基本语法
iptables -nvL查看规则默认保存在/etc/sysconfig/iptables
清空规则 iptables -F
iptables -t nat -t指定表明
iptables -Z 清除数据量
指定端口 -p 目标源ip -s 目标端口 sport 地址IP -d 地址端口80 DROP直接丢掉 -A是APPEND的追加, -I是插入优先级高。
iptables -I 插入-p指定端口 --dport指定端口
使用 iptables -nvL --line-number查看便于删除规则
iptables -P output DROP
丢掉默认的规则
iptables小案例
icmp实例
可以ping通外网,不能ping通本机
nat表应用:
首先机器A两块网卡 eno16777736 ens38
机器B内网网卡ens38
让B机器可以连外网:
设置:echo "1" > /proc/sys/net/ipv4/ip_forward
其次在A机上执行规则
iptables -t nat -A POSTROUTING -s 192.168.100.1/24 -o eno16777736 -j MASQUERADE
在B机上设置网关192.168.100.1
在设置 /etc/ resolve.conf
添加DNS 119.29.29.29
即可访问网络地址。
selinux教程 http://os.51cto.com/art/201209/355490.htm
selinux pdf电子书 http://pan.baidu.com/s/1jGGdExK
iptables应用在一个网段 http://www.aminglinux.com/bbs/thread-177-1-1.html
sant,dnat,masquerade http://www.aminglinux.com/bbs/thread-7255-1-1.html
iptables限制syn速率 http://www.aminglinux.com/bbs/thread-985-1-1.html http://jamyy.us.to/blog/2006/03/206.html
转载于:https://blog.51cto.com/13749388/2128684