亚洲高清vr播放在线观看,欧美亚洲精品免费,欧美日韩天堂在线视频,午夜福利小视频

      學(xué)習(xí)啦 > 創(chuàng)業(yè)指南 > 職場 > 面試題 >

      關(guān)于centosiptables防火墻的基本命令有哪些

      時(shí)間: 書榮1192 分享

        網(wǎng)絡(luò)安全是指網(wǎng)絡(luò)系統(tǒng)的硬件、軟件及其系統(tǒng)中的數(shù)據(jù)受到保護(hù),不因偶然的或者惡意的原因而遭受到破壞、更改、泄露,系統(tǒng)連續(xù)可靠正常地運(yùn)行,網(wǎng)絡(luò)服務(wù)不中斷。下面是學(xué)習(xí)啦小編為你整理的網(wǎng)絡(luò)安全面試題,希望對你有所幫助!


        1、安裝iptables防火墻 如果沒有安裝iptables需要先安裝, CentOS執(zhí)行: yum install iptables Debian/Ubuntu執(zhí)行: apt-get install iptables 2、清除已有iptables規(guī)則 iptables -F iptables -X iptables -Z 3、開放指定的端口 #允許本地回環(huán)接口(即運(yùn)行本 1、安裝iptables防火墻

        如果沒有安裝iptables需要先安裝,CentOS執(zhí)行:

        yum install iptables

        Debian/Ubuntu執(zhí)行:

        apt-get install iptables 2、清除已有iptables規(guī)則 iptables -F

        iptables -X

        iptables -Z 3、開放指定的端口 #允許本地回環(huán)接口(即運(yùn)行本機(jī)訪問本機(jī))

        iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT

        # 允許已建立的或相關(guān)連的通行

        iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

        #允許所有本機(jī)向外的訪問

        iptables -A OUTPUT -j ACCEPT

        # 允許訪問22端口

        iptables -A INPUT -p tcp --dport 22 -j ACCEPT

        #允許訪問80端口

        iptables -A INPUT -p tcp --dport 80 -j ACCEPT

        #允許FTP服務(wù)的21和20端口

        iptables -A INPUT -p tcp --dport 21 -j ACCEPT

        iptables -A INPUT -p tcp --dport 20 -j ACCEPT

        #如果有其他端口的話,規(guī)則也類似,稍微修改上述語句就行

        #禁止其他未允許的規(guī)則訪問

        iptables -A INPUT -j REJECT

        iptables -A FORWARD -j REJECT 4、屏蔽IP #如果只是想屏蔽IP的話“3、開放指定的端口”可以直接跳過。

        #屏蔽單個(gè)IP的命令是

        iptables -I INPUT -s 123.45.6.7 -j DROP

        #封整個(gè)段即從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規(guī)則 iptables -L -n

        v:顯示詳細(xì)信息,包括每條規(guī)則的匹配包數(shù)量和匹配字節(jié)數(shù)

        x:在 v 的基礎(chǔ)上,禁止自動(dòng)單位換算(K、M) vps偵探

        n:只顯示IP地址和端口號,不將ip解析為域名

        5、刪除已添加的iptables規(guī)則

        將所有iptables以序號標(biāo)記顯示,執(zhí)行:

        iptables -L -n --line-numbers

        比如要?jiǎng)h除INPUT里序號為8的規(guī)則,執(zhí)行:

        iptables -D INPUT 8 6、iptables的開機(jī)啟動(dòng)及規(guī)則保存

        CentOS上可能會(huì)存在安裝好iptables后,iptables并不開機(jī)自啟動(dòng),可以執(zhí)行一下:

        chkconfig --level 345 iptables on

        將其加入開機(jī)啟動(dòng)。

        CentOS上可以執(zhí)行:service iptables save保存規(guī)則。

        另外更需要注意的是Debian/Ubuntu上iptables是不會(huì)保存規(guī)則的。

        需要按如下步驟進(jìn)行,讓網(wǎng)卡關(guān)閉是保存iptables規(guī)則,啟動(dòng)時(shí)加載iptables規(guī)則:

        創(chuàng)建/etc/network/if-post-down.d/iptables 文件,添加如下內(nèi)容:

        #!/bin/bash

        iptables-save > /etc/iptables.rules

        執(zhí)行:chmod +x /etc/network/if-post-down.d/iptables 添加執(zhí)行權(quán)限。

        創(chuàng)建/etc/network/if-pre-up.d/iptables 文件,添加如下內(nèi)容:

        #!/bin/bash

        iptables-restore < /etc/iptables.rules

        執(zhí)行:chmod +x /etc/network/if-pre-up.d/iptables 添加執(zhí)行權(quán)限。

        關(guān)于更多的iptables的使用方法可以執(zhí)行:iptables --help或網(wǎng)上搜索一下iptables參數(shù)的說明。


      面試題相關(guān)文章:

      1.求職面試題目及答案大全

      2.經(jīng)典面試題

      3.競聘上崗面試題及答案

      4.抗壓能力面試題及參考答案

      5.經(jīng)典情景面試題及參考答案

      4064171