Creating internal network with multiple public ips

Tetrabyte

New Member
Jan 8, 2019
2
0
1
24
Okay so I have setup so I can have an internal private network accept connections in and send connections out through a specific public IP in my block. (Seen in the config below)

I have two ip blocks and I want to use an ip from the other block, that block being the block the system was rented with (the main block) but for some reason I cannot get any IPs from the main block 69.x.x.x to work.

All the IPs in the 63.x.x.x block work fine with this config.


Code:
auto lo
iface lo inet loopback

allow-hotplug eth0

iface eth0 inet static
        broadcast 69.*.*.207
        network 69.*.*.200

auto vmbr0
iface vmbr0 inet static
        address  69.*.*.202
        gateway  69.*.*.201
        netmask  255.255.255.248
        bridge-ports eth0
        bridge-stp off
        bridge-fd 0

# 63.*.*.142 <-> 10.0.1.0
auto vmbr1
iface vmbr1 inet static
        address 10.0.1.254
        netmask 255.255.255.0
        bridge-ports none
        bridge-stp off
        bridge-fd 0

        # Enable ip forwarding on the Host OS
        post-up echo 1 > /proc/sys/net/ipv4/ip_forward

        # Create POST/PREROUTING rules on interface up
        post-up iptables -t nat -A PREROUTING -s 10.0.1.0/24 -i vmbr0 -j DNAT --to 63.*.*.142
        post-up iptables -t nat -A POSTROUTING -s 10.0.1.0/24 -o vmbr0 -j SNAT --to-source 63.*.*.142
        post-up iptables -t nat -A POSTROUTING -s '10.0.1.0/24' -o vmbr0 -j MASQUERADE

        # Remove POST/PREROUTING rules on interface down
        post-down iptables -t nat -D PREROUTING -s 10.0.1.0/24 -i vmbr0 -j DNAT --to 63.*.*.142
        post-down iptables -t nat -D POSTROUTING -s 10.0.1.0/24 -o vmbr0 -j SNAT --to-source 63.*.*.142
        post-down iptables -t nat -D POSTROUTING -s '10.0.1.0/24' -o vmbr0 -j MASQUERADE

        # Forward port 80 on public IP to 10.0.1.2
        post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 80 -j DNAT --to 10.0.1.2:80
        post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 80 -j DNAT --to 10.0.1.2:80

This is the config that does not work (The one attempting to use 69.*.*.205 in the same way)

Code:
auto lo
iface lo inet loopback

allow-hotplug eth0

iface eth0 inet static
        broadcast 69.*.*.207
        network 69.*.*.200

auto vmbr0
iface vmbr0 inet static
        address  69.*.*.202
        gateway  69.*.*.201
        netmask  255.255.255.248
        bridge-ports eth0
        bridge-stp off
        bridge-fd 0

# 69.*.*.205 <-> 10.0.1.0
auto vmbr1
iface vmbr1 inet static
        address 10.0.1.254
        netmask 255.255.255.0
        bridge-ports none
        bridge-stp off
        bridge-fd 0

        # Enable ip forwarding on the Host OS
        post-up echo 1 > /proc/sys/net/ipv4/ip_forward

        # Create POST/PREROUTING rules on interface up
        post-up iptables -t nat -A PREROUTING -s 10.0.1.0/24 -i vmbr0 -j DNAT --to 69.*.*.205
        post-up iptables -t nat -A POSTROUTING -s 10.0.1.0/24 -o vmbr0 -j SNAT --to-source 69.*.*.205
        post-up iptables -t nat -A POSTROUTING -s '10.0.1.0/24' -o vmbr0 -j MASQUERADE

        # Remove POST/PREROUTING rules on interface down
        post-down iptables -t nat -D PREROUTING -s 10.0.1.0/24 -i vmbr0 -j DNAT --to 69.*.*.205
        post-down iptables -t nat -D POSTROUTING -s 10.0.1.0/24 -o vmbr0 -j SNAT --to-source 69.*.*.205
        post-down iptables -t nat -D POSTROUTING -s '10.0.1.0/24' -o vmbr0 -j MASQUERADE

        # Forward port 80 on public IP to 10.0.1.2
        post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 80 -j DNAT --to 10.0.1.2:80
        post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 80 -j DNAT --to 10.0.1.2:80
 
Hi,

I guess your second IP block has another gateway?
If so you have to set the route manual.
 
Yes both of my blocks have a different gateway

Correct me if I'm wrong but I'm going to need a different interface for that I presume for the second block?

The odd part about that is the main ip block of the system (The one that is defined at the top in vmbr0 and eth0) is the one that is having issues.

The second block that does not have any definition in the file at all besides in this new interface works fine.
 

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!