{"id":24993,"date":"2023-02-10T09:50:43","date_gmt":"2023-02-10T09:50:43","guid":{"rendered":"http:\/\/localhost\/helpold\/?p=24306"},"modified":"2023-02-10T09:50:43","modified_gmt":"2023-02-10T09:50:43","slug":"whitelist-iptables","status":"publish","type":"post","link":"https:\/\/www.arvancloud.ir\/help\/en\/whitelist-iptables\/","title":{"rendered":"Whitelisting ArvanCloud IP Addresses in Iptables"},"content":{"rendered":"<p>An important step toward preventing disruption and delay in the connection between Arvan edge servers and the main host server is to mark the IP addresses of Arvan Cloud as whitelisted in the firewall settings of the host server. It means that the firewall must be configured to recognize a list of authorized IP addresses that might try to connect to the platform. This document presents two methods for adding Arvan IP addresses to the iptables.<\/p>\n<h2>Method 1: a separate entry for each IP range<\/h2>\n<p>In this method the following line must be repeated for each IP range that is listed in the IP addresses page of Arvan Cloud. The ip in the following line must be replaced by an IP address from Arvan Cloud.<\/p>\n<pre><code class=\"http hljs\"><span class=\"hljs-attribute\">iptables -I INPUT -p tcp -m multiport --dports http,https -s \"$ip\" -j ACCEPT<\/span><\/code><\/pre>\n<h2>Method 2: using ipset<\/h2>\n<p>Another method is using ipset, instead of entering every single IP address manually. If this tool is not installed on your host server, you can install it using the following command.<\/p>\n<h2>Ubuntu<\/h2>\n<pre><code class=\"http hljs\"><span class=\"hljs-attribute\">sudo apt-get install ipset<\/span><\/code><\/pre>\n<h2>CentOS<\/h2>\n<p>&nbsp;<\/p>\n<pre><code class=\"http hljs\"><span class=\"hljs-attribute\">yum install ipset<\/span><\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>Now, you can use ipset to specify a list of authorized IP addresses (in this case the IP addresses of Arvan Cloud). In the following command you can replace \u2018example\u2019 with a name that you prefer.<\/p>\n<pre><code class=\"http hljs\"><span class=\"hljs-attribute\">ipset create example hash:net for x in $(curl https:\/\/www.arvancloud.ir\/fa\/ips.txt); do ipset add example $x; done<\/span><\/code><\/pre>\n<p>Please note that after executing the above command, a list of IP addresses will be saved in memory. But, by default it would be erased after a system reboot. Therefore, you need to save this command and re-run it after system reboot.<br \/>\nNow that the list of authorized IP addresses is created using ipset, we can use this list (which we named example in the above command) in the iptables command:<\/p>\n<pre><code class=\"http hljs\"><span class=\"hljs-attribute\">iptables -A INPUT -m set --match-set example src -p tcp -m multiport --dports http,https -j ACCEPT<\/span><\/code><\/pre>\n<p>In both methods, the last step is to save the modified iptables rules. You can do it using the following commands:<\/p>\n<h2>Debian<\/h2>\n<p>&nbsp;<\/p>\n<pre><code class=\"http hljs\"><span class=\"hljs-attribute\">iptables-save &gt; \/etc\/iptables\/rules.v4<\/span><\/code><\/pre>\n<h2>CentOS<\/h2>\n<p>&nbsp;<\/p>\n<pre><code class=\"http hljs\"><span class=\"hljs-attribute\">iptables-save &gt; \/etc\/sysconfig\/iptables<\/span><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>An important step toward preventing disruption and delay in the connection between Arvan edge servers and the main host server is to mark the IP addresses of Arvan Cloud as whitelisted in the firewall settings of the host server. It means that the firewall must be configured to recognize a list of authorized IP addresses [&hellip;]<\/p>\n","protected":false},"author":79,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"r1_post_views_count":"1512","feedback_yes":"","feedback_no":"1","ads_id_sidebar":"","ads_id_content":"","footnotes":""},"categories":[249,255],"tags":[],"class_list":["post-24993","post","type-post","status-publish","format-standard","hentry","category-cdn","category-cdn-setting"],"lang":"en","translations":{"en":24993},"pll_sync_post":[],"_links":{"self":[{"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/posts\/24993","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/users\/79"}],"replies":[{"embeddable":true,"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/comments?post=24993"}],"version-history":[{"count":0,"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/posts\/24993\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/media?parent=24993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/categories?post=24993"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/tags?post=24993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}