{"id":10,"date":"2019-05-08T07:16:55","date_gmt":"2019-05-08T07:16:55","guid":{"rendered":"http:\/\/untanux.lt\/?p=10"},"modified":"2019-05-08T07:16:55","modified_gmt":"2019-05-08T07:16:55","slug":"simple-linux-nat-server","status":"publish","type":"post","link":"https:\/\/untanux.lt\/?p=10","title":{"rendered":"Simple Linux NAT server"},"content":{"rendered":"\n<p>\nAll of these commands must be executed as the root user.\nFirst you need to tell your kernel that you want to allow IP forwarding.\n<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo 1 > \/proc\/sys\/net\/ipv4\/ip_forward<\/code><\/pre>\n\n\n\n<p>\nThen you&#8217;ll need to configure iptables to forward the packets from\nyour internal network, on \/dev\/eth1, to your external network on \/dev\/eth0.\nYou do this will the following commands:\n<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \/sbin\/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE\n# \/sbin\/iptables -A FORWARD -i eth0 -o eth1 -m state\n   --state RELATED,ESTABLISHED -j ACCEPT\n# \/sbin\/iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT\n<\/code><\/pre>\n\n\n\n<p>\nYou should now be NATing.  You can test this by pinging an external address\nfrom one of your internal hosts. The last step is to ensure that this\nsetup survives over a reboot. Obviously you should only do these last two\nsteps if your test is a success.\n<\/p>\n\n\n\n<p>\nYou will need to edit <code>\/etc\/sysctl.conf<\/code> and change the line that says\n<code>net.ipv4.ip_forward = 0<\/code> to\n<code>net.ipv4.ip_forward = 1<\/code>. Notice how this is similar to\nstep number one? This essentially tells your kernel to do step one on boot.\n<\/p>\n\n\n\n<p>\nOk last step for Fedora\/RHEL users.  In order for your system to save the\niptables rules we setup in step two you have to configure iptables\ncorrectly.  You will need to edit <code>\/etc\/sysconfig\/iptables-config<\/code>\nand make sure <code>IPTABLES_MODULES_UNLOAD<\/code>,\n<code>IPTABLES_SAVE_ON_STOP<\/code>, and\n<code>IPTABLES_SAVE_ON_RESTART<\/code> are all set to &#8216;yes&#8217;.\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>All of these commands must be executed as the root user. First you need to tell your kernel that you want to allow IP forwarding. Then you&#8217;ll need to configure iptables to forward the packets from your internal network, on \/dev\/eth1, to your external network on \/dev\/eth0. You do this will the following commands: You [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-10","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/untanux.lt\/index.php?rest_route=\/wp\/v2\/posts\/10","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/untanux.lt\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/untanux.lt\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/untanux.lt\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/untanux.lt\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10"}],"version-history":[{"count":0,"href":"https:\/\/untanux.lt\/index.php?rest_route=\/wp\/v2\/posts\/10\/revisions"}],"wp:attachment":[{"href":"https:\/\/untanux.lt\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/untanux.lt\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/untanux.lt\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}