国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

【ubuntu】禁用IP和端口

這篇具有很好參考價(jià)值的文章主要介紹了【ubuntu】禁用IP和端口。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

引言

有時(shí)候服務(wù)器,為了安全需要,會(huì)限制某些ip和端口對(duì)服務(wù)器的訪問。那具體該如何配置呢?本文帶你解決。
ubuntu 禁用端口,計(jì)算機(jī)技術(shù),linux,ubuntu,ubuntu,tcp/ip,linux

禁用IP和端口

1、方法1:iptables

iptables v1.8.4

Usage: iptables -[ACD] chain rule-specification [options]
       iptables -I chain [rulenum] rule-specification [options]
       iptables -R chain rulenum rule-specification [options]
       iptables -D chain rulenum [options]
       iptables -[LS] [chain [rulenum]] [options]
       iptables -[FZ] [chain] [options]
       iptables -[NX] chain
       iptables -E old-chain-name new-chain-name
       iptables -P chain target [options]
       iptables -h (print this help information)

Commands:
Either long or short options are allowed.
  --append  -A chain            Append to chain
  --check   -C chain            Check for the existence of a rule
  --delete  -D chain            Delete matching rule from chain
  --delete  -D chain rulenum
                                Delete rule rulenum (1 = first) from chain
  --insert  -I chain [rulenum]
                                Insert in chain as rulenum (default 1=first)
  --replace -R chain rulenum
                                Replace rule rulenum (1 = first) in chain
  --list    -L [chain [rulenum]]
                                List the rules in a chain or all chains
  --list-rules -S [chain [rulenum]]
                                Print the rules in a chain or all chains
  --flush   -F [chain]          Delete all rules in  chain or all chains
  --zero    -Z [chain [rulenum]]
                                Zero counters in chain or all chains
  --new     -N chain            Create a new user-defined chain
  --delete-chain
            -X [chain]          Delete a user-defined chain
  --policy  -P chain target
                                Change policy on chain to target
  --rename-chain
            -E old-chain new-chain
                                Change chain name, (moving any references)
Options:
    --ipv4      -4              Nothing (line is ignored by ip6tables-restore)
    --ipv6      -6              Error (line is ignored by iptables-restore)
[!] --protocol  -p proto        protocol: by number or name, eg. `tcp'
[!] --source    -s address[/mask][...]
                                source specification
[!] --destination -d address[/mask][...]
                                destination specification
[!] --in-interface -i input name[+]
                                network interface name ([+] for wildcard)
 --jump -j target
                                target for rule (may load target extension)
  --goto      -g chain
                              jump to chain with no return
  --match       -m match
                                extended match (may load extension)
  --numeric     -n              numeric output of addresses and ports
[!] --out-interface -o output name[+]
                                network interface name ([+] for wildcard)
  --table       -t table        table to manipulate (default: `filter')
  --verbose     -v              verbose mode
  --wait        -w [seconds]    maximum wait to acquire xtables lock before give up
  --wait-interval -W [usecs]    wait time to try to acquire xtables lock
                                default is 1 second
  --line-numbers                print line numbers when listing
  --exact       -x              expand numbers (display exact values)
[!] --fragment  -f              match second or further fragments only
  --modprobe=<command>          try to insert modules using this command
  --set-counters PKTS BYTES     set the counter during insert/append
[!] --version   -V              print package version.

  • ??端口
iptables -A INPUT -p tcp --dport 80 -j DROP
iptables -A INPUT -p tcp --dport 5053 -j DROP
  • ??IP
iptables -I INPUT -s 10.115.10.129 -j DROP
  • 保存配置
    sudo service iptables save
    實(shí)測(cè)這條命令行不通,報(bào)錯(cuò):iptables: unrecognized service
    下面這條可以
sudo iptables-save

2、方法2:ufw

UFW (Uncomplicated Firewall)是Ubuntu 自帶的防火墻配置工具 。UFW 是一個(gè)用來管理 iptables 防火墻規(guī)則的用戶友好的前端工具。它的主要目的就是為了使得管理 iptables 更簡(jiǎn)單。

Usage: ufw COMMAND

Commands:
 enable                          enables the firewall
 disable                         disables the firewall
 default ARG                     set default policy
 logging LEVEL                   set logging to LEVEL
 allow ARGS                      add allow rule
 deny ARGS                       add deny rule
 reject ARGS                     add reject rule
 limit ARGS                      add limit rule
 delete RULE|NUM                 delete RULE
 insert NUM RULE                 insert RULE at NUM
 route RULE                      add route RULE
 route delete RULE|NUM           delete route RULE
 route insert NUM RULE           insert route RULE at NUM
 reload                          reload firewall
 reset                           reset firewall
 status                          show firewall status
 status numbered                 show firewall status as numbered list of RULES
 status verbose                  show verbose firewall status
 show ARG                        show firewall report
 version                         display version information

Application profile commands:
 app list                        list application profiles
 app info PROFILE                show information on PROFILE
 app update PROFILE              update PROFILE
 app default ARG                 set default application policy

Ubuntu安裝完畢,默認(rèn)沒有啟動(dòng)ufw。所以如果直接運(yùn)行上述語句,那么它啟動(dòng)后就會(huì)使用默認(rèn)規(guī)則,禁止一切流量,包括SSH的22端口,如果本來就是在SSH上遠(yuǎn)程操作,那么悲劇了,所以要先啟用SSH的端口(默認(rèn)是22,如果你設(shè)置了其他端口就加上去)

sudo ufw allow 22
sudo ufw reject 80 #(拒絕,直接返回:Connection refused)
sudo ufw deny 5053 #(否認(rèn),過段時(shí)間后返回:Connection timed out)
sudo ufw enable
sudo ufw status
  • 查看ufw防火墻是否在工作,查看使用中的規(guī)則
ufw status
  • 啟動(dòng)/關(guān)閉/重置ufw防火墻
ufw enable
ufw disable
ufw reset
  • 允許其它主機(jī)訪問本機(jī)21端口,協(xié)議包含tcp和udp
ufw allow 21

-允許其它主機(jī)使用tcp協(xié)議訪問本機(jī)80端口

ufw allow 80/tcp
  • 可以使用in或out來指定向內(nèi)還是向外。如果未指定,默認(rèn)是in
    允許訪問本機(jī)http端口
ufw allow in http
  • 禁止其它主機(jī)訪問本機(jī)80端口,
    • reject,直接告訴拒絕,返回的提示信息更多,比如ssh該主機(jī)時(shí),直接返回:Connection refused

    • deny,否認(rèn),返回的提示信息少,比如ssh該主機(jī)時(shí),過段時(shí)間后才返回:Connection timed out

ufw reject 80
ufw deny 80
  • 禁止本機(jī)對(duì)外訪問192.168.1.1
    (實(shí)測(cè)有用)
ufw deny out to 192.168.1.1
  • 禁止192.168.1.1對(duì)內(nèi)訪問本機(jī)
    (實(shí)測(cè)沒用)
ufw deny from 192.168.1.1
  • 刪除規(guī)則,只要在命令中加入delete就行了
ufw delete deny 80/tcp
  • 打開/關(guān)閉log
ufw logging on
ufw logging off

logging on后 默認(rèn)是low 等級(jí)。ufw支持多個(gè)等級(jí): ‘low’, ‘medium’, ‘high’ and ‘full’。簡(jiǎn)單說low記錄事件做少,其他等級(jí)記錄逐級(jí)增加。使用默認(rèn)的low level就夠了。log文件保存在/var/log/ufw.log 文件內(nèi),可以用tail -n COUNT file的形式顯示最后幾行

參考文檔

Linux下iptables屏蔽IP和端口號(hào)
Ubuntu 18.04 防火墻設(shè)置ufw詳解
如何在 Ubuntu 20.04 上使用 UFW 來設(shè)置防火墻
Ubuntu自帶防火墻ufw配置和用法文章來源地址http://www.zghlxwxcb.cn/news/detail-595688.html

到了這里,關(guān)于【ubuntu】禁用IP和端口的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • cmd命令查看當(dāng)前計(jì)算機(jī)端口占用情況

    cmd命令查看當(dāng)前計(jì)算機(jī)端口占用情況

    ? ? 1.打開cmd命令提示符,輸入netstat -ano,可以看到當(dāng)前本機(jī)的所有端口情況 2.輸入netstat -aon|findstr,加端口號(hào),記住進(jìn)程pid 3.tasklist|findstr,加剛才記住的pid,可以查到該端口是哪個(gè)應(yīng)用占用的 (1)地址一欄相關(guān)說明: 0.0.0.0 是對(duì)外開放,通過服務(wù)域名、ip可以訪問的端口 1

    2024年02月06日
    瀏覽(18)
  • Linux【安全 01】云服務(wù)器主機(jī)安全加固(修改SSHD端口、禁用登陸失敗的IP地址、使用密鑰登錄)

    Linux【安全 01】云服務(wù)器主機(jī)安全加固(修改SSHD端口、禁用登陸失敗的IP地址、使用密鑰登錄)

    修改SSHD的默認(rèn)端口,它可以抵御一些簡(jiǎn)單的密碼暴力破解腳本。 查看登錄失敗的IP地址 通過下面的命令將這些登陸失敗的IP加入服務(wù)器訪問限制名單【失敗次數(shù)最多的10個(gè)IP】 使用SSH密鑰,并禁用密碼登錄,以MobaXterm為例進(jìn)行說明。 以下命令在本機(jī)上執(zhí)行(Windows) 使用Mob

    2024年02月05日
    瀏覽(20)
  • 計(jì)算機(jī)圖形與圖像技術(shù)

    計(jì)算機(jī)圖形與圖像技術(shù)

    可以使用Python、Java等語言。 下圖中,圖中各事物比例失調(diào) 如何使用代碼去掉某個(gè)人(不允許使用摳圖工具)? ????????像素(Pixel)是“圖像元素”的縮寫, 指的是圖像的最小單位 。 它是構(gòu)成數(shù)碼圖像或屏幕顯示圖像的基本單元,代表了圖像中的一個(gè)小點(diǎn)或一個(gè)小方塊

    2024年02月07日
    瀏覽(29)
  • 【計(jì)算機(jī)視覺】基于OpenCV計(jì)算機(jī)視覺的攝像頭測(cè)距技術(shù)設(shè)計(jì)與實(shí)現(xiàn)

    【計(jì)算機(jī)視覺】基于OpenCV計(jì)算機(jī)視覺的攝像頭測(cè)距技術(shù)設(shè)計(jì)與實(shí)現(xiàn)

    在當(dāng)今技術(shù)日益進(jìn)步的時(shí)代,計(jì)算機(jī)視覺已成為我們生活中不可或缺的一部分。從智能監(jiān)控到虛擬現(xiàn)實(shí),計(jì)算機(jī)視覺技術(shù)的應(yīng)用范圍日益廣泛。在這篇博客中,我們將探索一個(gè)特別實(shí)用的計(jì)算機(jī)視覺案例:使用OpenCV實(shí)現(xiàn)攝像頭測(cè)距。這一技術(shù)不僅對(duì)專業(yè)人士有用,也為編程愛

    2024年02月04日
    瀏覽(26)
  • 計(jì)算機(jī)視覺:填充(padding)技術(shù)

    計(jì)算機(jī)視覺:填充(padding)技術(shù)

    在前面的課程中,我們學(xué)習(xí)了使用3*3的過濾器去卷積一個(gè)5*5的圖像,那么最終會(huì)得到一個(gè)3*3的輸出。那是因?yàn)?3×3 過濾器在 5×5 矩陣中,只可能有 3×3 種可能的位置。 這背后的數(shù)學(xué)解釋是,如果我們有一個(gè)n × n的圖像,用f×f的過濾器做卷積,那么輸出的維度就是 (n?f+1)×(

    2024年02月07日
    瀏覽(18)
  • 計(jì)算機(jī)通信地址【圖解TCP/IP(筆記六)】

    計(jì)算機(jī)通信地址【圖解TCP/IP(筆記六)】

    通信傳輸中,發(fā)送端和接收端可以被視為通信主體。它們都能由一個(gè)所謂“地址”的信息加以標(biāo)識(shí)出來。當(dāng)人們使用電話時(shí),電話號(hào)碼就相當(dāng)于“地址”。當(dāng)人們選擇寫信時(shí),通信地址加上姓名就相當(dāng)于“地址”。 現(xiàn)實(shí)生活當(dāng)中的“地址”比較容易理解,然而在計(jì)算機(jī)通信當(dāng)

    2024年02月13日
    瀏覽(16)
  • 保護(hù)隱私:5 種隱藏計(jì)算機(jī) IP 地址的方法

    IP 地址是您在互聯(lián)網(wǎng)上的名片。每當(dāng)您訪問網(wǎng)站或使用在線服務(wù)時(shí),目的地服務(wù)器都會(huì)看到它。問題出在哪里?那么,你的 IP 地址足以確定你的位置,甚至你的身份,它可以用來發(fā)動(dòng)網(wǎng)絡(luò)攻擊你的網(wǎng)絡(luò)。然而,有辦法留下一個(gè)較小的在線線索直接導(dǎo)致你的家庭網(wǎng)絡(luò)和身份。在

    2024年02月06日
    瀏覽(10)
  • 計(jì)算機(jī)安裝Ubuntu系統(tǒng)(非虛擬機(jī))步驟簡(jiǎn)述

    計(jì)算機(jī)安裝Ubuntu系統(tǒng)(非虛擬機(jī))步驟簡(jiǎn)述

    ? ? ? ?由于我的筆記本電腦比較古老(近10年),已經(jīng)過了質(zhì)保期,甚至續(xù)保時(shí)間都過了,所以本著能用則用的想法就在上面改安裝Ubuntu系統(tǒng)。下面簡(jiǎn)單介紹下安裝過程,自己留筆記,如果有碰到同樣問題的能參考更好。 注意:如果是基于虛擬機(jī)安裝學(xué)習(xí)請(qǐng)查找其它資料,

    2024年02月13日
    瀏覽(18)
  • 《計(jì)算機(jī)視覺技術(shù)與應(yīng)用》重點(diǎn)復(fù)盤

    《計(jì)算機(jī)視覺技術(shù)與應(yīng)用》重點(diǎn)復(fù)盤

    《計(jì)算機(jī)視覺技術(shù)與應(yīng)用》-----第二章 圖像處理基礎(chǔ) 《計(jì)算機(jī)視覺技術(shù)與應(yīng)用》-----第三章 圖形用戶界面 《計(jì)算機(jī)視覺技術(shù)與應(yīng)用》-----第四章 圖像變換 《計(jì)算機(jī)視覺技術(shù)與應(yīng)用》-----第五章 邊緣和輪廓 《計(jì)算機(jī)視覺技術(shù)與應(yīng)用》-----第六章 邊緣和輪廓 《計(jì)算機(jī)視覺技術(shù)

    2023年04月08日
    瀏覽(23)
  • 計(jì)算機(jī)視覺(CV)技術(shù)的優(yōu)勢(shì)

    計(jì)算機(jī)視覺(CV)技術(shù)的優(yōu)勢(shì): 1. 自動(dòng)化任務(wù):計(jì)算機(jī)視覺技術(shù)可以自動(dòng)執(zhí)行一系列視覺任務(wù),如圖像分類、目標(biāo)檢測(cè)和識(shí)別等,從而實(shí)現(xiàn)任務(wù)的自動(dòng)化。 2. 高速處理:計(jì)算機(jī)視覺技術(shù)可以在短時(shí)間內(nèi)處理大量的圖像和視頻數(shù)據(jù),實(shí)現(xiàn)快速的分析和決策。 3. 準(zhǔn)確性:相對(duì)于

    2024年01月22日
    瀏覽(23)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包