iptables/firewall防火墻詳解

(实验环境:CentOS7.3)

iptables	
firewalld

netfilter / iptables   --iptables 的全名		2.4版本内核后都集成有这个组件



# yum install iptables\*  


# rpm -qa |grep iptables
iptables-services-1.4.21-17.el7.x86_64
iptables-utils-1.4.21-17.el7.x86_64
iptables-devel-1.4.21-17.el7.x86_64
iptables-1.4.21-17.el7.x86_64


# systemctl start iptables.service
# systemctl status iptables.service




iptables  基本概念


四张表:    表里有链  (chain )

filter:  用来进行包过滤:  INPUT  OUTPUT FORWARD  
nat:   用来网络地址转换:   network  address translation ,允许一个内网地址块,通过NAT转换成公网IP,实现对公网的访问,解决IP地址不足
	PREROUTING  INPUT   POSTROUTING	OUTPUT

mangle :用来对数据包标记	
	 PREROUTING INPUT OUTPUT  FORWARD  POSTROUTING

raw:对原始数据包的处理
	PREROUTING	OUTPUT
 


iptables  
例1,列规则

	iptables -L 	--默认看的就是filter表
	iptables -L -t  filter

	iptables -L -t  nat
	iptables -L -t  mangle
	iptables -L -t  raw


# iptables -t filter -F
# iptables -t nat -F
# iptables -t mangle -F		--这三张表有些默认的规则,我们把规则都清掉



例2,控制ping

172.16.25.0/24网段ping本机,会被拒绝(客户端会收到拒绝信息)
# iptables -t filter -A INPUT -p icmp -s 172.16.25.0/24 -j REJECT
# iptables -t filter -D INPUT -p icmp -s 172.16.25.0/24 -j REJECT	--删除上一条规则

# iptables -t filter -A INPUT -p icmp -s 172.16.25.0/24 -j DROP
# iptables -t filter -D INPUT -p icmp -s 172.16.25.0/24 -j DROP

# iptables -t filter -A OUTPUT -p icmp -d 172.16.25.0/24 -j REJECT
# iptables -t filter -D OUTPUT -p icmp -d 172.16.25.0/24 -j REJECT

# iptables -t filter -A OUTPUT -p icmp -d 172.16.25.0/24 -j DROP
# iptables -t filt
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值