How do I allow a container to access the internet?

imarceldoe

New Member
Jan 24, 2020
3
0
1
26
Hi, sorry for the basic question -- but I'm having trouble getting my container to successfully ping 8.8.8.8

I'm a total newbie by the way, so I would appreciate any patience and guidance. I've tried to do some reading and watching some videos but it's sorta going over my head.

Currently I have these default settings for the device
1579905086712.png

And these for the bridge:
1579905114168.png

Could somebody guide me on what to enter to get my container to be able to connect to the internet?
 
You have configured your container to use "Static IP" but did not configure a static IP address (plus CIDR) nor a gateway. A container will need a working IP configuration either provided by you or by a DHCP server. Also note that it cannot use the same IP address as the host.

So what you will need to do (please search the forum) is for example:

a) Add another vmbr1 interface which is configured with a private IP address on the host side and bridge (or even route) this interface with/to vmbr0. Alternatively, add a private IP address as a secondary IP to vmbr0.
b) Configure the container to use the vmbr interface with the newly added private IP address and give the container another IP address in the same private network and use the host private IP as gateway
c) Implement NAT so that this network is NATed to the public IP address on vmbr0 when trying to reach the Internet
d) Make sure the nameservers configured in /etc/resolv.conf on the host will be reachable by the container

Have fun!
 
  • Like
Reactions: imarceldoe
You have configured your container to use "Static IP" but did not configure a static IP address (plus CIDR) nor a gateway. A container will need a working IP configuration either provided by you or by a DHCP server. Also note that it cannot use the same IP address as the host.

So what you will need to do (please search the forum) is for example:

a) Add another vmbr1 interface which is configured with a private IP address on the host side and bridge (or even route) this interface with/to vmbr0. Alternatively, add a private IP address as a secondary IP to vmbr0.
b) Configure the container to use the vmbr interface with the newly added private IP address and give the container another IP address in the same private network and use the host private IP as gateway
c) Implement NAT so that this network is NATed to the public IP address on vmbr0 when trying to reach the Internet
d) Make sure the nameservers configured in /etc/resolv.conf on the host will be reachable by the container

Have fun!

I’m using SoYouStart. In order to get the secondary IP for the container, do I have to buy it from them?

Can this be done through the GUI, by the way?
 
Last edited:
Like I mentioned, add a "private IP address" within one of the following RFC1918 ranges:

10.0.0.0 - 10.255.255.255 (10/8 prefix)
172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
192.168.0.0 - 192.168.255.255 (192.168/16 prefix)

No, secondary IPs need to be added in /etc/network/interfaces unless you add a new bridge, which can be done in the GUI.
 
  • Like
Reactions: imarceldoe
Like I mentioned, add a "private IP address" within one of the following RFC1918 ranges:

10.0.0.0 - 10.255.255.255 (10/8 prefix)
172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
192.168.0.0 - 192.168.255.255 (192.168/16 prefix)

No, secondary IPs need to be added in /etc/network/interfaces unless you add a new bridge, which can be done in the GUI.

Which route would you say is optimal? Adding a new bridge or adding it in the /etc/network/interfaces?

By adding a "private IP address" do you mean just assigning it in the GUI?

Is there a video or guide on this? This is sort of going over my head, unfortunately. I'm just trying to get Linux containers that can connect to the internet and run applications :(

I understand how to edit /etc/network/interfaces but I'm not sure what should go in each line.
 
Last edited:
I'd do this with a new bridge, it would add more flexibility later. Doing this with a secondary IP is easier though, so try that first.

I haven't searched the forum or the Internet for you, there may be a video or someone else has opened a similar post on the forum. This kind of configuration will require you to use the linux console either way and thus would demand that you have knowledge about how to configure networking and iptables on Debian based Linux.

You need to google how to add a secondary IP in Debian to an existing interface in /etc/network/interfaces. You need to make up your mind which network you are going to use, e.g. 192.168.234.0/24, so the secondary IP would be 192.168.234.1, and your VMs would use other IPs inside that network. You need to setup NAT (masquerading) to masquerade this network to your public IP, I'd use the package iptables-persistent. And finally, you need to edit the containers and add proper static IP configuration.
 
Which route would you say is optimal? Adding a new bridge or adding it in the /etc/network/interfaces?

By adding a "private IP address" do you mean just assigning it in the GUI?

Is there a video or guide on this? This is sort of going over my head, unfortunately. I'm just trying to get Linux containers that can connect to the internet and run applications :(

I understand how to edit /etc/network/interfaces but I'm not sure what should go in each line.
Hi,
I do not know if you are aware of this, but there are some example network configurations in the docs.
This might be helpful https://pve.proxmox.com/pve-docs/pve-admin-guide.html#sysadmin_network_configuration
You probably want to use the NAT setup where you have one single public IP and the private network (e.g. 10.10.10.0/24) where your containers reside.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!