次のIPテーブルを作成しようとしていますが、複数のポート(この場合は80と110)の設定に問題があり、同じルールで複数のポートを設定する方法がわかりません。
sudo iptables -t nat -A PREROUTING -d 192.168.0.1 -p tcp --dport 80,110 -j DNAT --to-destination 10.0.0.2
次のエラーを返します。
iptables v1.8.7 (legacy): invalid port/service `80,110' specified
Try `iptables -h' or 'iptables --help' for more information.
ベストアンサー1
man iptables-extensions
-m multiport
[!] --destination-ports,--dports port[,port|,port:port]...
Match if the destination port is one of the given ports. The flag --dports
is a convenient alias for this option.
したがって、次のようにする必要があります。
sudo iptables -t nat -A PREROUTING -d 192.168.0.1 -p tcp -m multiport --dports 80,110 -j DNAT --to-destination 10.0.0.2
(私はすでにテストなしでnftablesに切り替えました。)