Centos 系統禁ping設定

來源:互聯網
上載者:User

Centos 系統禁ping設定

說明:

* 在網路中允許外來的ping響應,有時會給伺服器帶來安全風險;

* Linux預設允許ping響應;

* 系統是否允許ping由2個因素決定(核心參數和防火牆),只有2個因素同時滿足才能允許ping。

一、修改核心參數

  1. 臨時生效:臨時禁ping,伺服器重啟後失效

    #echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all//預設值是0

  2. 永久生效:修改檔案/etc/sysctl.conf

    #vi /etc/sysctl.conf

     net.ipv4.icmp_echo_ignore_all=1//在最後添加此行

    #sysctl -p //使新配置立即生效

  如上設定後,本伺服器還可以ping其它伺服器

二、設定防火牆(核心參數預設情況下)

  利用iptables丟棄掉來自外網請求的ICMP包,達到禁Ping的效果

1.禁ping設定

 #iptables -A INPUT -p icmp --icmp-type 8 -s 0/0 -j DROP

2.解除禁ping

 #iptables -D INPUT -p icmp --icmp-type 8 -s 0/0 -j DROP

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.