飞嗨,欢迎您的光临,本博所发布之文章皆为作者亲测通过,如有错误,欢迎通过各种方式指正。(本博已于2015.12.6升级到php7,运行环境php7 php-fpm + nginx1.8.0)

centos 7 firewalld基本配置

Linux lf 15450℃ 0评论

centos7以后,内置的防火墙从iptables变成了firewalld。好吧,我对iptables也不熟,所以也就没有换回iptables(后来还是去学了些基础的命令)。

firewalld支持动态更新和zone概念。firewalld有图形界面和命令行界面,图形界面简单粗暴,挺好用,but server没有的咯。firewalld命令行管理工具是firewall-cmd,没事多firewalld-cmd –help就好了。
firewalld默认有8个zone,都配置好了,只要切换就可以了
drop 默认丢弃所有包
block 拒绝所有外部链接,允许内部发起的连接
public 指定外部连接可以进入
external
dmz 和硬件防火墙一样,受限制的公共连接可以进入
work 工作区,概念和workgroup一样,指定的外部链接允许
home 类似家庭组
internal 信任所有链接
centos7默认安装了firewalld,若没有安装,执行 yum install firewalld firewalld-config安装
systemctl start firewalld 启动
systemctl status firewalld或者firewall-cmd –state 查看状态
sytemctl disable firewalld 停止并禁用开机启动
systemctl enable firewalld 设置开机启动
systemctl stop firewalld 禁用
firewall-cmd –version 查看版本
firewall-cmd –help帮助信息
firewall-cmd –get-active-zones查看区域信息
firewall-cmd –get-zone-of-interface=eth0查看指定接口所属区域
firewall-cmd –panic-on 拒绝所有包
firewall-cmd –panic-off取消拒绝状态
firewall-cmd –query-panic查看是否拒绝
firewall-cmd –reload 更新防火墙规则
firewall-cmd –complete-reload 断开再连接
firewall-cmd –zone=public –add-interface=eth0 将接口添加到public区域 , 默认接口都在public。若加上–permanet则永久生效
firewall-cmd –set-default-zone=public 设置public为默认接口区域
firewall-cmd –zone=pulic –list-ports 查看所有打开的端口
firewall-cmd –zone=pulic –add-port=80/tcp 把tcp 80端口加入到区域
firewall-cmd –zone=public –add-service=http 把http服务加入到区域
firewall-cmd –zone=public –remove-service=http 移除http服务
设置一下防火墙,无论使用哪个zone,千万记得把ssh服务允许了。。。不然下次putty就连不上去咯
1.查看防火墙状态和启用防火墙并加入开机启动
systemctl status firewalld.service
systemctl enable firewalld.service
systemctl status firewalld.service

firewalld status

firewalld status


 
firewall-cmd –get-zones 列出所有zone
firewall-cmd –new-zone=prod –permanet 增加一个zone
firewall-cmd –complete-reload 重启防火墙
firewall-cmd –get-zones 可以看到刚增加的prod了
firewall-cmd –set-default-zone=prod 设置默认为prod
firewall-cmd –get-default-zone 查看默认的zone(当然也可以用firewall-cmd –zone=prod –add-interface=eth0把指定接口设置成prod)
防火墙zone设置

防火墙zone设置


firewall-cmd –zone=prod –add-service=http 允许http服务
这个时候blog.feehi.com能够正常访问了,但是samba svn服务防火墙还是拦截
firewalld

firewalld


firewalld

firewalld


firewall-cmd –zone=prod –add-service=samba
firewall-cmd –zone=prod –add-port=3690/tcp
svn可以使用了
firewall

firewall


一开始,我以为firewalld比iptables会更麻烦,其实firewalld比iptables方便多了。这只是firewalld基本的配置,还有更复杂的配置,有待学习.

转载请注明:飞嗨 » centos 7 firewalld基本配置

喜欢 (4)or分享 (0)
发表我的评论
取消评论
表情
(31)个小伙伴在吐槽
  1. Levitra 20 Mg Commenti http://cheapcialisir.com - Cheap Cialis Venta De Cialis En Madrid Cheap Cialis Order Now Cod Only Fluoxetine Fedex
    匿名2020-02-21 05:43 (3天前)回复
  2. Avis Sur Achat Cytotec En Ligne http://abuycialisb.com - Cialis Zithromax Typhoid Fever Cialis Does Amoxicillin Activate Tick
    匿名2020-02-19 03:21 (5天前)回复
  3. Ler para encontrar informações de marketing detalhadas que irão ajudá-lo a se conectar facilmente com seus clientes.
    匿名2020-02-17 00:32 (7天前)回复
  4. Cialis Kje Dobiti http://cheapcialisir.com - Cialis Levitra Preise Apotheke cialis 5mg Who Has The Cheapest Levitra
    匿名2020-02-16 18:36 回复
  5. Citalopram 20 Mg Pharmacy http://abuycialisb.com - cialis without a doctor's prescription Cialis Come Usarlo Buy Cialis Clomid Masculine
    匿名2020-02-10 21:56 回复
  6. Generic Isotretinoin Internet Website http://buycialisuss.com - order cialis online Brand Name Viagra By Pfizer Cialis Venta De Kamagra
    匿名2020-02-08 02:35 回复
  7. Levitra Kaufen 10mg http://buycialisuss.com - Cialis Buy Levitra?At A Discount Buy Cialis Cialis Generico A Basso Costo
    匿名2020-02-06 17:52 回复
  8. Levitra Scatola http://abcialisnews.com - Buy Cialis Dyazide Without Prescription order cialis online Cialis Gli Effetti
    匿名2020-02-05 06:15 回复
  9. Propecia En Espana Online http://cialisir.com - Cialis Online Harmacy Buy Cialis Propecia Dose It Really Work
    匿名2020-02-04 04:24 回复
  10. Cialis 20mg 8 St http://ggenericcialisle.com - Buy Cialis Cialis Versus Propecia Cialis Best Online Site To Buy Sex Drugs
    匿名2020-02-02 03:07 回复
  11. Le Viagra Est Il En Vente Libre En Pharmacie En France http://buyciaonlinex.com/#38 - Buy Cialis Priligy Directions Buy Cialis Propecia De 10 Mg
    匿名2020-01-31 13:26 回复
  12. Peut Acheter Viagra Sans Ordonnance http://cheapcialisir.com - Cialis Levaquin Anthrax Internet Cash Delivery Pharmacy Cialis 125 Tab Sandoz
    匿名2020-01-29 14:49 回复
  13. Alli Weight Loss In Stock http://ggenericcialisle.com - online pharmacy Cheap Brand Propecia Online Cialis Levitra Cialis A Basso Costo
    匿名2020-01-28 07:41 回复
  14. Para Que Sirve La Cialis http://buycialisuss.com - Buy Cialis Kamagra St Cialis Jelly Viagra Kamagra Tablets
    匿名2020-01-28 07:31 回复
  15. Viagra Adolescent http://abcialisnews.com - Buy Cialis Sale Discount Cash On Delivery Acticin Oregon Buy Cialis Can Cats Have Amoxicillin
    匿名2020-01-27 18:01 回复
  16. Kamagra Oral Jelly Kopen http://cialibuy.com - cialis Prix Cialis Medicament cialis cheapest online prices Comparatif Prix Viagra
    匿名2020-01-26 04:53 回复
  17. Que Proscar Vs Propecia http://cialibuy.com - Cialis Next Day Delivery Pharmacy Buy Cialis Comprar Priligy Generico Online
    匿名2020-01-25 05:15 回复
  18. Propecia Shedding Of Day http://cialibuy.com - Cialis Duphaston Cialis Propecia Nioxin Combined
    匿名2020-01-24 21:17 回复
  19. Aurochem Sildenafil Citrate 100mg http://cialibuy.com - Buy Cialis Estrace .5 generic cialis Amoxicillin Causes Leukopenia
    匿名2020-01-23 01:40 回复
  20. Zithromax Globalrph http://cialibuy.com - cialis Finasteride Non Funziona Propecia Cialis Cialis Vendita On Line In Italia
    匿名2020-01-22 21:14 回复
  21. Viagra Ausprobieren http://cialibuy.com - Buy Cialis Amoxicillin Dosage 875 Mg Cialis Baclofen Generique En France
    匿名2020-01-21 19:00 回复
  22. Nosipren Prednisona http://cialibuy.com - Buy Cialis Cialis For Sale Canadian cheapest cialis Priligy Generika Dapoxetine
    匿名2020-01-20 19:23 回复
  23. Levitra Prescription Online Pediatric Zithromax Dosage cialis 5mg best price Cialis Generique Pharmacie Prix Problemi Propecia
    匿名2020-01-20 07:55 回复
  24. Zithromax For Epiglottitis Viagra Frei Verkauflich Cephalexin Vaginal Bacteria Cialis Keflex Talwin And Clotrimazole
    匿名2020-01-19 20:04 回复
  25. Propecia Mastalgia Stendra Medicine Louisville cialis cheapest online prices Tadalafil 10mg Cheap Overnight Pharmacy 4u Zentel Best Website Discount Price Overseas Denver
    匿名2020-01-19 15:31 回复
  26. >firewall-cmd –zone-prod –add-service=http 允许http服务 写错了 >firewall-cmd --zone=prod --add-service=http 允许http服务
    匿名2017-01-11 22:10 回复
    • 感谢提醒,我去编辑页面看了,确实写的是--zone,但是却显示成-zone了,好在图片上的命令是完全正常的。
      lf2017-01-12 00:05 回复
      • 是 zone后面是= 不是-
        匿名2017-01-12 12:04 回复
        • 感谢指出错误,已经把zone-改成zone=了
          lf2017-01-12 12:07 回复
  27. 赞一个!
    匿名2015-12-17 02:20 回复
粤ICP备15018643号-1