CentOS 리눅스 서버단에서 특정 IP SSH 접속 제한 설정 가능

 

[설정 방법]

1. 허용 IP 설정 : /etc/hosts.allow 파일내에 접속 허용할 IP 설정

 

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

ALL:127.0.0.1:allow

ALL:xxx.xxx.xxx.xxx:allow

 

2. 차단 IP 설정 : /etc/hosts.deny 파일을 하기와 같이 설정하면 hosts.allow 내에 설정되어 있는 IP를 제외한 나머지 ALL 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
#

ALL:ALL

 

:ip 명령어를 이용해서 ip 주소 정보 조회나 ip 설정 등을 할 수 있음

: ifconfig 명령어와 사용법이 비슷

 

[예시]

:ip [option] [대상] [command] 

 

ip addr show # ip 정보 출력

ip addr add 192.168.5.10/24 dev eth0 # eth0 인터페이스에 ip 설정

ip addr del 192.168.5.10/24 dev eth0 # eth0 인터페이스의 ip 삭제

ip link set eth0 up # eth0 인터페이스 활성화

ip link set eth0 down # eth0 인터페이스 비활성화

ip route show # 라우팅 정보 출력

ip route add default via 192.168.5.1 # 게이트웨이 설정

ip route del default via 192.168.5.1 # 게이트웨이 삭제

ip route add 10.20.12.0/24 via 192.168.5.1 dev eth0 # 정적 라우팅 정보 설정

ip route del 10.20.12.0/24 # 정적 라우팅 정보 삭제

서버 Bonding 구성 설정

 

[설정]

1. # cd /etc/sysconfig/network-scripts/

2. # cat /ifcfg-bond0
DEVICE=bond0
USERCTL=no
ONBOOT=yes
BOOTPROTO=static
BONDING_OPTS="miimon=100 mode=1"

3. # cat ifcfg-em1
TYPE=Ethernet
#PROXY_METHOD=none
#BROWSER_ONLY=no
BOOTPROTO=static
#DEFROUTE=yes
#IPV4_FAILURE_FATAL=no
#IPV6INIT=yes
#IPV6_AUTOCONF=yes
#IPV6_DEFROUTE=yes
#IPV6_FAILURE_FATAL=no
#IPV6_ADDR_GEN_MODE=stable-privacy
NAME=em1
UUID=6354f3b7-b5c1-4595-93e5-a58bf6b5efef
DEVICE=em1
ONBOOT=yes
SLAVE=yes
MASTER=bond0
USERCTL=no

4. # cat ifcfg-em3
TYPE=Ethernet
#PROXY_METHOD=none
#BROWSER_ONLY=no
BOOTPROTO=static
#DEFROUTE=yes
#IPV4_FAILURE_FATAL=no
#IPV6INIT=yes
#IPV6_AUTOCONF=yes
#IPV6_DEFROUTE=yes
#IPV6_FAILURE_FATAL=no
#IPV6_ADDR_GEN_MODE=stable-privacy
NAME=em3
UUID=be7a0cce-61e2-4403-bc3a-d58bd3dd5105
DEVICE=em3
ONBOOT=yes
USERCTL=no
SLAVE=yes
MASTER=bond0

5. systemctl restart network

 

 

 

+ Recent posts