본문 바로가기
프로그램

[ 리눅스 서버 보안 ] 불필요한 서비스 종료 - sendmail, postfix

by Dog_발자 2024. 7. 25.
반응형
써린이가 서버를 관리하면서 개인적으로 정리해 놓은 자료입니다.  써린이입니다. 
위험할 수 있으니  참고도 하지 말아 주십시요.

 

 

불필요한 서비스를 비활성화로 해주으로 필요 이상의 정보가 노출되는 것을 막고 불법적인 시스템 접근 및 파일변조등 시스템 주요 정보의 유출을 차단해 줄 수 있습니다.

 

불필요한 서비스 예 

  • SMTP - 인터넷을 통해 이메일을 보내고 받는 데 사용되는 통신서비스입니다.
  • DNS - Domain Name Service
  • SNMP - 장비에 문제가 생기지 않아도 먼저 관리자에게 특이점을 보고할 수 있는 프로토콜
  • NFS - 네트워크 상에서 다른 컴퓨터의 파일 시스템을 마운트 해서 공유하는 것

** 서버에서 불필요하다고 생각해서 서비스를 중단할 경우 본인이 인지하지 못하고 있는 다른 서비스와 종속성으로 다른 서비스의 장애를 발생시킬 수 있습니다. 서비스 중단하기 전에 다른 문제가 생길 수 있는지 철저히 확인이 필요하다. 

 

“SMTP” 서비스를 사용하지 않는 경우 서비스 데몬 중지합니다.

seldmail ( 또는 postfix)  프로세서 확인

* postfix는  Centos7 이상의 sendmail의 명칭

[root@localhost ~]# ps -ef | grep postfix
root      3096     1  0  2023 ?        00:01:53 /usr/libexec/postfix/master -w
postfix   3114  3096  0  2023 ?        00:00:21 qmgr -l -t unix -u
postfix  25844  3096  0 15:42 ?        00:00:00 pickup -l -t unix -u
root     26841 25255  0 16:01 pts/0    00:00:00 grep --color=auto postfix

 

열린 포트 확인 

[root@localhost ~]# netstat -tulpn | grep LISTEN
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      3096/master         
tcp        0      0 0.0.0.0:2575            0.0.0.0:*               LISTEN      2439/sshd           
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1978/rpcbind 
...

 

systemctl list-unit-files 로 실행 서비스명 확인

[root@localhost ~]# systemctl list-unit-files
... 
postfix.service                               enabled 
...

# enabled 로 서비스가 실행중

 

systemctl status postfix.service  // 서비스 실행 상태 확인 

[root@localhost ~]# systemctl status postfix.service
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: active (running) since 일 2023-05-14 19:56:15 KST; 1 years 2 months ago
  Process: 2470 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
  ...
  
* Active: active (running) -> 해당 서비스 실행중

 

postfix 서비스를 중지시키기 위해 아래 명령어를 사용합니다.

[root@localhost ~]# systemctl stop postfix.service


상태를 확인해 보면 상태가 inactive 비활성화 상태입니다.

[root@localhost ~]# systemctl status postfix.service
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since 목 2024-07-25 17:52:31 KST; 2s ago
 ...
 
#Active: inactive (dead) --> 비활성 상태로 변경됨 

[root@localhost ~]# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:2575            0.0.0.0:*               LISTEN      2439/sshd           
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1978/rpcbind        
tcp        0      0 0.0.0.0:30512           0.0.0.0:*               LISTEN      2513/fbserver 
 ...
 
#netstat -tulpn 확인한 서비스 실행 중이던 25번 포트 중단됨
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      3096/master

 

시스템을 재부팅했을 때  postfix가 다시 실행될 수 없도록 합니다.

[root@localhost ~]# systemctl disable postfix.service
Removed symlink /etc/systemd/system/multi-user.target.wants/postfix.service.

* 재부팅 시에 postfix 서비스는 활성화되지 않습니다.

 


서비스 재부팅 시 활성화시키려면,
# systemctl enable postfix.service 

반응형

댓글