New ip with different gateway

ienemy

Member
May 12, 2017
3
1
21
32
Hi,

So the issue im having is that i have 2 different /24 as follows:

xxx.xxx.250.0/24
xxx.xxx.20/24

the xxx.xxx.250.0 is the main vmbr 0 and works great including inside all the VMs they get ips etc no problem there, however, i have added a vmbr1 with the xxx.xxx.20.0 and this has the gateway of .20.1 not the same as vmbr0

here is my interfaces:

Code:
auto lo
iface lo inet loopback

iface eth0 inet manual

iface eth1 inet manual

iface eth2 inet manual

iface eth3 inet manual

auto vmbr0
iface vmbr0 inet static
        address  xxx.xxx.250.223
        netmask  255.255.255.0
        gateway  xxx.xxx.250.1
        bridge_ports eth0
        bridge_stp off
        bridge_fd 0

auto vmbr1
iface vmbr1 inet static
        address  xxx.xxx.20.80
        netmask  255.255.255.0
        bridge_ports none
        bridge_stp off
        bridge_fd 0

Now the strange thing is that i can ping from my home pc the .20.80 fine but try to ping out won't work for example:

ping -I vmbr1 8.8.8.8
From xxx.xxx.20.80 icmp_seq=1 Destination Host Unreachable

Any help would be much appreciated.
 
The ping above will not be using any gateway and will try to discover 8.8.8.8 via ARP (as if it were in the local network).
If you merely want to test the second connection however, you can do this with an additional routing table and a rule for traffic sent out via vmbr1, like this:
Code:
# ip route add table 100 default via xxx.xxx.20.1
# ip rule add oif vmbr1 table 100
This will utilize an additional routing table (id 100), give it a default route in your vmbr1's network, and add a rule that causes outgoing traffic on vmbr1 to use the .20.1 gateway.

But generally, while you can have multiple public ip addresses, you usually only have one main gateway to the outside, so most connections will stick to using vmbr0 here.