{"id":3599,"date":"2020-03-25T17:49:03","date_gmt":"2020-03-25T16:49:03","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=3599"},"modified":"2020-03-25T18:15:35","modified_gmt":"2020-03-25T17:15:35","slug":"iptables-port-forwarding","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/iptables-port-forwarding\/","title":{"rendered":"iptables port forwarding"},"content":{"rendered":"\n<p><a href=\"https:\/\/serverfault.com\/a\/838865\">https:\/\/serverfault.com\/a\/838865<\/a><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sysctl net.ipv4.ip_forward=1\n\niptables -t nat -A PREROUTING -p tcp -d MACHINE_B --dport 443 -j DNAT --to-destination MACHINE_C\n\niptables -t nat -A POSTROUTING -s MACHINE_A -o INTERFACE_NAME -j MASQUERADE\n\n# iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j DNAT --to 192.168.1.2:8080\n# iptables -A FORWARD -p tcp -d 192.168.1.2 --dport 8080 -j ACCEPT\n<\/pre>\n\n\n\n<p>Please note that you might want to tweak the commands:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>To allow packet forwardning on a specific interface only. For example:<code>sysctl net.ipv4.conf.eth0.forwarding=1\n<\/code><\/li><li>To allow not only MACHINE_A, but also all others to use port forwarding, remove:<code>-s MACHINE_A<\/code><\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/serverfault.com\/a\/838865 Please note that you might want to tweak the commands: To allow packet forwardning on a specific interface only. For example:sysctl net.ipv4.conf.eth0.forwarding=1 To allow not only MACHINE_A, but also all others to use port forwarding, remove:-s MACHINE_A<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3599","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/3599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=3599"}],"version-history":[{"count":2,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/3599\/revisions"}],"predecessor-version":[{"id":3607,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/3599\/revisions\/3607"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=3599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=3599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=3599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}