'

[SOLVED] CentOS 6 networking and Hyper-V.

March 1st, 2012 by Andrea Matesi 23386 Views

Recently I have been playing with CentOS on Hyper-V. My personal opinion is that both products are great.

My lab is made of:

  •     Microsoft Windows Server 2008 R2 w/SP1.
  •     Hyper-V Role enabled.
  •     CentOS 6.2 x64 minimal iso.
  •     Linux Integration Services for Hyper-V version 3.2 w/ synthetic drivers.

I experienced networking problems while CentOS was booting, more specifically:

/var/log/dmesg:eth0: Dropping NETIF_F_SG since no checksum feature.
/var/log/messages:Mar  1 11:00:25 pwrusrdev1 kernel: eth0: Dropping NETIF_F_SG since no checksum feature.

This specific issue seems related to the fact that the "Checksum offload feature" is missing from the virtual ethernet interface. But since we're speaking about a virtual interface, and the feature we're talking about is a hardware feature, implemented by manufacturers such as intel inside their ethernet silicon to offload the Checksum calculations from the CPU, consider this thing just a naggie and no more.

CentOS minimal doesn't have a gui, so no network config here, but I can live with that :)

Now many people are wondering "why CentOS minimal" and "CentOS minimal sucks", but on my next article series I'm gonna show you how great CentOS minimal is and how to put this smart Linux distribution to good use.

Consider this article as an entréé on CentOS6-minimal networking configuration.

So, I was configuring networking by creating a _single_ config file inside /etc/sysconfig/network-scripts/ifcfg-eth0
with the following lines:

nano /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
NETWORK=192.168.1.0
NETMASK=255.255.255.0
IPADDR=192.168.1.4

As you can see, I was trying to setup a static IP address on eth0. But generating only this file for CentOS networking simply isn't enough.

[UPDATE 03/APR/2012]: After Mr. Matt Gorecki comment, I've researched a more viable and efficient alternative and I've found a very clever description from Mr. Mark Wagner at the following address: http://serverfault.com/questions/189445/what-is-the-order-of-precedence-for-redhat-network-configuration-files.

Basically, he explains that CentOS Network Manager scripts create hard links instead of what I suggested.

My original description was (ignore it!):

You'll have to copy this file inside 2 other directories, like so:

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/networking/devices/
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/networking/profiles/default/

And make sure their permissions are set correctly, like so:

chmod 644 /etc/sysconfig/network-scripts/ifcfg-eth0
chmod 644 /etc/sysconfig/networking/devices/ifcfg-eth0
chmod 644 /etc/sysconfig/networking/profiles/default/ifcfg-eth0

The following is my new explanation (follow it!):

Since CentOS scripts seems to create hard links when defining ethernet devices, to maintain uniformity with what CentOS does, you can:

ln /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/networking/devices/ifcfg-eth0
ln /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/networking/profiles/default/ifcfg-eth0

Once this is done, you'll have to name you computer with the hostname command:

hostname my-system-name

Then you need to edit another file, /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=my-system-name
GATEWAY=192.168.1.1

Save and set its permissions to 644 like so:

chmod 644 /etc/sysconfig/network

Reboot and your networking should be working just fine.

Bonus: once we're at it, let's set up name resolution! Open /etc/resolv.conf and input a "nameserver statement" like this:

nameserver 192.168.1.1

Posted in LINUX, Microsoft, System Administration | 18 Comments »

18 responses to “[SOLVED] CentOS 6 networking and Hyper-V.”

  1. f0yNo Gravatar says:

    Thanks! I am newbie in CentOS and your article was very helpful!

  2. Matt GoreckiNo Gravatar says:

    Copying the files to /device and /profiles isn't necessary.
    /etc/sysconfig/network is the critical file that isn't created by default.

    • amatesiNo Gravatar says:

      Hello Matt and thanks for your comment, according to your suggestion, I’ve researched for a more efficient alternative, I tested it and I’ve amended my article.

  3. Luis FreitasNo Gravatar says:

    My congratulations. .
    optimal solution!

  4. MilenaNo Gravatar says:

    Perfect. Thank you.

  5. NickNo Gravatar says:

    This might be a bit easier-
     
    Install with both NICs attached, install the HyperV IC.
    Shutdown, remove the Legacy Adaptor, reboot.
    Modify /etc/sysconfig/network-scripts/ifcfg-eth0 to match the MAC of the full-speed NIC
    Modify /etc/udev/rules.d/70-persistent-net.rules as follows:
    The first device (usually "tulip", change the mac addr to match the full-speed NIC.
    Comment out the "SUBSYSTEM" line underneath.
    Save that file, and run this command:
    chattr +i /etc/udev/rules.d/70-persistent-net.rules
    Reboot. Fixed!

    • RoarNo Gravatar says:

      Thanks Nick, that worked for me.  If you've persisted in getting eth0 to show up without the IC installed you probably end up where I did.  Install the IC (v3.4 for me) and follow Nick's guide.

  6. […] me suis inspiré de cet article avec une ou 2 […]

  7. […] following looks similar to your situation; http://www.pwrusr.com/system-adminis…ng-and-hyper-v Although, since I'm not "The Help," I don't do […]

  8. SohailNo Gravatar says:

    after going to this solution, my network is working..

  9. SohailNo Gravatar says:

    you can simple make empty HWADDR field in /etc/sysconfig/network-Scripts/ifcfg-eth0,
    as
    HWADDR=

  10. bazNo Gravatar says:

    great great great! thanks!

  11. DrmanhattanNo Gravatar says:

    Just Install Linux Integration Services. Download Linux Integration Services ISO file from Microsoft’s Website.

  12. zeroangleNo Gravatar says:

    Great find. Also want to note that if you run legacy network adapters with more then one processor assigned to the vm, you loose network completely, even with LIC 3.4 installed.

  13. LeoNo Gravatar says:

    thank’s a lot, very useable article!

  14. FloodNo Gravatar says:

    For me, I had to use eth1 instead of eth0.

    To know that, you can try

    ifconfig eth0
    ifconfig eth1

    you see which one works…

    To restart the network, simply type

    service network restart

  15. MaxsuelNo Gravatar says:

    You Sir, just save my day. Thank you ;)