• <output id="aynwq"><form id="aynwq"><code id="aynwq"></code></form></output>

    <mark id="aynwq"><option id="aynwq"></option></mark>
  • <mark id="aynwq"><option id="aynwq"></option></mark><label id="aynwq"><dl id="aynwq"></dl></label>
  • 學習啦 > 學習電腦 > 電腦安全 > 防火墻知識 > Linux防火墻規(guī)則的查看、添加、刪除和修改

    Linux防火墻規(guī)則的查看、添加、刪除和修改

    時間: 林澤1002 分享

    Linux防火墻規(guī)則的查看、添加、刪除和修改

      這里只列出比較常用的參數(shù),詳細的請查看man iptables。下面是學習啦小編跟大家分享的是Linux防火墻規(guī)則的查看、添加、刪除和修改,歡迎大家來閱讀學習。

      Linux防火墻規(guī)則的查看、添加、刪除和修改

      1、查看

      iptables -nvL –line-number

      -L查看當前表的所有規(guī)則,默認查看的是filter表,如果要查看NAT表,可以加上-t NAT參數(shù)。

      -n不對ip地址進行反查,加上這個參數(shù)顯示速度會快很多。

      -v輸出詳細信息,包含通過該規(guī)則的數(shù)據(jù)包數(shù)量,總字節(jié)數(shù)及相應的網(wǎng)絡接口。

      –line-number顯示規(guī)則的序列號,這個參數(shù)在刪除或修改規(guī)則時會用到。

      2、添加

      添加規(guī)則有兩個參數(shù):-A和-I。其中-A是添加到規(guī)則的末尾;-I可以插入到指定位置,沒有指定位置的話默認插入到規(guī)則的首部。

      當前規(guī)則:

      [root@test ~]# iptables -nL --line-number

      Chain INPUT (policy ACCEPT)

      num target prot opt source destination

      1 DROP all -- 192.168.1.1 0.0.0.0/0

      2 DROP all -- 192.168.1.2 0.0.0.0/0

      3 DROP all -- 192.168.1.4 0.0.0.0/0

      添加一條規(guī)則到尾部:

      [root@test ~]# iptables -A INPUT -s 192.168.1.5 -j DROP

      再插入一條規(guī)則到第三行,將行數(shù)直接寫到規(guī)則鏈的后面:

      [root@test ~]# iptables -I INPUT 3 -s 192.168.1.3 -j DROP

      查看:

      [root@test ~]# iptables -nL --line-number

      Chain INPUT (policy ACCEPT)

      num target prot opt source destination

      1 DROP all -- 192.168.1.1 0.0.0.0/0

      2 DROP all -- 192.168.1.2 0.0.0.0/0

      3 DROP all -- 192.168.1.3 0.0.0.0/0

      4 DROP all -- 192.168.1.4 0.0.0.0/0

      5 DROP all -- 192.168.1.5 0.0.0.0/0

      可以看到192.168.1.3插入到第三行,而原來的第三行192.168.1.4變成了第四行。

      3、刪除

      刪除用-D參數(shù)

      刪除之前添加的規(guī)則iptables -A INPUT -s 192.168.1.5 -j DROP:

      [root@test ~]# iptables -D INPUT -s 192.168.1.5 -j DROP

      有時候要刪除的規(guī)則太長,刪除時要寫一大串,既浪費時間又容易寫錯,這時我們可以先使用--line-number找出該條規(guī)則的行號,再通過行號刪除規(guī)則。

      [root@test ~]# iptables -nv --line-number

      iptables v1.4.7: no command specified

      Try `iptables -h' or 'iptables --help' for more information.

      [root@test ~]# iptables -nL --line-number

      Chain INPUT (policy ACCEPT)

      num target prot opt source destination

      1 DROP all -- 192.168.1.1 0.0.0.0/0

      2 DROP all -- 192.168.1.2 0.0.0.0/0

      3 DROP all -- 192.168.1.3 0.0.0.0/0

      刪除第二行規(guī)則

      [root@test ~]# iptables -D INPUT 2

      4、修改

      修改使用-R參數(shù)

      先看下當前規(guī)則:

      [root@test ~]# iptables -nL --line-number

      Chain INPUT (policy ACCEPT)

      num target prot opt source destination

      1 DROP all -- 192.168.1.1 0.0.0.0/0

      2 DROP all -- 192.168.1.2 0.0.0.0/0

      3 DROP all -- 192.168.1.5 0.0.0.0/0

      將第三條規(guī)則改為ACCEPT:

      [root@test ~]# iptables -R INPUT 3 -j ACCEPT

      再查看下:

      [root@test ~]# iptables -nL --line-number

      Chain INPUT (policy ACCEPT)

      num target prot opt source destination

      1 DROP all -- 192.168.1.1 0.0.0.0/0

      2 DROP all -- 192.168.1.2 0.0.0.0/0

      3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0

      第三條規(guī)則的target已改為ACCEPT。

    2673843 主站蜘蛛池模板: 国产精品第一页第一页| 日韩欧美在线播放| 国产精品多人p群无码| 亚洲av永久青草无码精品| 国产成人精品1024在线| 日本50岁丰满熟妇xxxx| 午夜国产福利在线| 97麻豆精品国产自产在线观看| 欧美亚洲国产精品久久高清| 国产大片黄在线观看| 中国一级特黄毛片| 波多野结衣办公室在线| 国产精品亲子乱子伦xxxx裸| 久久人人爽人人爽人人片dvd| 精品无码久久久久久国产| 国模吧2021新入口| 久久精品国产9久久综合| 精品视频无码一区二区三区| 在线免费观看你懂的| 久草电影在线观看| 精品在线一区二区| 国产精品福利久久香蕉中文 | 国产一级一级一级成人毛片| 一个人看的www片免费| 欧美成人精品a∨在线观看| 国产乱视频在线观看| av无码免费一区二区三区| 最近2019中文字幕免费看最新| 国产一精品一av一免费爽爽| 99精品全国免费观看视频 | 在线中文字幕有码中文| 九九久久精品国产AV片国产 | 亚洲最大的黄色网| 我被黑人巨大开嫩苞在线观看| 亚洲精品国产成人| 青青草97国产精品免费观看| 天堂√在线官网| 久久精品国产99国产精品| 精品人妻久久久久久888| 国产激情无码视频在线播放性色| 中国一级特黄特色**毛片|