Hello,
I already have a virtual machine with its own public ip address and I would like to set up a new VM using port forwarding from the host.
I have two public addresses:
Currently, I have the following network configuration:
In order to setup the port forwarding for the second virtual machine (10.0.2.15), I added a new bridge on the host like this:
and I linked my virtual machine to the vmbr2 bridge.
but it doesn't work and, as I'm a newbie with the network, I don't know what is wrong.
Any help is welcome.
Thank you in advance.
I already have a virtual machine with its own public ip address and I would like to set up a new VM using port forwarding from the host.
I have two public addresses:
- X.X.X.146 for the host
- Y.Y.Y.99 for the first virtual machine
Currently, I have the following network configuration:
- /ect/network/interfaces (host)
Code:
# cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto vmbr0
iface vmbr0 inet static
address X.X.X.146
netmask 255.255.255.224
gateway X.X.X.129
bridge_ports eth0
bridge_stp off
bridge_fd 9
bridge_hello 2
bridge_maxage 12
- /ect/network/interfaces (vm with public IP address)
Code:
# cat /etc/network/interfaces
auto eth0
iface eth0 inet static
address Y.Y.Y.99
netmask 255.255.255.248
pointopoint Y.Y.Y.97
gateway Y.Y.Y.97
dns-nameservers 8.8.8.8 8.8.4.4
In order to setup the port forwarding for the second virtual machine (10.0.2.15), I added a new bridge on the host like this:
Code:
auto vmbr2
iface vmbr2 inet static
address 10.0.2.254
netmask 255.255.255.0
bridge_ports none
bridge_stp off
bridge_fd 0
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '10.0.2.0/24' -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '10.0.2.0/24' -o vmbr0 -j MASQUERADE
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 2222 -j DNAT --to 10.0.2.15:22
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 2222 -j DNAT --to 10.0.2.15:22
but it doesn't work and, as I'm a newbie with the network, I don't know what is wrong.
Any help is welcome.
Thank you in advance.