1.iptables: 开启防火墙:可以正常使用ssh服务,dns服务, httpd服务,chrony服务, nfs服务
2.firewalld: 开启防火墙:可以正常使用ssh服务,dns服务, httpd服务,chrony服务, nfs服务
且实现:访问第一台机器web服务的9090端口,转发到第二台机器的80端口(永久生效)
实验1
安装iptables服务
关闭防火墙,开启iptables服务,添加规则:ssh服务端口22,dns服务53,httpd服务80,chrony服务123,nfs服务111
[ root @ jingchen ~]# systemctl stop firewalld . service
[ root @ jingchen ~]# systemctl start firewalld . service
[ root @ jingchen ~]# iptables - t filter - A INPUT - p tcp -- dport 22- j ACCEPT
[ root @ jingchen ~]# iptables - t filter - A INPUT - p udp -- dport 53- j ACCEPT
[ root @ jingchen ~]# iptables - t filter - A INPUT - p tcp -- dport 80- j ACCEPT
[ root @ jingchen ~]# iptables - t filter - A INPUT - p udp -- dport 123- j ACCEPT
[ root @ jingchen ~]# iptables - t filter - A INPUT - p udp -- dport 111- j ACCEPT
- 查看规则表
[ root @ jingchen ~]# iptables -vnL --line-numbers
实验2
1.关闭iptables,开启firewalld
[ root @ jingchen ~]# systemctl stop iptables
[ root @ jingchen ~]# systemctl start firewalld
2.允许协议访问:ssh,http,dns,chrony,nfs服务
[root@jingchen ~]#firewal1- Cmd -- add - service = Ssh
Warning : ALREADY _ENABLED :' ssh ' already in 'public'
success
Iroot@jingchen ~]# firewal - c - cmd -- add - service = http
success
[ root@jingchen ~]# firewalL -- cmd -- add - service = dns
success
Iroot@jingchen ~]# firewalL - Cmcmd -- add - port =123/udp
success
[ root@ingchen ~]#firewal1- cmd -- add - service = n fs
success
3.查看
4.转发端口,永久生效,需要重新加载并测试