Centos 7 firewall :
1、firewalld的基本使用
启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld
开机禁用 : systemctl disable firewalld
开机启用 : systemctl enable firewalld
2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。
启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl –failed
3.配置firewalld-cmd
查看版本: firewall-cmd –version
查看帮助: firewall-cmd –help
显示状态: firewall-cmd –state
查看所有打开的端口: firewall-cmd –zone=public –list-ports
更新防火墙规则: firewall-cmd –reload
查看区域信息: 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 –zone=public –add-port=80/tcp –permanent (–permanent永久生效,没有此参数重启后失效)
重新载入
firewall-cmd –reload
查看
firewall-cmd –zone= public –query-port=80/tcp
删除
firewall-cmd –zone= public –remove-port=80/tcp –permanent
调整默认策略(默认拒绝所有访问,改成允许所有访问):
firewall-cmd –permanent –zone=public –set-target=ACCEPT
firewall-cmd –reload
对某个IP开放多个端口:
firewall-cmd –permanent –add-rich-rule=”rule family=”ipv4″ source address=”10.159.60.29″ port protocol=”tcp” port=”1:65535″ accept”
firewall-cmd –reload
Centos 6 iptables:
1、iptables的基本使用
启动: service iptables start
关闭: service iptables stop
查看状态: service iptables status
开机禁用 : chkconfig iptables off
开机启用 : chkconfig iptables on
2、开放指定的端口
-A和-I参数分别为添加到规则末尾和规则最前面。
允许本地回环接口(即运行本机访问本机)
iptables -A INPUT -i lo -j ACCEPT
允许已建立的或相关连的通行
iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
允许所有本机向外的访问iptables -P INPUT ACCEPT
iptables -A OUTPUT -j ACCEPT
允许访问22端口
iptables -A INPUT -p tcp –dport 22 -j ACCEPTiptables -A INPUT -p tcp -s 10.159.1.0/24 –dport 22 -j ACCEPT 注:-s后可以跟IP段或指定IP地址
允许访问80端口
iptables -A INPUT -p tcp –dport 80 -j ACCEPT
允许FTP服务的21和20端口
iptables -A INPUT -p tcp –dport 21 -j ACCEPT
iptables -A INPUT -p tcp –dport 20 -j ACCEPT
如果有其他端口的话,规则也类似,稍微修改上述语句就行
允许ping
iptables -A INPUT -p icmp -m icmp –icmp-type 8 -j ACCEPT
禁止其他未允许的规则访问
iptables -A INPUT -j REJECT #(注意:如果22端口未加入允许规则,SSH链接会直接断开。)
iptables -A FORWARD -j REJECT
3、屏蔽IP
如果只是想屏蔽IP的话 “3、开放指定的端口” 可以直接跳过。
屏蔽单个IP的命令是
iptables -I INPUT -s 123.45.6.7 -j DROP
封整个段即从123.0.0.1到123.255.255.254的命令
iptables -I INPUT -s 123.0.0.0/8 -j DROP
封IP段即从123.45.0.1到123.45.255.254的命令
iptables -I INPUT -s 124.45.0.0/16 -j DROP
封IP段即从123.45.6.1到123.45.6.254的命令是
iptables -I INPUT -s 123.45.6.0/24 -j DROP
4、查看已添加的iptables的规则
iptables -L -n
N:只显示IP地址和端口号,不将IP解析为域名
删除已添加的iptables的规则
将所有iptables以序号标记显示,执行:
iptables -L -n --line-numbers
比如要删除INPUT里序号为8的规则,执行:
iptables -D INPUT 8
5、也可以直接编辑配置文件,添加iptables防火墙规则:
iptables的配置文件为/ etc / sysconfig / iptables
编辑配置文件:
vi /etc/sysconfig/iptables
文件中的配置规则与通过的iptables命令配置,语法相似:
如,通过iptables的命令配置,允许访问80端口:
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
那么,在文件中配置,只需要去掉句首的iptables,添加如下内容:
-A INPUT -p tcp --dport 80 -j ACCEPT
保存退出。
有两种方式添加规则
iptables -A 和iptables -I
iptables -A 添加的规则是添加在最后面。如针对INPUT链增加一条规则,接收从eth0口进入且源地址为192.168.0.0/16网段发往本机的数据。
[root@localhost ~]# iptables -A INPUT -i eth0 -s 192.168.0.0/16 -j ACCEPT
iptables -I 添加的规则默认添加至第一条。
如果要指定插入规则的位置,则使用iptables -I 时指定位置序号即可。
删除规则
如果删除指定则,使用iptables -D命令,命令后可接序号。效果请对比上图。
或iptables -D 接详细定义;
如果想把所有规则都清除掉,可使用iptables -F。
备份iptabes rules
使用iptables-save命令,如:
[root@localhost ~]# iptables-save > /etc/sysconfig/iptables.save
恢复iptables rules
使用iptables命令,如:
[root@localhost ~]# iptables-restore < /etc/sysconfig/iptables.save
iptables 配置保存
以上做的配置修改,在设备重启后,配置将丢失。可使用service iptables save进行保存。
[root@localhost ~]# service iptables save
重启iptables的服务使其生效:
service iptables save 添加规则后保存重启生效。
service iptables restart
关于更多的iptables的使用方法可以执行:
iptables --help
文章来源:www.rakbuluo.com/p90
generic viagra over counter illinois department of public health irrigation #060 031501 que es mas seguro viagra o cialis <a href="https://himsprescription.com/#">viagra without a doctor prescription</a> - buy bulk cialis https://himsprescription.com/# - cialis generika in holland for how long hiv can go undetected
foods for arthritis using cialis levitra
<a href="https://withoutshort.com">viagra from canada</a> Aiqikar
https://withoutshort.com buy generic viagra online overnight
<a href=http://www.levitraye.com>viagra</a> http://www.canadianvolk.com
<a href=https://litnet.com/ru/dasha-romanova-u7772648/about>экологические изыскания</a>
<a href=https://telegra.ph/Kadastrovye-i-geodezicheskie-raboty-02-11-2>инженерные изыскания</a>
<a href=https://mama.ru/forums/theme/kadastrovye-uslugi-sankt-peterburg/#post-401868>технический план СПБ</a>
<a href=https://club.7ya.ru/ya417045/>геологические изыскания</a>
<a href=http://rur.biz/blog.php?cp=4489>ООО «ГеоСервис»</a>
geoszp3131
<a href="https://subscribe.ru/author/25866822">комплексные кадастровые работы</a>
<a href="https://mama.ru/forums/theme/kadastrovye-uslugi-sankt-peterburg/#post-401868">технический план СПБ</a>
<a href="https://www.liveinternet.ru/users/geoszz/profile">комплексные кадастровые работы</a>
<a href="http://barca.ru/forum/member.php?u=74351">межевание земельного участка СПБ</a>
<a href="https://ksonline.ru/author/geoszz/">комплексные кадастровые работы</a>
viagra generic europe how to apply for health insurance how much is viagra at rite aid <a href="https://viawithoutdctrs.com/#">viagra without doctor prescription</a> - sample viagra cialis levitra https://viawithoutdctrs.com/# - cialis marketing director what is the role of shark cartilage in the management of hiv and aids
what physician cialis 20 mg cosa serve
<a href="https://kamagrajellynow.com">kamagra fast</a> Uwqlo65
https://kamagrajellynow.com kamagra oral jelly
<a href=http://www.winviag.com>viagra without a doctor prescription</a> http://www.withoutbro.com
erectile dysfunction may be tied to decreased blood flow to the penis caused by <a href=https://www.withoutbro.com>viagra without doctor prescription</a> erectile dysfunction aat 80
buy sildenafil over the counter: https://www.withoutbro.com viagra no prescription
cialis rock song doctors office cialis au maroc <a href="https://tadalafilkiva.com/#">tadalafil</a> - viagra vs cialis cheaper https://tadalafilkiva.com/# - black actress in cialis commercial can you get aids from
india xxxxxxx videos http://onnetfact.com/__media__/js/netsoltrademark.php?d=trahito.net/mov/289993/very-sexy-big-tits-babe-alison-tyler
xxx video inglend http://fistingpornpics.com/cgi-bin/atc/out.cgi?id=28&u=https://trahito.net/mov/796691/oriental-playgirl-gets-down-on-all-fours-and-fucked-hard
sex torrent magnet http://strikeoffertas.com/__media__/js/netsoltrademark.php?d=trahito.net/mov/513294/jessica-has-an-awesome-sex-on-a-lawn-outdoor
xxxxx hd mp4 http://ravnsborg.org/gbook143/go.php?url=https://trahito.net/mov/800704/xxxmas-twerking-2016
sleping mom sex http://ritaandandrew.com/__media__/js/netsoltrademark.php?d=trahito.net/videos/xvedios5
sariwala xxx hd http://www.minieredisardegna.it/VaiURL.php?link=https://trahito.net/mov/467289/hairy-muff-of-torrid-bbw-cock-sucker-raylene-gets-boned-on-top
divya nair porn http://lazyengines.com/__media__/js/netsoltrademark.php?d=trahito.net/videos/fbb-vs-weak-man
brazzes blood video http://hovenjagtforening.dk/index.php/tools/packages/easy_news/rss?redirect_url=https://trahito.net/mov/501849/ash-hollywood-is-roped-and-pinned-by-master
sunni leoni sex http://jthilo.com/__media__/js/netsoltrademark.php?d=trahito.net/mov/912727/milf-hj-pov-xxx-hd
mom sex rape http://streamreveal.com/__media__/js/netsoltrademark.php?d=trahito.net/mov/426711/dutch-blonde-blowjob-abuse-deep-roughly
tamil chodi videos http://estheticsbyjill.com/__media__/js/netsoltrademark.php?d=trahito.net/mov/294660/sensual-session-porn
madison ivy xvideo http://clementecycles.com/__media__/js/netsoltrademark.php?d=trahito.net/mov/358333/brunette-rose-monroe-sucking-big-cock-by-the-pool
xxx parnding parn.com http://worksafetyprograms.com/__media__/js/netsoltrademark.php?d=trahito.net/mov/436432/mom-and-chums-daughter-fuck-guy-xxx-dominant-milf-gets-a-creampie
dog xxx 18 http://www.gyctxx.com/blog/go.asp?url=https://trahito.net/videos/bachelorette-party-bride-fucked-reluctant-forced
fuking pusy x http://medinhk.com/__media__/js/netsoltrademark.php?d=trahito.net/videos/darling-darla
xxxhd hot mobi http://salontreatment.com/__media__/js/netsoltrademark.php?d=trahito.net/mov/457124/bootylicious-body-and-tits-of-nikki-sexx-get-wet-and-shiny-in-the-shower-room
father and sonxxx.com https://www.google.com.sa/url?q=https://trahito.net/mov/453358/two-teen-chicks-lara-and-mia-practicing-gay-sex-and-fingering-pussies
ईगलिस सैकश विडिव http://saboresdovinho.com/__media__/js/netsoltrademark.php?d=trahito.net/mov/304729/sean-let-sally-squirts-pussy-ride-on-his-top
www six videos.com http://talawat.com/__media__/js/netsoltrademark.php?d=trahito.net/mov/502025/versatile-slut-brynn-tyler-enjoys-teasing-the-dick-of-horny-will-powers
xxx vidoes donwlod https://tracker.stylewish.me/ar/1?url=https://trahito.net/mov/483053/slutty-luscious-lopez-is-busy-with-sucking-a-black-dick-for-cum
<a href=http://www.doctorborat.com>buy cialis</a> http://www.viagwithoutdr.com
You explained that terrifically. <a href=https://www.kamagradr.com>kamagra</a> kamagra can women use
cheap kamagra gold: https://www.kamagradr.com kamagra oral jelly at walgreens
You actually expressed that superbly. <a href=https://www.goldkamagra.com>kamagra</a> taking kamagra holiday
kamagra oral jelly kaufen deutschland: https://www.goldkamagra.com kamagra online
what is tinder , tinder app
<a href=http://tinderdatingsiteus.com/?>tinder dating app </a>
Ignorance of the law is no excuse for breaking it.
physician doctors near me - <a href=https://www.withoutbro.com/>viagra</a> Yaptcpd
does fake cialis look like
does viagra help control premature ejaculation: <a href="https://www.withoutbro.com/">generic viagra</a>
tinder online , tinder website
<a href=http://tinderdatingsiteus.com/?>tinder date </a>
dating sites
what is tinder , how to use tinder
<a href=http://tinderdatingsiteus.com/?>tider </a>
<a href="http://canadiannextpharmacy.com/">mexican pharmacies shipping to usa</a>
http://canadiannextpharmacy.com/
<a href=http://canadiannextpharmacy.com/>online pharmacies legitimate</a>
tinder date , browse tinder for free
viagra <a href=" http://sild100fast.com/# ">generic viagra</a> viagra canada
<a href="http://canadianpharmacynethd.com/">canadian pharmacies mail order</a>
http://canadianpharmacynethd.com/
<a href=http://canadianpharmacynethd.com/>legitimate canadian mail order pharmacies</a>