<em id="0a85b"><option id="0a85b"></option></em>

<abbr id="0a85b"></abbr>

      <nobr id="0a85b"></nobr>
        <tr id="0a85b"></tr>
        9久久伊人精品综合,亚洲一区精品视频在线,成 人免费va视频,国产一区二区三区黄网,99国产精品永久免费视频,亚洲毛片多多影院,精品久久久无码人妻中文字幕,无码国产欧美一区二区三区不卡
        學習啦>學習電腦>操作系統>Linux教程>

        LINUX防火墻常用操作

        時間: 春健736 分享

          學習啦小編來給大家介紹下LINUX防火墻常用操作,對于自己學習使用Linux更有幫助。下面跟著學習啦小編一起來了解一下吧。

          LINUX防火墻常用操作

          (1) 重啟后永久性生效:

          開啟:chkconfig iptables on

          關閉:chkconfig iptables off

          (2) 即時生效,重啟后失效:

          開啟:service iptables start

          關閉:service iptables stop

          (3)Linux 防火墻開放特定端口

          iptables是linux下的防火墻,同時也是服務名稱。

          service iptables status 查看防火墻狀態

          service iptables start 開啟防火墻

          service iptables stop 關閉防火墻

          service iptables restart 重啟防火墻

          防火墻開放特定端口:

          ①文件/etc/sysconfig/iptables

          ②添加:

          -A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT

          ★具體參照/etc/sysconfig/iptables中的配置,一般默認會有一個22端口開放★

          ★數字3306代表開放3306端口,也可以改成其他的端口.★

          ③重啟防火墻

          service iptables restart

          保存對防火墻的設置

          serivce iptables save

          =====================================

          查看iptables規則及編號

          iptables -nL –line-number

          查看iptables規則及編號

          iptables -nL –line-number

          關閉所有的INPUT FORWARD(轉發) OUTPUT的所有端口

          iptables -P INPUT DROP

          iptables -P FORWARD DROP

          iptables -P OUTPUT DROP

          只打開22端口

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

          iptables -A OUTPUT -p tcp –sport 22 -j ACCEPT

          參數講解:

          –A 參數就看成是添加一條規則

          –p 指定是什么協議,我們常用的tcp 協議,當然也有udp,例如53端口的DNS

          –dport 就是目標端口,當數據從外部進入服務器為目標端口

          –sport 數據從服務器出去,則為數據源端口使用

          –j 就是指定是 ACCEPT -接收 或者 DROP 不接收

          禁止某個IP訪問

          iptables -A INPUT -p tcp -s 192.168.1.2 -j DROP

          –s 參數是來源(即192.168.1.2)

          后面拒絕就是DROP

          刪除規則

          iptables -D INPUT 2

          刪除INPUT鏈編號為2的規則

          1、允許通過某一端口

          vi /etc/sysconfig/iptables

          -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT(允許80端口通過防火墻)

          /etc/init.d/iptables restart

          #最后重啟防火墻使配置生效

          只允許特定ip訪問某端口?參考下面命令,只允許46.166.150.22訪問本機的80端口。如果要設置其他ip或端口,改改即可。

          iptables -I INPUT -p TCP --dport 80 -j DROP

          iptables -I INPUT -s 46.166.150.22 -p TCP --dport 80 -j ACCEPT

          在root用戶下執行上面2行命令后,重啟iptables, service iptables restart

          查看iptables是否生效:

          [root@www.ctohome.com]# iptables -L

          Chain INPUT (policy ACCEPT)

          target prot opt source destination

          ACCEPT tcp -- 46.166.150.22 anywhere tcp dpt:http

          DROP tcp -- anywhere anywhere tcp dpt:http

          Chain FORWARD (policy ACCEPT)

          target prot opt source destination

          Chain OUTPUT (policy ACCEPT)

          target prot opt source destination

          上面命令是針對整個服務器(全部ip)禁止80端口,如果只是需要禁止服務器上某個ip地址的80端口,怎么辦?

          下面的命令是只允許來自174.140.3.190的ip訪問服務器上216.99.1.216的80端口

          iptables -A FORWARD -s 174.140.3.190 -d 216.99.1.216 -p tcp -m tcp --dport 80 -j ACCEPT

          iptables -A FORWARD -d 216.99.1.216 -p tcp -m tcp --dport 80 -j DROP

          如果您不熟悉linux的ssh命令,那么可以在webmin/virtualmin面板中設置,達到相同效果。參考:webmin面板怎樣設置允許特定ip訪問80端口,禁止80端口

          更多iptables參考命令如下:

          1.先備份iptables

          # cp /etc/sysconfig/iptables /var/tmp

          需要開80端口,指定IP和局域網

          下面三行的意思:

          先關閉所有的80端口

          開啟ip段192.168.1.0/24端的80口

          開啟ip段211.123.16.123/24端ip段的80口

          # iptables -I INPUT -p tcp --dport 80 -j DROP

          # iptables -I INPUT -s 192.168.1.0/24 -p tcp --dport 80 -j ACCEPT

          # iptables -I INPUT -s 211.123.16.123/24 -p tcp --dport 80 -j ACCEPT

          以上是臨時設置。

          2.然后保存iptables

          # service iptables save

          3.重啟防火墻

          #service iptables restart

          ===============以下是轉載================================================

          以下是端口,先全部封再開某些的IP

          iptables -I INPUT -p tcp --dport 9889 -j DROP

          iptables -I INPUT -s 192.168.1.0/24 -p tcp --dport 9889 -j ACCEPT

          如果用了NAT轉發記得配合以下才能生效

          iptables -I FORWARD -p tcp --dport 80 -j DROP

          iptables -I FORWARD -s 192.168.1.0/24 -p tcp --dport 80 -j ACCEPT

          常用的IPTABLES規則如下:

          只能收發郵件,別的都關閉

          iptables -I Filter -m mac --mac-source 00:0F:EA:25:51:37 -j DROP

          iptables -I Filter -m mac --mac-source 00:0F:EA:25:51:37 -p udp --dport 53 -j ACCEPT

          iptables -I Filter -m mac --mac-source 00:0F:EA:25:51:37 -p tcp --dport 25 -j ACCEPT

          iptables -I Filter -m mac --mac-source 00:0F:EA:25:51:37 -p tcp --dport 110 -j ACCEPT

          IPSEC NAT 策略

          iptables -I PFWanPriv -d 192.168.100.2 -j ACCEPT

          iptables -t nat -A PREROUTING -p tcp --dport 80 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.2:80

          iptables -t nat -A PREROUTING -p tcp --dport 1723 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.2:1723

          iptables -t nat -A PREROUTING -p udp --dport 1723 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.2:1723

          iptables -t nat -A PREROUTING -p udp --dport 500 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.2:500

          iptables -t nat -A PREROUTING -p udp --dport 4500 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.2:4500

          FTP服務器的NAT

          iptables -I PFWanPriv -p tcp --dport 21 -d 192.168.1.22 -j ACCEPT

          iptables -t nat -A PREROUTING -p tcp --dport 21 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.1.22:21

          只允許訪問指定網址

          iptables -A Filter -p udp --dport 53 -j ACCEPT

          iptables -A Filter -p tcp --dport 53 -j ACCEPT

          iptables -A Filter -d www.ctohome.com -j ACCEPT

          iptables -A Filter -d www.guowaivps.com -j ACCEPT

          iptables -A Filter -j DROP

          開放一個IP的一些端口,其它都封閉

          iptables -A Filter -p tcp --dport 80 -s 192.168.1.22 -d www.pconline.com.cn -j ACCEPT

          iptables -A Filter -p tcp --dport 25 -s 192.168.1.22 -j ACCEPT

          iptables -A Filter -p tcp --dport 109 -s 192.168.1.22 -j ACCEPT

          iptables -A Filter -p tcp --dport 110 -s 192.168.1.22 -j ACCEPT

          iptables -A Filter -p tcp --dport 53 -j ACCEPT

          iptables -A Filter -p udp --dport 53 -j ACCEPT

          iptables -A Filter -j DROP

          多個端口

          iptables -A Filter -p tcp -m multiport --destination-port 22,53,80,110 -s 192.168.20.3 -j REJECT

          連續端口

          iptables -A Filter -p tcp -m multiport --source-port 22,53,80,110 -s 192.168.20.3 -j REJECT iptables -A Filter -p tcp --source-port 2:80 -s 192.168.20.3 -j REJECT

          指定時間上網

          iptables -A Filter -s 10.10.10.253 -m time --timestart 6:00 --timestop 11:00 --days Mon,Tue,Wed,Thu,Fri,Sat,Sun -j DROP

          iptables -A Filter -m time --timestart 12:00 --timestop 13:00 --days Mon,Tue,Wed,Thu,Fri,Sat,Sun -j ACCEPT

          iptables -A Filter -m time --timestart 17:30 --timestop 8:30 --days Mon,Tue,Wed,Thu,Fri,Sat,Sun -j ACCEPT

          禁止多個端口服務

          iptables -A Filter -m multiport -p tcp --dport 21,23,80 -j ACCEPT

          將WAN 口NAT到PC

          iptables -t nat -A PREROUTING -i $INTERNET_IF -d $INTERNET_ADDR -j DNAT --to-destination 192.168.0.1

          將WAN口8000端口NAT到192。168。100。200的80端口

          iptables -t nat -A PREROUTING -p tcp --dport 8000 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.1.22:80

          MAIL服務器要轉的端口

          iptables -t nat -A PREROUTING -p tcp --dport 110 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.1.22:110

          iptables -t nat -A PREROUTING -p tcp --dport 25 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.1.22:25

          只允許PING 202。96。134。133,別的服務都禁止

          iptables -A Filter -p icmp -s 192.168.1.22 -d 202.96.134.133 -j ACCEPT

          iptables -A Filter -j DROP

          禁用BT配置

          iptables –A Filter –p tcp –dport 6000:20000 –j DROP

          禁用QQ防火墻配置

          iptables -A Filter -p udp --dport ! 53 -j DROP

          iptables -A Filter -d 218.17.209.0/24 -j DROP

          iptables -A Filter -d 218.18.95.0/24 -j DROP

          iptables -A Filter -d 219.133.40.177 -j DROP

          基于MAC,只能收發郵件,其它都拒絕

          iptables -I Filter -m mac --mac-source 00:0A:EB:97:79:A1 -j DROP

          iptables -I Filter -m mac --mac-source 00:0A:EB:97:79:A1 -p tcp --dport 25 -j ACCEPT

          iptables -I Filter -m mac --mac-source 00:0A:EB:97:79:A1 -p tcp --dport 110 -j ACCEPT

          禁用MSN配置

          iptables -A Filter -p udp --dport 9 -j DROP

          iptables -A Filter -p tcp --dport 1863 -j DROP

          iptables -A Filter -p tcp --dport 80 -d 207.68.178.238 -j DROP

          iptables -A Filter -p tcp --dport 80 -d 207.46.110.0/24 -j DROP

          只允許PING 202。96。134。133 其它公網IP都不許PING

          iptables -A Filter -p icmp -s 192.168.1.22 -d 202.96.134.133 -j ACCEPT

          iptables -A Filter -p icmp -j DROP

          禁止某個MAC地址訪問internet:

          iptables -I Filter -m mac --mac-source 00:20:18:8F:72:F8 -j DROP

          禁止某個IP地址的PING:

          iptables –A Filter –p icmp –s 192.168.0.1 –j DROP

          禁止某個IP地址服務:

          iptables –A Filter -p tcp -s 192.168.0.1 --dport 80 -j DROP

          iptables –A Filter -p udp -s 192.168.0.1 --dport 53 -j DROP

          只允許某些服務,其他都拒絕(2條規則)

          iptables -A Filter -p tcp -s 192.168.0.1 --dport 1000 -j ACCEPT

          iptables -A Filter -j DROP

          禁止某個IP地址的某個端口服務

          iptables -A Filter -p tcp -s 10.10.10.253 --dport 80 -j ACCEPT

          iptables -A Filter -p tcp -s 10.10.10.253 --dport 80 -j DROP

          禁止某個MAC地址的某個端口服務

          iptables -I Filter -p tcp -m mac --mac-source 00:20:18:8F:72:F8 --dport 80 -j DROP

          禁止某個MAC地址訪問internet:

          iptables -I Filter -m mac --mac-source 00:11:22:33:44:55 -j DROP

          禁止某個IP地址的PING:

          iptables –A Filter –p icmp –s 192.168.0.1 –j DROP

          啟動iptables

          service iptables start

          iptables –list //*查看iptables規則集*//

          下面是沒有定義規劃時iptables的樣子:

          Chain INPUT (policy ACCEPT)

          target prot opt source destination

          Chain FORWARD (policy ACCEPT)

          target prot opt source destination

          Chain OUTPUT (policy ACCEPT)

          target prot opt source destination

          如何開啟/關閉指定端口

          例如:

          開啟81端口:

          iptables -I INPUT -i eth0 -p tcp –dport 81 -j ACCEPT

          iptables -I OUTPUT -o eth0 -p tcp –sport 81 -j ACCEPT

          關閉81端口:

          iptables -I INPUT -i eth0 -p tcp –dport 81 -j DROP

          iptables -I OUTPUT -o eth0 -p tcp –sport 81 -j DROP

          然后保存

          /etc/rc.d/init.d/iptables save

          eth0為網卡名稱,可以輸入ifconfig來查看網卡信息,注意填寫正確的網卡名稱。

          可以使用lsof命令來查看某一端口是否開放.查看端口可以這樣來使用.

          我就以81端口為例:

          lsof -i:81

          如果有顯示說明已經開放了,如果沒有顯示說明沒有開放。

        LINUX防火墻常用操作

        學習啦小編來給大家介紹下LINUX防火墻常用操作,對于自己學習使用Linux更有幫助。下面跟著學習啦小編一起來了解一下吧。 LINUX防火墻常用操作 (1) 重啟后永久性生效: 開啟:chkconfig iptables on 關閉:chkconfig iptables off (2) 即
        推薦度:
        點擊下載文檔文檔為doc格式

        精選文章

        • Linux防火墻怎么開放特定端口
          Linux防火墻怎么開放特定端口

          學習啦小編來給大家介紹下Linux防火墻怎么開放特定端口,也就是只允許某個特定端口才可以通過,其余的不行。下面跟著學習啦小編一起來了解一下吧。

        • Linux怎么配置Web服務器
          Linux怎么配置Web服務器

          從1998年Linux開始在中國市場受到關注,時間已經過去5年,從最初蜂擁而至的桌面版本,到后來悄悄進入企業應用的Linux服務器,Linux逐漸得到人們的認可。

        • linux中怎么添加ftp用戶
          linux中怎么添加ftp用戶

          Linux下創建用戶是很easy的事情了,只不過不經常去做這些操作,時間久了就容易忘記。那么linux中怎么添加ftp用戶,下面跟著學習啦小編一起來了解一下吧

        • Linux如何給文件夾設置密碼
          Linux如何給文件夾設置密碼

          電腦里經常會存儲著重要文件,這些文件需要進行加密,有許多方法來實現。但是你知道在Linux里面怎么給文件夾加密碼?下面跟著學習啦小編一起來了解一

        646735 主站蜘蛛池模板: 久色伊人激情文学你懂的| 最新国产麻豆aⅴ精品无| 人妻少妇精品中文字幕| 国产在线午夜不卡精品影院| 狠狠色丁香婷婷综合| 亚洲av免费成人精品区| 中文国产不卡一区二区| 日韩中文字幕亚洲精品一| 中文无码日韩欧免费视频| jlzz大jlzz大全免费| 亚洲人成影院在线观看| 日韩精品视频一二三四区| 肉大捧一进一出免费视频| 亚洲欧美日韩另类| 风韵丰满熟妇啪啪区老熟熟女| 91麻豆精品国产91久| 国产精品午夜福利91| 人妻少妇偷人无码视频| 久久精品无码专区免费青青| 久久综合久中文字幕青草| 国产精品色一区二区三区| 国产剧情福利一区二区麻豆| 久久国产免费观看精品3| 国产精品无码a∨麻豆| 午夜精品久久久久久久久| 中国丰满熟妇av| 亚洲国产五月综合网| 成人国产一区二区三区精品| 无码专区 人妻系列 在线| 精品福利视频导航| 一区二区亚洲人妻精品| 久久无码av一区二区三区电影网| 亚洲一二三区精品美妇| 亚洲男人在线无码视频| 亚洲av日韩av永久无码电影| 17岁高清完整版在线观看| 高清自拍亚洲精品二区| 亚洲AV无码成人精品区一本二本 | 美女一级毛片无遮挡内谢| 日韩中文字幕人妻精品| 亚洲精品天堂无码中文字幕|