The Gluster Blog

Gluster blog stories provide high-level spotlights on our users all over the world

Static IPs on KVM + (minimal) Fedora 16 installation

Gluster
2013-03-26

Getting networking to work the way you want it to in a VM can be scary sometimes.
 
I recently found it was tricky to have both a STATIC IP as well as internet connectivity inside of KVM provisioned VMs.   The ultimate reason was that the “GATEWAY” field was not being set right. 

The moral of the story:  On KVM boxes, when bridging in a virtual network, the virt managed default bridged IP address needs to be set as the gateway… Thus, when your guests are in a “virtual network” – the “gateway” is the internal IP address provided to them by the hypervisor that represents the “outside” of their internal network.   

1) Stop the firewalls in iptables:

         iptables -F

2) Edit /etc/sysconfig/network-scripts/ifcfg-eth0 like so (obviously the “IPADDR” can be anything you want as long as its in the right range.

DEVICE=”eth0″

HWADDR=”52:54:00:94:AF:F4″

BOOTPROTO=”static” <— Change this from “dhcp” to “static”

ONBOOT=”yes”

NM_CONTROLLED=”yes”

IPADDR=192.168.122.171 <— this is any old arbitrary IP in-range.

NETMASK=255.255.255.0

GATEWAY=192.168.122.1 <— this is aliased ipaddress of your host inside of KVM.

USERCTL=”no”

3) Restart networking so that the IP and GATEWAY can be reset.

       service network restart

4) Ping somebody and watch the magic unfold:

       ping www.yahoo.com

Yay!

If you get a “Destination Host Unreachable”: 

Your gateway is wrong.   Make sure your gateway is the same as your host vm’s ipaddress. 
 

If you get an unknown host: 

You may not have an assigned IP (IPADDR wrong or out of range).

A strange note to keep in mind — somehow, even with a bad gateway (i.e. destination host unreachable), I could still resolve hostnames – not sure why. 

BLOG

  • 06 Dec 2020
    Looking back at 2020 – with g...

    2020 has not been a year we would have been able to predict. With a worldwide pandemic and lives thrown out of gear, as we head into 2021, we are thankful that our community and project continued to receive new developers, users and make small gains. For that and a...

    Read more
  • 27 Apr 2020
    Update from the team

    It has been a while since we provided an update to the Gluster community. Across the world various nations, states and localities have put together sets of guidelines around shelter-in-place and quarantine. We request our community members to stay safe, to care for their loved ones, to continue to be...

    Read more
  • 03 Feb 2020
    Building a longer term focus for Gl...

    The initial rounds of conversation around the planning of content for release 8 has helped the project identify one key thing – the need to stagger out features and enhancements over multiple releases. Thus, while release 8 is unlikely to be feature heavy as previous releases, it will be the...

    Read more