Mail 国外からの接続を拒否

smtps imapsへのアクセスが多すぎの為 国外からのアクセス拒否設定

ただし、DNS参照、メールはSMTPは海外からのメールも来るのでpublicにて設定

国内のゾーンを作ってそれを充てる設定をしているページがあるが

同じインターフェイスに複数のゾーンを持つことができない?

リッチルール側にて国内IPのみを通す設定とする

mkdir /root/iptables
vi /root/iptables/jpip_setup.sh
#!/bin/bash
COUNTRYLIST='JP'
curl -s -o /root/iptables/delegated-apnic-latest http://ftp.apnic.net/stats/apnic/delegated-apnic-latest
:> /root/iptables/jpip
for country in $COUNTRYLIST
do
	for ip in `cat /root/iptables/delegated-apnic-latest | grep "apnic|$country|ipv4|"`
	do
		COUNTRY=`echo $ip | awk -F"|" '{ print $2 }'`
		IPADDR=`echo $ip | awk -F"|" '{ print $4 }'`
		TMPCIDR=`echo $ip | awk -F"|" '{ print $5 }'`

		FLTCIDR=32
		while [ $TMPCIDR -ne 1 ];
		do
			TMPCIDR=$((TMPCIDR/2))
			FLTCIDR=$((FLTCIDR-1))
		done
		echo "$IPADDR/$FLTCIDR" >> /root/iptables/jpip
	done
done
chmod 700 /root/iptables/jpip_setup.sh
/root/iptables/jpip_setup.sh
firewall-cmd --permanent --new-ipset=jpnip --type=hash:net
firewall-cmd --permanent --ipset=jpnip --add-entries-from-file=/root/iptables/jpip
firewall-cmd --permanent --info-ipset=jpnip
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source ipset="jpnip" service name="imaps" accept'
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source ipset="jpnip" service name="smtps" accept'
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source ipset="jpnip" service name="smtp-submission" accept'
firewall-cmd --ipset=jpnip --add-entry=10.0.0.0/8 --permanent
firewall-cmd --ipset=jpnip --add-entry=192.168.0.0/16 --permanent
firewall-cmd --permanent --zone=public --remove-service=imaps
firewall-cmd --permanent --zone=public --remove-service=smtps
firewall-cmd --permanent --zone=public --remove-service=smtp-submission
firewall-cmd --reload
firewall-cmd --list-services
firewall-cmd --list-rich-rules
vi /etc/cron.monthly/fiewall_ipset.sh
#!/bin/bash
sh /root/iptables/jpip_setup.sh
firewall-cmd --reload

WEBを追加する場合は

firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source ipset="jpnip" port port=80 protocol=tcp accept'  --permanent


firewall-cmd --permanent --zone=public --remove-service=http