Port Forward setup for LXC

QNAP NAS solution for server virtualization and clustering/HA/FT
Post Reply
First post
Posts: 1
Joined: Fri Jun 19, 2009 12:02 pm

Port Forward setup for LXC

Post by veryniceworld » Tue Oct 13, 2015 5:26 pm

Glad to see that QNAP including the docker and lxc support starting from QTS 4.2. Just imported the LXC of ubuntu 14.04 for testing. It is using a NAT subnet for the container by default. Seem that there is no way to change it to bridge network. May I ask the how to setup port forward?



Starting out
Posts: 41
Joined: Fri Oct 31, 2014 5:43 am
Location: Germany - DD

Re: Port Forward setup for LXC

Post by tobilux » Mon Oct 19, 2015 12:18 am

Hi Mac,

Did you solve this?

I want to run Jenkins in a container that uses my NAS' SVN server with svn:// Syntax. However, all containers I tried (Jenkins, Ubuntu) cant't even ping my NAS' IP. Seems the containers do get a 10.30.x.x IP while my NAS is on 192.168.178.x.

QNAP TS-451 Firmware 4.2.0 b0925

Starting out
Posts: 16
Joined: Wed May 13, 2015 10:13 am

Re: Port Forward setup for LXC

Post by solamar » Sun Nov 08, 2015 4:57 pm

I'm wondering; looks like once you create a container, you cannot change the port forwards? at least not in the UI...

Nice .. but limited

User avatar
New here
Posts: 2
Joined: Wed Feb 08, 2017 4:32 am

Re: Port Forward setup for LXC

Post by demure » Wed Feb 08, 2017 4:46 am

I know I'm double posting this (different thread), but this thread is the top google hit, so:

I did some digging, and you can manually fix it from the command line.
In my case, I was using an lxc, which will be named 'debian'.

Code: Select all

(where CHACHEDEV1 is the root of my raid6, and 'debian' is the root of the image), you will find a qnap.json.

Here is a 'bad' file:

Code: Select all

{"volume": {"new": [], "host": {}, "container": []}, "version": "8", "resource": {"device": [], "limit": {}}, "name": "deleteme", "autostart": true, "arch": "amd64", "image": "debian-jessie", "type": "lxc", "network": {"hostname": "debian", "port": [], "mode": "nat"}}

And here is one with a working port forward readded:

Code: Select all

{"volume": {"new": [], "host": {}, "container": []}, "version": "8", "resource": {"device": [], "limit": {}}, "name": "deleteme", "autostart": true, "arch": "amd64", "image": "debian-jessie", "type": "lxc", "network": {"hostname": "deleteme", "port": [[1111, 22, "TCP"]], "mode": "nat"}}

Format of

Code: Select all

[[1111, 22, "TCP"]]
is EXTERIOR, CONTAINER, tcp/udp. I didn't bother to dig into multiple, but I assume it would be

Code: Select all

[[FIRST], [SECOND], [ETC...]]

First post
Posts: 1
Joined: Wed Apr 12, 2017 8:10 pm

Re: Port Forward setup for LXC

Post by mchakrab » Sun Apr 23, 2017 5:59 am

demure -- thanks for digging.

Confirmed that multiple ports are in the format you specified:

Code: Select all

 "network": {"port": [[11, 11, "TCP"], [12, 12, "UDP"]], "mode": "nat"}}

would forward TCP 11 and UDP 12 from host to container.

Post Reply

Return to “Server Virtualization & Clustering”