我的linux学习日记day9

防火墙:

iptables 

firewall-cmd

firewall-config

tcp_wrapper

一、iptable
--line-number 列出规则的序号
-j 动作(ACCEPT DROP REJECT LOG)
-D num 删除某一条规则
查看iptables列表
清空iptables列表
全部拒绝

#iptables -p INPUT DROP

添加icmp,使主机能Ping通虚拟机

#iptables -I INPUT -p icmp -j ACCEPT

删除某一条规则

#iptables -d INPUT 1
#iptables --line-number -L INPUT

允许所有

#iptables -P INPUT ACCEPT

允许来自特定网段特定协议特定端口的

#iptables -I INPUT -s 192.168.10.0/24 -p tcp --dport=22 -j ACCEPT

  


二、firewalld
firewalld 服务名称
firewall-cmd 命令行配置工具
firewall-config 图形化配置工具
不要同时使用两个工具去配置
1、配置允许https:

[root@localhost ~]# firewall-cmd --get-default-zone 
public
[root@localhost ~]# firewall-cmd --get-zone-of-interface=eno16777728 
public
[root@localhost ~]# firewall-cmd --zone=public --query-service=ssh
yes
[root@localhost ~]# firewall-cmd --zone=public --query-service=http
no
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-service=https
success
[root@localhost ~]# firewall-cmd --zone=public --query-service=https
no
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --zone=public --query-service=https
yes

  


2、端口号转发,把888端口转发到22
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-forward-port=port=888:proto=tcp:toport=22:toaddr=192.168.10.10
success
[root@localhost ~]# firewall-cmd --reload


三、TCP Wrappers 访问控制列表
/etc/hosts.deny
/etc/hosts.allow

猜你喜欢

转载自www.cnblogs.com/miracle1989/p/12939865.html