Changes

Jump to: navigation, search

Using NAT for container with private IPs

222 bytes added, 21:57, 12 September 2015
no edit summary
net.ipv4.conf.all.forwarding=1</pre>
== How to provide access for create the container and attach network properties to Internet it ==
Create the container:  # prlctl create 100700 --vmtype ct Attach the internal IP address and DNS server:  # prlctl set 100700 --ipadd 192.168.0.101/24 # prlctl set 100700 --nameserver 8.8.8.8 Start the container:  # prlctl start 100700 == How to provide access for container to the Internet == To enable the [[container]]s, which have only internal IP addresses, to access the Internet, SNAT (Source Network Address Translation, also known as IP masquerading) should be configured on the [[Hardware Node]]. This is ensured by the standard Linux <tt>iptables</tt> utility.  To perform a simple SNAT setup, execute the following command on the [[Hardware Node]]:
<pre>
# iptables -t nat -A POSTROUTING -s src_net -o eth0 -j SNAT --to ip_address
</pre>
Or you can just use:
# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# iptables-save > /etc/sysconfig/iptables
# service iptables restart
 
=== Nameserver ===
 
Make sure in-CT nameserver is set. The easiest way to do it is:
 
# vzctl set $CTID --nameserver inherit
=== Test ===
Now you should be able to reach internet from your container(for Virtuozzo 6 only):
# vzctl exec $CTID ping openvz.org
91
edits

Navigation menu