IP centos 7 방화벽에 대한 smtp 서비스 차단

IP centos 7 방화벽에 대한 smtp 서비스 차단

centos 7 방화벽이 설치된 서버에서 smtp 서비스를 사용하기 위해 IP를 차단하는 방법을 알고 싶습니다. 나는 다음과 같은 것을 사용하려고합니다.

   firewall-cmd --permanent --zone="public" --add-rich-rule='rule family=ipv4 source address=[ipadress] --remove-service=smtp'

하지만 올바른 구문은 아닙니다

아니면 TCP 포트 25, 465, 587을 차단해야 합니까?

또한 누군가가 자동으로 이 작업을 수행하는 방법을 알려줄 수 있다면 (가능한 경우) 파일에서 IP를 얻는 것이 좋을 것입니다.

답변1

맨페이지 에 설명된 대로 올바른 구문은 firewalld.richlanguage(5)다음과 같습니다.

# firewall-cmd --zone="FedoraWorkstation" \
  --add-rich-rule='rule family=ipv4 source address=1.2.3.4 service name=smtp reject'
success

# iptables-save | grep 1.2.3.4
-A IN_FedoraWorkstation_deny -s 1.2.3.4/32 -p tcp -m tcp --dport 25 -m conntrack --ctstate NEW -j REJECT --reject-with icmp-port-unreachable

이는 서비스 파일에 설명된 대로 포트 25/tcp로 들어오는 트래픽에 적용됩니다 /usr/lib/firewalld/services/smtp.xml.

<?xml version="1.0" encoding="utf-8"?>
<service>
  <short>Mail (SMTP)</short>
  <description>This option allows incoming SMTP mail delivery. If you need to allow remote hosts to connect directly to your machine to deliver mail, enable this option. You do not need to enable this if you collect your mail from your ISP's server by POP3 or IMAP, or if you use a tool such as fetchmail. Note that an improperly configured SMTP server can allow remote machines to use your server to send spam.</description>
  <port protocol="tcp" port="25"/>
</service>

관련 정보