当前位置:   article > 正文

Linux iptable_iptables 配置完需要重启

iptables 配置完需要重启

命令

iptable 修改配置文件 要先重启 再保存, 不然一保存再重启,配置文件又恢复了

vi /etc/sysconfig/iptables
service iptables restart
service iptables save

  • 1
  • 2
  • 3
  • 4

iptables [-t 表名] 命令选项 [链名] [条件匹配] [-j 目标动作或跳转]

iptables -A INPUT -p tcp --dport 22 -j ACCEPT

设置只允许指定ip地址访问指定端口

iptables -A INPUT -s xxx.xxx.xxx.xxx -p tcp --dport 22 -j ACCEPT 
iptables -A OUTPUT -d xxx.xxx.xxx.xxx -p tcp --sport 22 -j ACCEPT 
iptables -A INPUT -s xxx.xxx.xxx.xxx -p tcp --dport 3306 -j ACCEPT 
iptables -A OUTPUT -d xxx.xxx.xxx.xxx -p tcp --sport 3306 -j ACCEPT 

  • 1
  • 2
  • 3
  • 4
  • 5

上面这两条,请注意–dport为目标端口,当数据从外部进入服务器为目标端口;反之,数据从服务器出去则为数据源端口,使用 --sport
同理,-s是指定源地址,-d是指定目标地址。

然后,关闭所有的端口 。

iptables -P INPUT DROP 
iptables -P OUTPUT DROP 
iptables -P FORWARD DROP 
  • 1
  • 2
  • 3

最后,保存当前规则

/etc/rc.d/init.d/iptables save 
service iptables restart 
  • 1
  • 2

linux vi面板如何复制一行

把光标移动到要复制的行上
按yy
把光标移动到要复制的位置
按p
  • 1
  • 2
  • 3
  • 4
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/631824
推荐阅读
相关标签
  

闽ICP备14008679号