Linux系统防火墙

Iptables

yum install iptables iptables-services
systemctl start iptables

iptables -A INPUT -s 86.106.181.76 -j DROP
 iptables -A INPUT -s 86.106.181.76 -j REJECT
iptables -A OUTPUT -s 86.106.181.76 -j DROP
iptables -A OUTPUT -s 86.106.181.76 -j REJECT

iptables -A INPUT -s 185.170.213.251 -j DROP
 iptables -A INPUT -s 185.170.213.251 -j REJECT
iptables -A OUTPUT -s 185.170.213.251 -j DROP
iptables -A OUTPUT -s 185.170.213.251 -j  REJECT


[root@host49 ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  确定  
 
 
 iptables -nL --line-numbe


iptables v1.4.21

Usage: iptables -[ACD] chain rule-specification [options]
       iptables -I chain [rulenum] rule-specification [options]
       iptables -R chain rulenum rule-specification [options]
       iptables -D chain rulenum [options]
       iptables -[LS] [chain [rulenum]] [options]
       iptables -[FZ] [chain] [options]
       iptables -[NX] chain
       iptables -E old-chain-name new-chain-name
       iptables -P chain target [options]
       iptables -h (print this help information)


 -[ACD ]    -A append  -C  check  -D delete
 -I  insert
 -L  list
 -S  --list-rules
 -F  flush
 
 Option 
 
 -s source
 -p protocol
 -d destination
 -i in-interface
 -j jump
 
 

firewalld

防火墙

网络场所分区

	public: 仅允许访问本机的sshd dhcp ping服务
	trusted: 允许任务访问
	block : 阻塞任务来的访问请求 (明确拒绝,会响应客户端)
	drop: 丢弃任何来访的数据包 (直接丢弃,不给客户端回应)

	节省服务器开销,drop优于block

防火墙5元组 : 源IP 源端口 目的IP 目的端口 动作(deny permit)

防火墙匹配原则:匹配即停止
	1 查看数据包中源IP, IP落在哪个区域,就进入哪个区域,没匹配,进入默认区域

	2 防火墙默认区域 (public) 
		~ ]# firewall-cmd --get-default-zone
		~ ]# firewall-cmd --set-default-zone=public
		

	
防火墙协议的添加
	~ ]# firewall-cmd --zone=public --list-all
	~ ]# firewall-cmd --zone=public --add-service=http
	~ ]# firewall-cmd --zone=public --add-service=ftp
	--permanent 永久 保存防火墙策略

	firewall-cmd --reload

	~ ]# firewall-cmd --zone=block --add-source=192.168.3.10

	~ ]# firewall-cmd --permanent  --zone=block --add-source=192.168.3.10
	firewall-cmd --reload

策略
	宽松: 默认区域为trusted,单独拒绝的策略写入block
	严格: 默认区域为block,单独拒绝的策略写入trusted


实现本机的端口映射
	IP:5423--> IP:80
	~ ]# firewall-cmd --permanent --zone=trusted --add-forward-port=port=5423:proto=tcp:toport=80

http 80
https 443
ftp 21
tftp 69
telnet 23 
dns 53
snmp 161
smtp 25
pop3 110







 
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yolo2016

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值