Linux防火墙iptables设置
来源:才华咖 本文已影响3.03W人
来源:才华咖 本文已影响3.03W人
防火墙是保护服务器的重要措施。它可以对访问权限等做出细粒度的约束。废话少说,下面我们就来看看如何对防火墙进行设置。
相关命令
只允许特定ip访问80端口:
iptables -I INPUT -p TCP –dport 80 -j DROP
注意dport前面是两个-
iptables -I INPUT -s specificIp -p TCP –dport 80 -j ACCEPT
第一条命令是禁止所有访问80端口的请求。第二条就是对特定IP开放80端口。
这个是很有用的。比如,我们可以只让负载均衡服务器来访问应用服务器的80端口。
查看设置是否生效:
iptables -L
只允许特定ip访问多ip服务器上的80端口:
我们可以给一个服务器配置多个ip地址。在第一个命令中,我们是禁止了此台服务器上的全部ip的.80端口。那么我们如何只禁止服务器上的一个ip的80端口呢?
下面这条命令只允许来自的ip访问服务器上的80端口:
iptables -A FORWARD -s -d -p tcp -m tcp –dport 80 -j ACCEPT
iptables -A FORWARD -d -p tcp -m tcp –dport 80 -j DROP
允许指定IP段来访问80端口:
iptables -I INPUT -p tcp –dport 80 -j DROP
iptables -I INPUT -s -p tcp –dport 80 -j ACCEPT
上面的例子中,就是只允许这个ip段的ip访问80端口。
只允许访问特定网址:
iptables -A Filter -d -j ACCEPT
iptables -A Filter -j DROP
多个端口:
iptables -A Filter -p tcp -m multiport –destination-port 22,53,80,110 -s -j REJECT
指定时间上网:
iptables -A Filter -m time –timestart 17:30 –timestop 8:30 –days Mon,Tue,Wed,Thu,Fri,Sat,Sun -j ACCEPT
禁止某个MAC地址访问internet:
iptables -I Filter -m mac –mac-source 00:11:22:33:44:55 -j DROP
禁止某个MAC地址的某个端口服务
iptables -I Filter -p tcp -m mac –mac-source 00:20:18:8F:72:F8 –dport 80 -j DROP
禁止某个ip地址的Ping:
iptables –A Filter –p icmp –s –j DROP
英语报纸解读:Data may disrupt a peculiar business
托福英语写作范文:Examinations exert a pernicious influence on educat
英语《Module 6 Unit 1 You can play football well》的教案设计
英语阅读:Life is inevitable consequence of physics
Scientists Build Robots to Live With Humans英语美文
7B Unit5 Abilities第四课时Vcabular教学案
初中英语《Unit 1 Will people have robots》教学设计
最新《Fate/Stay Night Unlimited Blade Works》经典名句
英语阅读:Are You Tricked by These Optical Illusions
评教研课Unit One Will people have robots?范文
英语作文 Complaint about the Noise Pollution
Telling Lies Is Painful英语作文
英语报纸解读:Data may disrupt a peculiar business大纲
linux下防火墙设置
高中预测英语作文:Unpredictability rules
《PEP Book 5 Unit 4 A Let’s learn》说课稿范文
entOS 6.7 Linux系统的IP配置方法
防火墙购销的合同
Unit 1 London is the capital of England说课稿
英文短文:Spill Some Oil? Magnetize It for Cleanup
初二上册英语NaturalAbilities家庭作业
linux的防火墙设置方法
人教版八年级上册英语Unit7Willpeoplehaverobots随堂检测题
Unit 4 Janet Feels Ill优秀教学设计
长篇英语阅读文AbundanceisaLifeStyle
英语阅读:Dollar Hit by Trump Tax Plan Doubts
疫情防控|“六个注重”筑牢战“疫”防火墙
Unit 5 It must belong to Caral section A英语评课稿
Should Internet Slang Be Prohibited英语作文
人教PEP版小学五年级英语下册Unit3Myschoolcalender.ALet’stalk
Linux防火墙iptables设置
Unit 5 Abilities 学案设计
高二英语Unit 3TheMillionPoundBankNote教案
java的String=a; a==null和a.equals(null)这两个判断有什么区别
英语口语:Teaching and Learning Responsibility
Unit six Opening and Closing Ceremonies口译材料
基于ubuntu下nginx+php+mysql安装配置
电脑防火墙关闭有危害吗
三年级上册Unit2 Colours Part B Let’s talk教学反思
BeingaLittlePrincess高中英语作文