{"id":91,"date":"2016-12-15T00:10:20","date_gmt":"2016-12-14T21:10:20","guid":{"rendered":"https:\/\/qwertys.ru\/?p=91"},"modified":"2017-03-08T23:32:52","modified_gmt":"2017-03-08T20:32:52","slug":"lxc-%d0%b7%d0%b0-%d0%be%d0%b1%d1%80%d0%b0%d1%82%d0%bd%d1%8b%d0%bc-nat-reverse-nat-%d0%9f%d0%be%d1%88%d0%b0%d0%b3%d0%be%d0%b2%d0%b0%d1%8f-%d0%b8%d0%bd%d1%81%d1%82%d1%80%d1%83%d0%ba%d1%86%d0%b8%d1%8f","status":"publish","type":"post","link":"https:\/\/qwertys.ru\/?p=91","title":{"rendered":"LXC \u0437\u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u043c NAT (Reverse NAT). \u041f\u043e\u0448\u0430\u0433\u043e\u0432\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f."},"content":{"rendered":"<p>\u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0438\u0441\u0447\u0435\u0440\u043f\u0430\u043d\u0438\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 ipv4 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0432\u0441\u0435 \u0431\u043e\u043b\u0435\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0442\u0435\u043c\u0430 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u0448\u0438\u043d \u0437\u0430 NAT. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432:<br \/>\n1. \u042d\u043a\u043e\u043d\u043e\u043c\u0438\u044f \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u043b\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043c\u0430\u0448\u0438\u043d;<br \/>\n2. \u0421\u043e\u043a\u0440\u044b\u0442\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 (\u0442. \u0435. \u0432\u0430\u0448\u0430 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u0430 \u0434\u043b\u044f \u043c\u0438\u0440\u0430).<br \/>\n\u041e\u0434\u043d\u0430\u043a\u043e, \u043a\u0430\u043a \u0438 \u0443 \u043b\u044e\u0431\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438, \u0443 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0435\u0441\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438.<br \/>\n<!--more--><\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e:<br \/>\n1. NAT \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044f \/ \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0430 \u043f\u0430\u043a\u0435\u0442\u0430;<br \/>\n2. \u041f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0430\u043a\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0443\u0437\u043b\u0443 (\u043f\u0443\u0441\u043a\u0430\u0439 \u0438 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c\u0443 &#8212; \u043d\u0430 \u044d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b).<br \/>\n\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u044d\u0442\u043e \u043d\u0435 \u0441\u0442\u0440\u0430\u0448\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u0441\u0435\u0442\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b?<\/p>\n<p>\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 Debian Jessie, \u0440\u0430\u0441\u0447\u0438\u0442\u0430\u043d\u044b \u043d\u0430 \u043b\u044e\u0434\u0435\u0439 \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 NAT. \u041f\u043e\u043c\u0438\u043c\u043e LXC, \u043e\u043d\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u044b \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p><strong>1. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u043c\u043e\u0441\u0442 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432.<\/strong><br \/>\n\u0412 \u0444\u0430\u0439\u043b\u0435 <code>\/etc\/network\/interfaces<\/code>, \u043f\u0440\u043e\u043f\u0438\u0448\u0438\u0442\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043c\u043e\u0441\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u0432 \u0438\u0442\u043e\u0433\u0435 \u0444\u0430\u0439\u043b \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u043b \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<pre class=\"code_block\">auto lo\r\niface lo inet loopback\r\n\r\n# The primary network interface\r\nallow-hotplug eth0\r\niface eth0 inet static\r\n        address 12.13.14.15\r\n        netmask 255.255.255.0\r\n        gateway 12.13.14.1\r\n        dns-nameservers 8.8.8.8 8.8.4.4\r\n\r\nauto br0\r\niface br0 inet static\r\n        address 172.16.1.1\r\n        netmask 255.255.255.0\r\n        bridge_ports none\r\n        dns-nameservers 8.8.8.8 8.8.4.4<\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c:<br \/>\nlo &#8212; loopback \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0443 \u0432\u0430\u0441 \u043e\u043d \u0443\u0436\u0435 \u0435\u0441\u0442\u044c.<br \/>\neth0 &#8212; \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c IP.<br \/>\nbr0 &#8212; \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u043c\u043e\u0441\u0442\u0430, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b. \u0423 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 IP \u0438\u0437 \u0441\u0435\u0442\u0438 172.16.1.0\/24<\/p>\n<p><strong>2. \u0420\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u043e\u0432.<\/strong><br \/>\n\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043e\u0432 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043e. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0430\u0434\u0440\u0435\u0441 192.168.1.20) \u043f\u0440\u0438\u0434\u0435\u0442 \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u043e\u0433\u043e IP (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 192.168.2.45), \u0442\u043e \u043e\u043d \u0435\u0433\u043e \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u0442. \u041f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u043c \u0436\u0435 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438, \u043e\u043d \u0435\u0433\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442 \u0446\u0435\u043b\u0435\u0432\u043e\u043c\u0443 \u0443\u0437\u043b\u0443.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435:<br \/>\n<code>\/etc\/network\/interfaces<\/code>root@sol:~# echo 1 > \/proc\/sys\/net\/ipv4\/ip_forward<br \/>\nroot@sol:~# echo &#171;net.ipv4.ip_forward=1&#187; > \/etc\/sysctl.d\/99-ipfwd.conf<br \/>\n\u041f\u0435\u0440\u0432\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0435\u0441\u0441\u0438\u0438, \u0432\u0442\u043e\u0440\u0430\u044f &#8212; \u0441\u0442\u0430\u0432\u0438\u0442 \u0435\u0433\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043d\u0435 \u0441\u043b\u0435\u0442\u0435\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n<p><strong>3. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e iptables \u0434\u043b\u044f NAT.<\/strong><br \/>\n\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u0434\u0440\u0435\u0441:<br \/>\n<code>root@sol:~# iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 12.13.14.15<\/code><br \/>\n\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u0434\u0440\u0435\u0441:<br \/>\n<code>root@sol:~# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE<\/code><br \/>\n\u041e\u043d\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u0441\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u0430\u043c \u0432\u044b\u0445\u043e\u0434\u044f\u0449\u0438\u043c \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 eth0 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d \u0430\u0434\u0440\u0435\u0441 \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0430\u0434\u0440\u0435\u0441, \u043d\u043e \u044d\u0442\u043e \u043f\u043e\u043d\u0438\u0436\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0435\u043d. \u0422\u0430\u0431\u043b\u0438\u0446\u0430 iptables POSTROUTING \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0441\u043f\u0435\u0440\u0432\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043f\u0430\u043a\u0435\u0442 \u0438\u0434\u0435\u0442 \u043d\u0430\u0440\u0443\u0436\u0443, \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0435\u0442\u044c \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043d \u0435\u0433\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044c. \u041f\u0430\u043a\u0435\u0442\u044b \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0442\u0438 NAT \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0443\u0442.<\/p>\n<p><strong>4. \u041f\u0440\u043e\u043f\u0438\u0448\u0438\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441\u0435\u0442\u0438 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432.<\/strong><br \/>\n\u042d\u0442\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0432 \/etc\/lxc\/default.conf:<\/p>\n<pre class=\"code_block\">lxc.network.type = veth\r\nlxc.network.link = br0\r\nlxc.network.name = eth0\r\nlxc.network.flags = up<\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440:<br \/>\n<code>root@sol:~# lxc-create -t debian -n cnt0<\/code><\/p>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441\u0435\u0442\u0438 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 (\/var\/lib\/lxc\/cnt0\/config):<\/p>\n<pre class=\"code_block\">lxc.network.ipv4 = 172.16.1.13\/24 172.16.1.255\r\nlxc.network.ipv4.gateway = 172.16.1.1<\/pre>\n<p><strong>5. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u043d\u0430 \u043d\u0435\u043c \u0441\u0435\u0442\u044c.<\/strong><\/p>\n<pre class=\"code_block\">root@sol:~# lxc-start -n earth\r\nroot@sol:~# lxc-attach -n earth\r\nroot@earth:~# ping 8.8.8.8\r\nPING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.\r\n64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=1.29 ms\r\n64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=1.29 ms\r\n64 bytes from 8.8.8.8: icmp_seq=3 ttl=56 time=1.37 ms\r\n64 bytes from 8.8.8.8: icmp_seq=4 ttl=56 time=1.24 ms\r\n64 bytes from 8.8.8.8: icmp_seq=5 ttl=56 time=1.25 ms\r\n^C\r\n--- 8.8.8.8 ping statistics ---\r\n5 packets transmitted, 5 received, 0% packet loss, time 4005ms\r\nrtt min\/avg\/max\/mdev = 1.241\/1.291\/1.375\/0.060 ms\r\nroot@earth:~#<\/pre>\n<p><strong>6. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 iptables \u0434\u043b\u044f \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0430 \u043f\u043e\u0440\u0442\u043e\u0432.<\/strong><br \/>\n\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0432 iptables:<br \/>\n<code>root@sol:~# iptables -t nat -I PREROUTING 2 -i eth0 -p tcp -m multiport --dports=80,443 -j DNAT --to 172.16.1.13<\/code><br \/>\n\u041e\u043d\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e TCP-\u043f\u0430\u043a\u0435\u0442\u0430\u043c \u043d\u0430 \u043f\u043e\u0440\u0442\u044b 80 \u0438 443, \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0438\u043c \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 eth0, \u0430\u0434\u0440\u0435\u0441\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043d \u043d\u0430 172.16.1.13, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0434\u043b\u044f \u043d\u0438\u0445 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u0438. \u0413\u043b\u0430\u0437\u0430\u043c\u0438 \u044f\u0434\u0440\u0430 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<br \/>\n<em>1. &#171;\u041e, \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f \u043c\u0435\u043d\u044f (12.13.14.15) \u043d\u0430 80 \u043f\u043e\u0440\u0442!&#187;<br \/>\n2. &#171;\u041f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u0435\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0430 \u043d\u0430 172.16.1.13.&#187;<br \/>\n3. &#171;\u0422\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f \u0441\u0435\u0442\u0438 172.16.1.1\/24.&#187;<br \/>\n4. &#171;\u042d\u0442\u0430 \u0441\u0435\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u043a\u043e \u043c\u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 br0. \u0422\u0443\u0434\u0430 \u0435\u0433\u043e \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044e.&#187;<\/em><br \/>\n\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0438 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u043e\u0440\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0438\u0437\u0432\u043d\u0435.<\/p>\n<p><strong>7. \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 iptables.<\/strong><br \/>\n\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0444\u0430\u0435\u0440\u0432\u043e\u043b\u0430 \u043f\u043e\u0441\u043b\u0435 \u043f\u043b\u0430\u043d\u043e\u0432\u043e\u0439(?) \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0445 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c:<br \/>\n<code>root@sol:~# iptables-save > \/etc\/iptables\/rules.v4<\/code><\/p>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e! \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u043e\u043a \u0434\u043b\u044f \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0441\u0432\u043e\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432.<br \/>\n\u041a\u0441\u0442\u0430\u0442\u0438, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 Docker.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0438\u0441\u0447\u0435\u0440\u043f\u0430\u043d\u0438\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 ipv4 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0432\u0441\u0435 \u0431\u043e\u043b\u0435\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0442\u0435\u043c\u0430 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u0448\u0438\u043d \u0437\u0430 NAT. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432: 1. \u042d\u043a\u043e\u043d\u043e\u043c\u0438\u044f \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u043b\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043c\u0430\u0448\u0438\u043d; 2. \u0421\u043e\u043a\u0440\u044b\u0442\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 (\u0442. \u0435. \u0432\u0430\u0448\u0430 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u0430 \u0434\u043b\u044f \u043c\u0438\u0440\u0430). \u041e\u0434\u043d\u0430\u043a\u043e, \u043a\u0430\u043a \u0438 [&#8230;] <\/p>\n<p class=\"more-link-container\"><a href=\"https:\/\/qwertys.ru\/?p=91\" class=\"more-link\">Read More<span class=\"screen-reader-text\"> &#171;LXC \u0437\u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u043c NAT (Reverse NAT). \u041f\u043e\u0448\u0430\u0433\u043e\u0432\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f.&#187;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[17],"tags":[18,19,23,22],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/posts\/91"}],"collection":[{"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qwertys.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=91"}],"version-history":[{"count":6,"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/posts\/91\/revisions"}],"predecessor-version":[{"id":97,"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/posts\/91\/revisions\/97"}],"wp:attachment":[{"href":"https:\/\/qwertys.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=91"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qwertys.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=91"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qwertys.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}