Answer the question
In order to leave comments, you need to log in
Proxmox and container with internal network
What I'm trying to do:
Create a container, with an IP such as 192.168.2.2, so that it has access to the Internet and then forward the port to it from the host machine.
What I did:
Started a container, in it bridge1 c 192.168.2.1
network parameters are as follows:
# Auto generated lo interface
auto lo
iface lo inet loopback
# Auto generated venet0 interface
auto venet0
iface venet0 inet manual
up ifconfig venet0 up
up ifconfig venet0 127.0.0.2
up route add default dev venet0
down route del default dev venet0
down ifconfig venet0 down
iface venet0 inet6 manual
up route -A inet6 add default dev venet0
down route -A inet6 del default dev venet0
auto venet0:0
iface venet0:0 inet static
address 192.168.2.2
netmask 255.255.255.255
# network interface settings
auto lo
iface lo inet loopback
iface eth0 inet manual
broadcast 155.76.167.159
up route add -net 155.76.167.128 netmask 255.255.255.224 gw 155.76.167.129 eth0
# default route to access subnet
auto vmbr0
iface vmbr0 inet static
address 155.76.167.155
netmask 255.255.255.224
gateway 155.76.167.129
bridge_ports eth0
bridge_stp off
bridge_fd 0
auto vmbr1
iface vmbr1 inet static
address 192.168.2.1
netmask 255.255.255.0
bridge_ports eth0
bridge_stp off
bridge_fd 0
Answer the question
In order to leave comments, you need to log in
Smoke man iptables
on the hypervisor do the following:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to external_ip_on_hypervisor
(and where eth0 is the external IP interface on the hypervisor )
this will give us the Internet on all containers
, then we forward ports using the example of port 25
iptables -t nat -A PREROUTING -p tcp -d external_ip --dport 25 -j DNAT --to-destination local_ip_container:25
iptables -A FORWARD -i eth0 -d external_IP -p tcp --dport 25 -j ACCEPT
Then you need to make sure that all these rules do not fly off on reboot
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question