[root@localhost ~]
# yum install iptables -y
[root@localhost ~]
# systemctl stop firewalld
[root@localhost ~]
# systemctl start iptables
[root@server ~]
# iptables -F #
清空所有的规则表,清空之后客户端可以访问
ssh
和
http
服务
(
2
)实验
实验一:搭建
web
服务,设置任何人能够通过
80
端口访问。
[root@localhost ~]
# iptables -I INPUT -p tcp --dport 80 -j ACCEPT
[root@localhost ~]
# iptables -L --line-numbers
[root@localhost ~]
# iptables -D INPUT 1
先重启
实验二:禁止所有人
ssh
远程登录该服务器
[root@localhost ~]
# iptables -I INPUT -p tcp --dport 22 -j REJECT
#
删除设置的拒绝
ssh
连接:
[root@localhost Desktop]
# iptables -D INPUT 1
实验三:禁止某个主机地址
ssh
远程登录该服务器,允许该主机访问服务器的
web
服务。服务器地址为
172.24.8.128
拒绝
172.24.8.129
通过
ssh
远程连接服务器:
[root@localhost ~]
# iptables -I INPUT -p tcp -s 172.24.8.129 --dport 22 -j
REJECT
允许
172.24.8.129
访问服务器的
web
服务:
[root@localhost ~]
# iptables -I INPUT -p tcp -s 172.24.8.129 --dport 80 -j
ACCEPT