![]() |
IPv6 Networking and LXC Containers - Printable Version +- Post4VPS Forum | Free VPS Provider (https://post4vps.com) +-- Forum: VPS Discussion (https://post4vps.com/Forum-VPS-Discussion) +--- Forum: Tutorials (https://post4vps.com/Forum-Tutorials) +--- Thread: IPv6 Networking and LXC Containers (/Thread-IPv6-Networking-and-LXC-Containers) |
IPv6 Networking and LXC Containers - Mr.Monkey - 06-04-2017 For some of us, we like to keep things good and organized. We like to keep tabs on different containers, that could very well be running apps that might be incompatible or a headache to others. To some of us, we'd like to keep other users isolated if we share our main host. Setting LXC networking can a be a little cumbersome, if not, maddening if you do not have one of the distros that automatically set the networking interface for containers. (Most Debian and Ubuntu distributions set up a NAT interface for you). (from here, we assume you've installed LXC 1.0 or any 1.# version) 1.Introduction: Let us say that you have a distribution that doesn't have the packages that automatically set lxcbr0 or another interface to NAT and network containers on. A example configuration is shown below, written in /etc/default/lxc-net Code: USE_LXC_BRIDGE="true" Code: systemctl enable lxc-net 2. Introduce IPv6 to containers. Once you've gotten a container online with its own IPv4 network, you can setup and even make IPv6 only containers. To check the current containers, and their addresses, you can use the Code: lxc-ls --fancy Example output: Code: NAME STATE IPV4 IPV6 AUTOSTART Before we dive in, bringing the holy version 6 of networking to your young containers, we need to even CHECK if you have IPv6. Some providers offer native IPv6, but others do not. This guide will only apply to those who receive a routed prefix such as a /64. Many providers offer single /128 (or 1 IPv6) and can request some more, but this guide will be for networking as a whole prefix, and quite frankly I've never dealt with that before. Commonly systems that are more than capable to being conatiner'd (and worth to be conainter'd) usually are offered a /64 to /48s. 2.2 The Hurricane Electric tunnel. Let us assume that you do not have a IPv6 prefix routed to your container, and resort to the use of a tunnel. If you do, we are going to have to make some notes on the website. (We are going to assume that you've already successfully tunneled IPv6 to your system) In this example, I am using this picture I found on the internet because I managed to lock myself out of my account while making this: ![]() What we need to pay attention to is, Routed /64 and Client IPv6 address. Now, we are going to check your ifconfig, which in this exmaple is this: Code: he-ipv6 Link encap:IPv6-in-IPv4 To help understand this, I've made this diagram: Code: .-~~~-. Code: sysctl -w net.ipv6.conf.all.forwarding=1 Code: .-~~~-. See that we needed to address lxcbr0 a address to make it a gateway for the containers. How? We do these two commands Code: ip a a 2001:470:23:37e::1 dev lxcbr0 # adds a address to lxcbr0 Code: iface eth0 inet6 static And, restart networking. If all goes well, a simple ping6 google.com should give you results. 2.3 Native IPv6 connections. This guide is going to assume you have the bear minimum of a /64. Although this could very well be done with other amounts, a /64 is ideal within the RFCs rules for networking. It is the same principle, but you have to note of your routed netmask or amount of IPv6. In this case, it is as copy paste as before. You need to find your routed IPv6 address(es). The diffrence here is that you are not routed another prefix in between another: Code: .-~~~-. To check the addresses you can and cannot address, use this tool: http://www.gestioip.net/cgi-bin/subnet_calculator.cgi Example: My example ifconfig (in this case, I am offered a /112) Code: eth0 Link encap:Ethernet HWaddr 02:00:c0:a8:64:4b ![]() Usually, the network interface will always start with the first address listed. So, use the second address to assign to it to the lxcbr0 interface. The size of the network is shown after the address within ifconfig. Code: inet6 addr: 2001:41d0:1:777c:200:xxx:xxx:0/112 So, then, we substitute the address and sizes into the following commands. Code: ip a a 2001:41d0:1:777c:200:xxx:xxx:1/112 dev lxcbr0 # act as gateway for containers Troubleshooting: If you have a no route to host problem, make sure that ALL traffic is correctly gateway'd. If there is no route to host within the host system, and pinging outside of the system does not work, try: Code: ip r a 2000::/3 via (he-ipv6's address, or eth0 address for native connections) Check if you can ping the lxcbr0 interface, if you can't, you've incorrectly setup the IPv6 connection somewhere between the container and host system. If the container can ping the host system, via the gateway (or can ping the gateway), then try this command within the container: Code: ip r a 2000::/3 via (container's IPv6 gateway) |