{"id":2041,"date":"2026-11-16T13:24:15","date_gmt":"2026-11-16T11:24:15","guid":{"rendered":"https:\/\/avz.org.ua\/wp\/?p=2041"},"modified":"2026-11-16T14:24:10","modified_gmt":"2026-11-16T12:24:10","slug":"iptables-dnat-to-loopback","status":"publish","type":"post","link":"https:\/\/avz.org.ua\/wp\/2026\/11\/16\/iptables-dnat-to-loopback\/","title":{"rendered":"iptables rules to redirect incoming external requests to loopback service"},"content":{"rendered":"<p>The problem: some web-server listens on 127.0.0.1:8090. How to make in accessible from certain external IP using iptables rules?<\/p>\n<p>Solution:<\/p>\n<pre lang=\"bash\">\r\n# 1. Let eth0 accept and route packets to\/from 127.0.0.0\/8\r\nsysctl -w net.ipv4.conf.eth0.route_localnet=1\r\necho 'net.ipv4.conf.eth0.route_localnet = 1' > \/etc\/sysctl.d\/90-route-localnet.conf\r\n\r\n# 2. Redirect the allowed client's traffic to the loopback listener\r\niptables -t nat -A PREROUTING -i eth0 -p tcp -s 100.64.0.2 --dport 8090 -j DNAT --to-destination 127.0.0.1:8090\r\n\r\n# 3. Close the hole route_localnet opens (see below), then accept the DNATed flow.\r\n# After DNAT, INPUT sees dst=127.0.0.1, so match on that, not the public IP.\r\niptables -I INPUT 1 -i eth0 -d 127.0.0.0\/8 -m conntrack ! --ctstate RELATED,ESTABLISHED,DNAT -j DROP\r\niptables -I INPUT 2 -i eth0 -p tcp -s 100.64.0.2 -d 127.0.0.1 --dport 8090 -m conntrack --ctstate DNAT -j ACCEPT\r\n<\/pre>\n<p>We can\u2019t DNAT to 127.0.0.1 with iptables rules alone. By default the kernel drops any packet that arrives on a non-loopback interface with a destination in 127.0.0.0\/8, because it treats it as a \u201cmartian\u201d address. You have to allow this with route_localnet on the external interface first. After that, it\u2019s a standard DNAT.<\/p>\n<p>In the rules above, eth0 is the external interface and 100.64.0.2 is the allowed client. <\/p>\n<p>The risky part - route_localnet=1 means any host that can put packets on that interface\u2019s L2 segment can send traffic with destination 127.0.0.1 to your MAC. That traffic would reach every loopback-only service on the box, not just this one. (See CVE-2020-8558 in kube-proxy for details). The DROP rule in step 3 handles this by dropping everything to 127\/8 on eth0 that wasn\u2019t created by our DNAT. We have to keep that rule above any broad ACCEPT in INPUT. <\/p>\n<p>Test from 100.64.0.2 with curl -v http:\/\/<server_public_ip>:8090\/ should work. Curling the public IP from the server won\u2019t work, because locally generated traffic skips PREROUTING.<\/p>\n<p>For debugging: conntrack -L -p tcp --dport 8090 shows whether the DNAT is happening. sysctl -w net.ipv4.conf.all.log_martians=1 will log drops in dmesg if route_localnet isn\u2019t taking effect for some reason. If the OUTPUT policy is DROP, we\u2019ll also need to allow the reply traffic.<\/p>\n<p>There are two cleaner alternatives to the proposed solution:<\/p>\n<p>1. Rebind the server to the public IP or 0.0.0.0 and filter with a plain -s 100.64.0.2 --dport 8090 -j ACCEPT. Then we don\u2019t need route_localnet and NAT.<br \/>\n2. A reverse proxy (HAProxy, nginx, or even socat) listening on the public IP and forwarding to 127.0.0.1:8090. This keeps the loopback boundary intact. The trade-off is that the app sees the proxy\u2019s IP unless we pass X-Forwarded-For HTTP-header or the PROXY protocol.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The problem: some web-server listens on 127.0.0.1:8090. How to make in accessible from certain external IP using iptables rules? Solution: # 1. Let eth0 accept and route packets to\/from 127.0.0.0\/8 sysctl -w net.ipv4.conf.eth0.route_localnet=1 echo 'net.ipv4.conf.eth0.route_localnet = 1' > \/etc\/sysctl.d\/90-route-localnet.conf # 2. Redirect the allowed client's traffic to the loopback listener iptables -t nat -A PREROUTING [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,21],"tags":[109,13,122,94],"class_list":["post-2041","post","type-post","status-publish","format-standard","hentry","category-nix","category-tips-and-tricks","tag-iptables","tag-nat","tag-sysctl","tag-port-forwarding"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.9 - aioseo.com -->\n\t<meta name=\"description\" content=\"The problem: some web-server listens on 127.0.0.1:8090. How to make in accessible from certain external IP using iptables rules? Solution: # 1. Let eth0 accept and route packets to\/from 127.0.0.0\/8 sysctl -w net.ipv4.conf.eth0.route_localnet=1 echo &#039;net.ipv4.conf.eth0.route_localnet = 1&#039; &gt; \/etc\/sysctl.d\/90-route-localnet.conf # 2. Redirect the allowed client&#039;s traffic to the loopback listener iptables -t nat -A PREROUTING\" \/>\n\t<meta name=\"robots\" content=\"max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n\t<meta name=\"author\" content=\"Admin\"\/>\n\t<meta name=\"keywords\" content=\"iptables,nat,sysctl,\u043f\u0440\u043e\u0431\u0440\u043e\u0441 \u043f\u043e\u0440\u0442\u0456\u0432,*nix,howto\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/avz.org.ua\/wp\/2026\/11\/16\/iptables-dnat-to-loopback\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.9\" \/>\n\t\t<meta property=\"og:locale\" content=\"uk_UA\" \/>\n\t\t<meta property=\"og:site_name\" content=\"\u0411\u043b\u043e\u0433 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 | \u041d\u043e\u0442\u0430\u0442\u043a\u0438 \u043f\u0440\u043e Linux \u0442\u0430 \u043a\u043e\u0440\u0438\u0441\u043d\u0456 \u043f\u043e\u0440\u0430\u0434\u0438 \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0438\u0445 \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0456\u0432\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"iptables rules to redirect incoming external requests to loopback service | \u0411\u043b\u043e\u0433 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430\" \/>\n\t\t<meta property=\"og:description\" content=\"The problem: some web-server listens on 127.0.0.1:8090. How to make in accessible from certain external IP using iptables rules? Solution: # 1. Let eth0 accept and route packets to\/from 127.0.0.0\/8 sysctl -w net.ipv4.conf.eth0.route_localnet=1 echo &#039;net.ipv4.conf.eth0.route_localnet = 1&#039; &gt; \/etc\/sysctl.d\/90-route-localnet.conf # 2. Redirect the allowed client&#039;s traffic to the loopback listener iptables -t nat -A PREROUTING\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/avz.org.ua\/wp\/2026\/11\/16\/iptables-dnat-to-loopback\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2026-11-16T11:24:15+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2026-11-16T12:24:10+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"iptables rules to redirect incoming external requests to loopback service | \u0411\u043b\u043e\u0433 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430\" \/>\n\t\t<meta name=\"twitter:description\" content=\"The problem: some web-server listens on 127.0.0.1:8090. How to make in accessible from certain external IP using iptables rules? Solution: # 1. Let eth0 accept and route packets to\/from 127.0.0.0\/8 sysctl -w net.ipv4.conf.eth0.route_localnet=1 echo &#039;net.ipv4.conf.eth0.route_localnet = 1&#039; &gt; \/etc\/sysctl.d\/90-route-localnet.conf # 2. Redirect the allowed client&#039;s traffic to the loopback listener iptables -t nat -A PREROUTING\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/2026\\\/11\\\/16\\\/iptables-dnat-to-loopback\\\/#article\",\"name\":\"iptables rules to redirect incoming external requests to loopback service | \\u0411\\u043b\\u043e\\u0433 \\u0441\\u0438\\u0441\\u0442\\u0435\\u043c\\u043d\\u043e\\u0433\\u043e \\u0430\\u0434\\u043c\\u0456\\u043d\\u0456\\u0441\\u0442\\u0440\\u0430\\u0442\\u043e\\u0440\\u0430\",\"headline\":\"iptables rules to redirect incoming external requests to loopback service\",\"author\":{\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/#organization\"},\"datePublished\":\"2026-11-16T13:24:15+02:00\",\"dateModified\":\"2026-11-16T14:24:10+02:00\",\"inLanguage\":\"uk\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/2026\\\/11\\\/16\\\/iptables-dnat-to-loopback\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/2026\\\/11\\\/16\\\/iptables-dnat-to-loopback\\\/#webpage\"},\"articleSection\":\"*nix, Howto, iptables, NAT, sysctl, \\u043f\\u0440\\u043e\\u0431\\u0440\\u043e\\u0441 \\u043f\\u043e\\u0440\\u0442\\u0456\\u0432\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/2026\\\/11\\\/16\\\/iptables-dnat-to-loopback\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp#listItem\",\"position\":1,\"name\":\"\\u0413\\u043b\\u0430\\u0432\\u043d\\u0430\\u044f\",\"item\":\"https:\\\/\\\/avz.org.ua\\\/wp\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/category\\\/tips-and-tricks\\\/#listItem\",\"name\":\"Howto\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/category\\\/tips-and-tricks\\\/#listItem\",\"position\":2,\"name\":\"Howto\",\"item\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/category\\\/tips-and-tricks\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/category\\\/tips-and-tricks\\\/nix\\\/#listItem\",\"name\":\"*nix\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp#listItem\",\"name\":\"\\u0413\\u043b\\u0430\\u0432\\u043d\\u0430\\u044f\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/category\\\/tips-and-tricks\\\/nix\\\/#listItem\",\"position\":3,\"name\":\"*nix\",\"item\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/category\\\/tips-and-tricks\\\/nix\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/2026\\\/11\\\/16\\\/iptables-dnat-to-loopback\\\/#listItem\",\"name\":\"iptables rules to redirect incoming external requests to loopback service\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/category\\\/tips-and-tricks\\\/#listItem\",\"name\":\"Howto\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/2026\\\/11\\\/16\\\/iptables-dnat-to-loopback\\\/#listItem\",\"position\":4,\"name\":\"iptables rules to redirect incoming external requests to loopback service\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/category\\\/tips-and-tricks\\\/nix\\\/#listItem\",\"name\":\"*nix\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/#organization\",\"name\":\"\\u0411\\u043b\\u043e\\u0433 \\u0441\\u0438\\u0441\\u0442\\u0435\\u043c\\u043d\\u043e\\u0433\\u043e \\u0430\\u0434\\u043c\\u0456\\u043d\\u0456\\u0441\\u0442\\u0440\\u0430\\u0442\\u043e\\u0440\\u0430\",\"description\":\"\\u041d\\u043e\\u0442\\u0430\\u0442\\u043a\\u0438 \\u043f\\u0440\\u043e Linux \\u0442\\u0430 \\u043a\\u043e\\u0440\\u0438\\u0441\\u043d\\u0456 \\u043f\\u043e\\u0440\\u0430\\u0434\\u0438 \\u0434\\u043b\\u044f \\u0441\\u0438\\u0441\\u0442\\u0435\\u043c\\u043d\\u0438\\u0445 \\u0430\\u0434\\u043c\\u0456\\u043d\\u0456\\u0441\\u0442\\u0440\\u0430\\u0442\\u043e\\u0440\\u0456\\u0432\",\"url\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/author\\\/admin\\\/#author\",\"url\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/author\\\/admin\\\/\",\"name\":\"Admin\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/2026\\\/11\\\/16\\\/iptables-dnat-to-loopback\\\/#webpage\",\"url\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/2026\\\/11\\\/16\\\/iptables-dnat-to-loopback\\\/\",\"name\":\"iptables rules to redirect incoming external requests to loopback service | \\u0411\\u043b\\u043e\\u0433 \\u0441\\u0438\\u0441\\u0442\\u0435\\u043c\\u043d\\u043e\\u0433\\u043e \\u0430\\u0434\\u043c\\u0456\\u043d\\u0456\\u0441\\u0442\\u0440\\u0430\\u0442\\u043e\\u0440\\u0430\",\"description\":\"The problem: some web-server listens on 127.0.0.1:8090. How to make in accessible from certain external IP using iptables rules? Solution: # 1. Let eth0 accept and route packets to\\\/from 127.0.0.0\\\/8 sysctl -w net.ipv4.conf.eth0.route_localnet=1 echo 'net.ipv4.conf.eth0.route_localnet = 1' > \\\/etc\\\/sysctl.d\\\/90-route-localnet.conf # 2. Redirect the allowed client's traffic to the loopback listener iptables -t nat -A PREROUTING\",\"inLanguage\":\"uk\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/2026\\\/11\\\/16\\\/iptables-dnat-to-loopback\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2026-11-16T13:24:15+02:00\",\"dateModified\":\"2026-11-16T14:24:10+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/#website\",\"url\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/\",\"name\":\"\\u0411\\u043b\\u043e\\u0433 \\u0441\\u0438\\u0441\\u0430\\u0434\\u043c\\u0456\\u043d\\u0430\",\"description\":\"\\u041d\\u043e\\u0442\\u0430\\u0442\\u043a\\u0438 \\u043f\\u0440\\u043e Linux \\u0442\\u0430 \\u043a\\u043e\\u0440\\u0438\\u0441\\u043d\\u0456 \\u043f\\u043e\\u0440\\u0430\\u0434\\u0438 \\u0434\\u043b\\u044f \\u0441\\u0438\\u0441\\u0442\\u0435\\u043c\\u043d\\u0438\\u0445 \\u0430\\u0434\\u043c\\u0456\\u043d\\u0456\\u0441\\u0442\\u0440\\u0430\\u0442\\u043e\\u0440\\u0456\\u0432\",\"inLanguage\":\"uk\",\"publisher\":{\"@id\":\"https:\\\/\\\/avz.org.ua\\\/wp\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"iptables rules to redirect incoming external requests to loopback service | \u0411\u043b\u043e\u0433 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430","description":"The problem: some web-server listens on 127.0.0.1:8090. How to make in accessible from certain external IP using iptables rules? Solution: # 1. Let eth0 accept and route packets to\/from 127.0.0.0\/8 sysctl -w net.ipv4.conf.eth0.route_localnet=1 echo 'net.ipv4.conf.eth0.route_localnet = 1' > \/etc\/sysctl.d\/90-route-localnet.conf # 2. Redirect the allowed client's traffic to the loopback listener iptables -t nat -A PREROUTING","canonical_url":"https:\/\/avz.org.ua\/wp\/2026\/11\/16\/iptables-dnat-to-loopback\/","robots":"max-snippet:-1, max-image-preview:large, max-video-preview:-1","keywords":"iptables,nat,sysctl,\u043f\u0440\u043e\u0431\u0440\u043e\u0441 \u043f\u043e\u0440\u0442\u0456\u0432,*nix,howto","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/avz.org.ua\/wp\/2026\/11\/16\/iptables-dnat-to-loopback\/#article","name":"iptables rules to redirect incoming external requests to loopback service | \u0411\u043b\u043e\u0433 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430","headline":"iptables rules to redirect incoming external requests to loopback service","author":{"@id":"https:\/\/avz.org.ua\/wp\/author\/admin\/#author"},"publisher":{"@id":"https:\/\/avz.org.ua\/wp\/#organization"},"datePublished":"2026-11-16T13:24:15+02:00","dateModified":"2026-11-16T14:24:10+02:00","inLanguage":"uk","mainEntityOfPage":{"@id":"https:\/\/avz.org.ua\/wp\/2026\/11\/16\/iptables-dnat-to-loopback\/#webpage"},"isPartOf":{"@id":"https:\/\/avz.org.ua\/wp\/2026\/11\/16\/iptables-dnat-to-loopback\/#webpage"},"articleSection":"*nix, Howto, iptables, NAT, sysctl, \u043f\u0440\u043e\u0431\u0440\u043e\u0441 \u043f\u043e\u0440\u0442\u0456\u0432"},{"@type":"BreadcrumbList","@id":"https:\/\/avz.org.ua\/wp\/2026\/11\/16\/iptables-dnat-to-loopback\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/avz.org.ua\/wp#listItem","position":1,"name":"\u0413\u043b\u0430\u0432\u043d\u0430\u044f","item":"https:\/\/avz.org.ua\/wp","nextItem":{"@type":"ListItem","@id":"https:\/\/avz.org.ua\/wp\/category\/tips-and-tricks\/#listItem","name":"Howto"}},{"@type":"ListItem","@id":"https:\/\/avz.org.ua\/wp\/category\/tips-and-tricks\/#listItem","position":2,"name":"Howto","item":"https:\/\/avz.org.ua\/wp\/category\/tips-and-tricks\/","nextItem":{"@type":"ListItem","@id":"https:\/\/avz.org.ua\/wp\/category\/tips-and-tricks\/nix\/#listItem","name":"*nix"},"previousItem":{"@type":"ListItem","@id":"https:\/\/avz.org.ua\/wp#listItem","name":"\u0413\u043b\u0430\u0432\u043d\u0430\u044f"}},{"@type":"ListItem","@id":"https:\/\/avz.org.ua\/wp\/category\/tips-and-tricks\/nix\/#listItem","position":3,"name":"*nix","item":"https:\/\/avz.org.ua\/wp\/category\/tips-and-tricks\/nix\/","nextItem":{"@type":"ListItem","@id":"https:\/\/avz.org.ua\/wp\/2026\/11\/16\/iptables-dnat-to-loopback\/#listItem","name":"iptables rules to redirect incoming external requests to loopback service"},"previousItem":{"@type":"ListItem","@id":"https:\/\/avz.org.ua\/wp\/category\/tips-and-tricks\/#listItem","name":"Howto"}},{"@type":"ListItem","@id":"https:\/\/avz.org.ua\/wp\/2026\/11\/16\/iptables-dnat-to-loopback\/#listItem","position":4,"name":"iptables rules to redirect incoming external requests to loopback service","previousItem":{"@type":"ListItem","@id":"https:\/\/avz.org.ua\/wp\/category\/tips-and-tricks\/nix\/#listItem","name":"*nix"}}]},{"@type":"Organization","@id":"https:\/\/avz.org.ua\/wp\/#organization","name":"\u0411\u043b\u043e\u0433 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430","description":"\u041d\u043e\u0442\u0430\u0442\u043a\u0438 \u043f\u0440\u043e Linux \u0442\u0430 \u043a\u043e\u0440\u0438\u0441\u043d\u0456 \u043f\u043e\u0440\u0430\u0434\u0438 \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0438\u0445 \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0456\u0432","url":"https:\/\/avz.org.ua\/wp\/"},{"@type":"Person","@id":"https:\/\/avz.org.ua\/wp\/author\/admin\/#author","url":"https:\/\/avz.org.ua\/wp\/author\/admin\/","name":"Admin"},{"@type":"WebPage","@id":"https:\/\/avz.org.ua\/wp\/2026\/11\/16\/iptables-dnat-to-loopback\/#webpage","url":"https:\/\/avz.org.ua\/wp\/2026\/11\/16\/iptables-dnat-to-loopback\/","name":"iptables rules to redirect incoming external requests to loopback service | \u0411\u043b\u043e\u0433 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430","description":"The problem: some web-server listens on 127.0.0.1:8090. How to make in accessible from certain external IP using iptables rules? Solution: # 1. Let eth0 accept and route packets to\/from 127.0.0.0\/8 sysctl -w net.ipv4.conf.eth0.route_localnet=1 echo 'net.ipv4.conf.eth0.route_localnet = 1' > \/etc\/sysctl.d\/90-route-localnet.conf # 2. Redirect the allowed client's traffic to the loopback listener iptables -t nat -A PREROUTING","inLanguage":"uk","isPartOf":{"@id":"https:\/\/avz.org.ua\/wp\/#website"},"breadcrumb":{"@id":"https:\/\/avz.org.ua\/wp\/2026\/11\/16\/iptables-dnat-to-loopback\/#breadcrumblist"},"author":{"@id":"https:\/\/avz.org.ua\/wp\/author\/admin\/#author"},"creator":{"@id":"https:\/\/avz.org.ua\/wp\/author\/admin\/#author"},"datePublished":"2026-11-16T13:24:15+02:00","dateModified":"2026-11-16T14:24:10+02:00"},{"@type":"WebSite","@id":"https:\/\/avz.org.ua\/wp\/#website","url":"https:\/\/avz.org.ua\/wp\/","name":"\u0411\u043b\u043e\u0433 \u0441\u0438\u0441\u0430\u0434\u043c\u0456\u043d\u0430","description":"\u041d\u043e\u0442\u0430\u0442\u043a\u0438 \u043f\u0440\u043e Linux \u0442\u0430 \u043a\u043e\u0440\u0438\u0441\u043d\u0456 \u043f\u043e\u0440\u0430\u0434\u0438 \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0438\u0445 \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0456\u0432","inLanguage":"uk","publisher":{"@id":"https:\/\/avz.org.ua\/wp\/#organization"}}]},"og:locale":"uk_UA","og:site_name":"\u0411\u043b\u043e\u0433 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 | \u041d\u043e\u0442\u0430\u0442\u043a\u0438 \u043f\u0440\u043e Linux \u0442\u0430 \u043a\u043e\u0440\u0438\u0441\u043d\u0456 \u043f\u043e\u0440\u0430\u0434\u0438 \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0438\u0445 \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0456\u0432","og:type":"article","og:title":"iptables rules to redirect incoming external requests to loopback service | \u0411\u043b\u043e\u0433 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430","og:description":"The problem: some web-server listens on 127.0.0.1:8090. How to make in accessible from certain external IP using iptables rules? Solution: # 1. Let eth0 accept and route packets to\/from 127.0.0.0\/8 sysctl -w net.ipv4.conf.eth0.route_localnet=1 echo 'net.ipv4.conf.eth0.route_localnet = 1' &gt; \/etc\/sysctl.d\/90-route-localnet.conf # 2. Redirect the allowed client's traffic to the loopback listener iptables -t nat -A PREROUTING","og:url":"https:\/\/avz.org.ua\/wp\/2026\/11\/16\/iptables-dnat-to-loopback\/","article:published_time":"2026-11-16T11:24:15+00:00","article:modified_time":"2026-11-16T12:24:10+00:00","twitter:card":"summary","twitter:title":"iptables rules to redirect incoming external requests to loopback service | \u0411\u043b\u043e\u0433 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430","twitter:description":"The problem: some web-server listens on 127.0.0.1:8090. How to make in accessible from certain external IP using iptables rules? Solution: # 1. Let eth0 accept and route packets to\/from 127.0.0.0\/8 sysctl -w net.ipv4.conf.eth0.route_localnet=1 echo 'net.ipv4.conf.eth0.route_localnet = 1' &gt; \/etc\/sysctl.d\/90-route-localnet.conf # 2. Redirect the allowed client's traffic to the loopback listener iptables -t nat -A PREROUTING"},"aioseo_meta_data":{"post_id":"2041","title":null,"description":null,"keywords":null,"keyphrases":{"focus":{"keyphrase":"","score":0,"analysis":{"keyphraseInTitle":{"score":0,"maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":{"faqs":[],"keyPoints":[],"schemas":[],"titles":[],"descriptions":[],"socialPosts":{"email":{"subject":"","preview":"","content":""},"linkedin":[],"twitter":[],"facebook":[],"instagram":[]}},"created":"2026-11-16 11:12:11","updated":"2026-11-16 12:24:10","seo_analyzer_scan_date":null},"_links":{"self":[{"href":"https:\/\/avz.org.ua\/wp\/wp-json\/wp\/v2\/posts\/2041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/avz.org.ua\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/avz.org.ua\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/avz.org.ua\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/avz.org.ua\/wp\/wp-json\/wp\/v2\/comments?post=2041"}],"version-history":[{"count":0,"href":"https:\/\/avz.org.ua\/wp\/wp-json\/wp\/v2\/posts\/2041\/revisions"}],"wp:attachment":[{"href":"https:\/\/avz.org.ua\/wp\/wp-json\/wp\/v2\/media?parent=2041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/avz.org.ua\/wp\/wp-json\/wp\/v2\/categories?post=2041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/avz.org.ua\/wp\/wp-json\/wp\/v2\/tags?post=2041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}