禁止其他主机对该特定主机进行访问和远程连接控制,所以只开放特定端口

只控制INPUT链就可达到控制其他主机对该主机的访问。

1.首先关闭INPUT

  iptables -P INPUT DROP

  使用命令iptables -L 来查看iptables的状态及设置

  这样设置好后,对应iptables只是临时的,重启后还是会回复到原先最初的状态

  需要使用service iptables save进行保存

  保存之后的信息就会存储在/etc/sysconfig/iptables中。

2.开放INPUT链中特定端口。

  开放http80dns53https443端口

  iptables规则对特定端口都是成对存在的,有出就有进,有去就有回

  命令如下:


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

iptables -A INPUT -p tcp --sport 80 -j ACCEPT

iptables -A INPUT -p udp -–dport 53 -j ACCEPT
443 -j ACCEPT

 

  配置完之后使用iptables -L来查看iptables状态

  同样,这些对iptables的修改只是临时的,若想要永久修改运行命令:

  service iptables save

  重新启动iptables,可以查看修改已经写进/etc/sysconfig/iptables中了。


相关文章:

  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
  • 2021-05-16
  • 2021-06-06
猜你喜欢
  • 2021-06-28
  • 2021-07-04
  • 2022-12-23
  • 2021-06-29
  • 2022-12-23
相关资源
相似解决方案