Development

[Linux] 특정 ip만 접속 허용하기

곽진돔 2022. 3. 23. 11:04

hosts.allow / deny

특정한 클라이언트에게만 서비스를 허용(allow) 또는 차단(deny)할 수 있다.

특정 ip 허용하기 : allow

# vi /etc/hosts.allow

sshd: 허용할 ip

특정 ip 차단하기: deny

# vi /etc/hosts.deny

sshd: 차단할 ip

sshd: ALL

ALL로 차단하고, allow에서 특정 ip만 허용하면 모든 ip차단/허용된ip만 접속 되게 할 수 있다.

#
# 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: 111.111.111.111

sshd: '아이피주소'를 입력하면 된다. 전체 입력하지 않으면 해당 대역대가 적용되고, 한 개가 아니라 여러개도 쓸 수 있다. ,(콤마)로 구분하거나 여러 줄로 나누어 입력해도 된다. 

더보기

ex) 1.

sshd: 111.111.111.111, 222.222.222

sshd: 111.111.111.111

ex) 2.
sshd: 222.222.222.