溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Linux服務(wù)器中ftp如何限制ip

發(fā)布時間:2021-11-09 16:04:36 來源:億速云 閱讀:693 作者:柒染 欄目:建站服務(wù)器

今天就跟大家聊聊有關(guān)Linux服務(wù)器中ftp如何限制ip,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

限制IP

1、通過vsftpd的配置文件以及“hosts.deny”和“hosts.allow”文件設(shè)置允許某個ip地址訪問

1)修改配置文件“/etc/vsftpd/vsftpd.conf”中的參數(shù)“tcp_wrapper”,確保這個參數(shù)是yes

[root@localhost wj]# gedit /etc/vsftpd/vsftpd.conf        //匿名登錄

tcp_wrapper=YES

2)打開配置文件“/etc/hosts.deny“,在末尾追加一句話”vsftpd:all:Deny

[root@localhost wj]# gedit /etc/hosts.deny 

# hosts.deny  This file contains access rules which are used to

#      deny connections to network services that either use

#      the tcp_wrappers library or that have been

#      started through a tcp_wrappers-enabled xinetd.

#

#      The rules in this file can also be set up in

#      /etc/hosts.allow with a 'deny' option instead.

#

#      See 'man 5 hosts_options' and 'man 5 hosts_access'

#      for information on rule syntax.

#      See 'man tcpd' for information on tcp_wrappers

#

vsftpd:all:Deny       //所有的ip都不可以訪問

3)打開配置文件“/etc/hosts.allow“,在末尾追加一句話”vsftpd:192.168.0.123:Allow“。當(dāng)前的配置就是只允許“192.168.0.123”訪問

[root@localhost wj]# gedit /etc/hosts.allow

 # hosts.allow This file contains access rules which are used to

#      allow or deny connections to network services that

#      either use the tcp_wrappers library or that have been

#      started through a tcp_wrappers-enabled xinetd.

#

#      See 'man 5 hosts_options' and 'man 5 hosts_access'

#      for information on rule syntax.

#      See 'man tcpd' for information on tcp_wrappers

#

vsftpd:192.168.0.123:Allow

4)測試是否可以訪問,當(dāng)前主機(jī)的ip并不是“192.168.0.123”,因此訪問不會成功的

[root@localhost wj]# service vsftpd restart        //重啟服務(wù)

關(guān)閉vsftpd                                             [確定]

 vsftpd 啟動vsftpd                                    [確定]

 

[root@localhost wj]# lftp weijie:123456@192.168.0.113:8765     //本地用戶登錄

lftp weijie@192.168.0.113:~> ls

中斷                                                                     //ls失敗,并沒有連接成功

lftp weijie@192.168.0.113:~> bye

 

[root@localhost wj]# lftp 192.168.0.113:8765                     //匿名登錄

lftp 192.168.0.113:~> ls

中斷                                                                     //ls失敗,并沒有連接成功

lftp 192.168.0.113:~> 

2、當(dāng)一個ip地址對主機(jī)的連接太多時,就會降低服務(wù)器的效率。因此有必要設(shè)置一個IP的連接數(shù),當(dāng)連接超過一定的數(shù)量就不能再連了,這樣就可以提高服務(wù)器的效率。Vsftpd默認(rèn)沒有連接設(shè)置,可以通過參數(shù)“max_clients“來設(shè)置。由于同一個局域網(wǎng)的ip是一樣的,因此這個最大連接數(shù)要合理設(shè)置。

1)打開配置文件“/etc/vsftpd/vsftpd.conf“,在末尾追加一句話”max_clients=2“

[root@localhost pub]# gedit /etc/vsftpd/vsftpd.conf 

 max_clients=2

2)重啟服務(wù),測試。一次打開三個連接,發(fā)現(xiàn)第三個連接不能訪問

[root@localhost wj]# service vsftpd restart        //重啟服務(wù)

關(guān)閉vsftpd                                             [確定]

 vsftpd 啟動vsftpd                                    [確定]

 

[root@localhost wj]# lftp weijie:123456@192.168.0.113:8765        //登錄weijie

lftp weijie@192.168.0.113:~> ls

-rwxrwxrwx    1 0        0        2375494044 Aug 14 07:13 1.zip

lftp weijie@192.168.0.113:~> 

 

[root@localhost wj]# lftp 192.168.0.113:8765                       //匿名登錄

lftp 192.168.0.113:~> ls

drwxr-xr-x    2 0        0            4096 Aug 14 06:38 pub

lftp 192.168.0.113:/> 

 

[root@localhost pub]# lftp 192.168.0.113                          //匿名登錄

lftp 192.168.0.113:~> ls

[0] ls &                                 

    `ls' at 0 [重新連接前延時: 22]                                  //不能再訪問,ls失效

lftp 192.168.0.113:~> 

做了一個Linux學(xué)習(xí)的平臺,目前出來一個雛形,各位可以參考使用
鏈接:https://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ  密碼:n7bk

Linux服務(wù)器中ftp如何限制ip

看完上述內(nèi)容,你們對Linux服務(wù)器中ftp如何限制ip有進(jìn)一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注億速云行業(yè)資訊頻道,感謝大家的支持。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI