防攻擊能夠增長IP白名單/etc/hosts.allow和黑名單/etc/hosts.denylinux
配置文件格式參考:服務器
修改/etc/hosts.allow文件
#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#
sshd:210.13.218.*:allow
sshd:222.77.15.*:allow
以上寫法表示容許210和222兩個ip段鏈接sshd服務(這必然須要hosts.deny這個文件配合使用),固然:allow徹底能夠省略的。www.111cn.net
固然若是管理員集中在一個IP那麼這樣寫是比較省事的
all:218.24.129.110//他表示接受110這個ip的全部請求!
/etc/hosts.deny文件,此文件是拒絕服務列表,文件內容以下:
#
# hosts.deny This file describes the names of the hosts which are
# *not* allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow. In particular
# you should know that NFS uses portmap!
sshd:all:deny
注意看:sshd:all:deny表示拒絕了全部sshd遠程鏈接。:deny能夠省略。
因此:當hosts.allow和 host.deny相沖突時,以hosts.allow設置爲準。
注意修改完後:www.111Cn.net
service xinetd restart
才能讓剛纔的更改生效。
/etc/hosts.allow(容許)和/etc/hosts.deny(禁止)這兩個文件是tcpd服務器的配置文件
tcpd服務器能夠控制外部IP對本機服務的訪問
linux 系統會先檢查/etc/hosts.deny規則,再檢查/etc/hosts.allow規則,若是有衝突 按/etc/hosts.allow規則處理ssh
好比:
1.禁止全部ip訪問linux 的ssh功能
能夠在/etc/hosts.deny添加一行 sshd:all:denytcp
2.禁止某一個ip(192.168.11.112)訪問ssh功能
能夠在/etc/hosts.deny添加一行sshd:192.168.11.112ide
3.若是在/etc/hosts.deny和/etc/hosts.allow同時 有sshd:192.168.11.112 規則,則192.168.11.112能夠訪問主機的ssh服務
總結:經過這種方法能夠控制部分非受權訪問,但不是一勞永逸的方法!咱們在看服務日誌的時候或許會看到不少掃描記錄,不是仍是直接針對root用戶的,這時控制你的訪問列表就很是有做用了!.net