아마존리눅스2 및 CentOS master 25번 포트 내리는 방법
기본적으로 AL2(아마존리눅스2)나 CentOS7 이상에서 기본적으로 설치되는 메일 서버인 postfix에 대해 사용하지 않는 방법에 대한 것입니다. 그리고 AWS는 SES라는 메일 서비스가 있으며 기본적으로 EC2에선 허용되지 않기 때문에 필요하면 별도 허가를 받기전에는 사용할 수 없습니다.
사용하지 않는 postfix 메일 서버 내리기
아래와 같이 사용하지 않는 메일 포트가 있는 경우 AL2나 CentOS에서는 postfix라는 메일 프로그램입니다.
기본설치가 되며 내가 별도 설치 하지 않아도 다른것 업그레이드 하거나 다른 패키지 설치 될때 나도 모르게 설치 된경우가 있습니다.
특이한 점은 보통의 데몬은 자신의 이름을 가지고 있는데 이 메일 프로그램은 Program name 이 master 라고 되어 있어 별도로 찾아 봐야 합니다.
ps augx | grep master 명령으로 프로세스를 확인하여 단서를 찾을 수 있습니다.
현재 열려진 포트를 확인 합니다.
아래는 불특정 다수의 서비스가 없는 상태이지만 많은 서비스를 하고 있는 경우는
netstat -antp | grep LISTEN 으로 해야 됩니다.
[root@test ~]# netstat -antp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1219/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2251/master
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1213/rpcbind
tcp6 0 0 :::22 :::* LISTEN 1219/sshd
tcp6 0 0 :::443 :::* LISTEN 32014/httpd
tcp6 0 0 :::111 :::* LISTEN 1813/rpcbind
메일 서비스 하지 않도록 내린다.
[root@test ~]# systemctl stop postfix
postfix 메일 포트가 내려 갔는지 확인 합니다.
[root@test ~]# netstat -antp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1219/sshd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1213/rpcbind
tcp6 0 0 :::22 :::* LISTEN 1219/sshd
tcp6 0 0 :::443 :::* LISTEN 32014/httpd
부팅시 시작되지 않도록
메일서버를 내려도 부팅시 시작하거나 시작하지 않는것과는 별개 입니다.
그렇기 때문에 부팅시 시작되지 않도록 하려면 반드시 disable 옵션을 줘서 상태를 변경 시켜 줘야 합니다.
[root@test ~]# systemctl disable postfix
Removed symlink /etc/systemd/system/multi-user.target.wants/postfix.service.