ファイアウォールのサービスに2つのポートを割り当てる

ファイアウォールのサービスに2つのポートを割り当てる

ファイアウォールで同じサービスに2つのポートを割り当てる方法はありますか?たとえば、SMTPサービスがポート25とポート465の両方でリッスンしたいとします。私の最初の反応は、/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 $
  <port protocol="tcp" port="465"/>
  <!-- is adding a second port here legal and the best approach? -->
  <port protocol="tcp" port="25"/> 
</service>

ベストアンサー1

別のサービスを作成できます。

<?xml version="1.0" encoding="utf-8"?>
<service>
  <short>Mail (SMTP on port 465)</short>
  <description>This option allows incoming SMTP mail delivery on the alternative port 465. 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="465"/>
</service>

たとえば、別の名前で保存すると、後で元のサービスと同じゾーン/usr/lib/firewalld/services/alt-smtp.xmlに追加できます。smtp

または、質問に提案されているように実行することもできます。からman firewalld.service

port
   Is an optional empty-element tag and can be used several times to have
   more than one port entry.

前者はより多くの制御を提供します。一方または両方を有効にできます。後者はタイピングが少なくて済みます。

おすすめ記事