Route IPs from a different subnet

rcbg

New Member
Jan 31, 2012
3
0
1
I know this question has been answered in a couple of threads but in my setup I'm not able to get it to work.

Here is how its setup.

I have vlan438 setup on my cisco 3750 switch.

I have the subnet assigned 10.4.4.64/30 to vlan438

vmbr0 has the IP 10.4.4.66 and the gateway 10.4.4.65.

I can access proxmox control panel, ssh etc etc...all fine.

I routed a 10.6.6.176/29 to vlan438...so I can assign IPs from .177 -> .182 to 6 usable IPs to 6 different VMs. Their default gateway is 10.4.4.65.

I can confirm the routed IPs are working because when I assign any IP from the 19.6.6.176/29 range to the node itself I can ping and access it fine.

I created a VM (VM1) with vmbr0 as the network and when I assign IP 10.6.6.177 to VM1 I CANNOT access it.

So on the node (10.4.4.66) I added the route..."route add -net 10.6.6.176 netmask 255.255.255.248 dev vmbr0" and I still cant access the VM1.

When I try to add a default gateway on VM1 (10.6.6.177) "route add default gw 10.4.4.65" I get the error "SIOCADDRT: No such process"...and I cant ping 10.4.4.65 from inside VM1...nor I can ping 10.6.6.177 from the node itself.

FORGOT TO MENTION: All these are KVM based VMs....

Anything I am missing here? Thanks.
 
Last edited:
I figured out the problem...looks like the primary IP (main IP) assigned to the VM must have a gateway in the same subnet as well.

For example if the main IP of the VM is 10.6.6.178...the gateway has to be in the 10.6.6.xxx range.

Once that requirement is met I can "ip route" on the cisco any number additional subnets and the VM is able to see them.

Initially the 10.6.6.176/29 subnet was routed via "ip route 10.6.6.176 255.255.255.248 vlan438"....so instead of that I added the subnet as secondary as such "ip add 10.6.6.177 255.255.255.248 secondary" (dont forget the "secondary" or it will overwrite the primary subnet..in this case 10.4.4.64/30). So the gateway is 10.6.6.177 and the VM was assigned IP 10.6.6.178. The main node's IP is still 10.4.4.66 with gateway 10.4.4.65.

Now I could route subnet 10.7.7.0/24 as such "ip route 10.7.7.0 255.255.255.0 vlan438" and I was able to assign any IP in that subnet to VM1.
 
Also...just to clarify...I did NOT use the "route add" commands on either the node or the VM itself. All changes were done on my cisco router.