需求:
只允许10.10.10.250的ip访问服务器9100端口
//对整个服务器(全部ip)禁止9100端口
[root@jiankunking]# iptables -I INPUT -p tcp --dport 9100 -j DROP
//只允许10.10.10.250访问9100端口
[root@jiankunking]# iptables -I INPUT -s 10.10.10.250 -p tcp --dport 9100 -j ACCEPT
//将规则保存到iptables 中
[root@jiankunking]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
//重启iptables
[root@jiankunking]# service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
//查看iptables 内容
[root@jiankunking]# cat iptables
Generated by iptables-save v1.4.7 on Thu Jan 18 10:46:02 2018
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]<