I have a bunch of virtual machines (Ubuntu Server 14.04) hosted on a single real server (Ubuntu Server 14.04 with KVM). The number of virtual machines grow, and I'll soon have more than 254 of them.
To test,
I changed in
/etc/network/interfaces
of the real server the netmask from255.255.255.0
to255.255.254.0
. The IP address of the real server is192.168.1.30
.I did the similar operation with
virsh net-edit default
, which changed the netmask ofvirbr0
to255.255.254.0
.I changed the netmask of the switch to
255.255.254.0
as well.I changed the configuration of the test virtual machine like this:
auto eth0 iface eth0 inet static address 192.168.2.35 netmask 255.255.254.0 network 192.168.1.0 broadcast 192.168.2.255 gateway 192.168.1.1 dns-nameservers 192.168.1.13 dns-search example.com
This is the current state:
I can't ping
192.168.2.35
from the real server: it is just stuck at "PING 192.168.2.35 (192.168.2.35) 56(84) bytes of data." When stopped (Ctrl+C), it complains: "143 packets transmitted, 0 received, 100% packet loss, time 142134ms".The virtual machine
192.168.2.35
can't ping anything (neither the switch, nor the real server, nor google.com), throwing "connect: Network is unreachable" error for the first two, or "ping: unknown host google.com" for the last one.The virtual machine can ping itself.
What's wrong with my configuration?
Because you have calculated your subnets wrong, and you are trying to use IPs from two different subnets.
Or to put it a different way, if you use a /23 bit mask your starting address for the range, must be the first address for that range. 192.168.1.1 is not a starting address for any network described by a 23 bit mask, because that is just how the math works out.
With a 23 bit mask the valid networks are the following.
In your interface configuration though you seem to have
address 192.168.2.35
, andgateway 192.168.1.1
. Given that mask your gateway and address are on completely separate subnets. Of course your broadcast and network address settings are also incorrect.If you use a 22 bit mask you will get a range that includes 192.168.1.x and 192.168.2.x. Be warned that your broadcast, and network values are still wrong, they also need to be fixed.