Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] Network problems with Gentoo as KVM / virtio guest
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
fberger
Tux's lil' helper
Tux's lil' helper


Joined: 04 Dec 2006
Posts: 84
Location: Germany

PostPosted: Sun Aug 20, 2017 10:12 am    Post subject: [solved] Network problems with Gentoo as KVM / virtio guest Reply with quote

Hi,

I have been running a Gentoo server as a KVM guest with a cloud provider. So far I have 437 days uptime and no issues.

I now am trying to migrate that server to a different data center with the same provider. I took my usual course of action, which is:
  • attaching a new empty virtual drive to a temporary virtual server at the new location
  • rsyncing the old server to the new drive
  • chrooting
  • installing a boot loader
  • terminating the temporary virtual server
  • and firing up the new server.

The issue is that on the new server copy, I am unable to set up networking, i.e. setting a default route does not work.

I got a static IP and an associated default gateway from the cloud provider. I use /etc/conf.d/net for setup:
Code:
config_eth0="<IP>"
routes_eth0="default via <Gateway IP>"
dns_servers_eth0="<DNS IP> <DNS IP> <DNS IP>"

On the original virtual server, this works flawlessly.

On the new server, the device apparently boots up and gets assigned an IP, but there is a problem setting the default gateway:
Code:
* About to start the service net.eth0
* Bringing up interface eth0
*   Caching network module dependencies
*   <IP> ... [ok]
*   Adding routes
*     default via <Gateway IP> ... RTNETLINK answers: Network is unreachable
[ !! ]
[ !! ]

Subsequently, `ifconfig` shows eth0 as up and running with the IP assigned, but `route` shows no route, and adding yields:
Code:
$ route add default gw <Gateway IP>
SIOCADDRT: Network is unreachable

The underlying KVM uses a virtio setup to provide networking.

What baffles me is that the very same configuration is running flawlessly in the old datacenter.

I assume that the cloud provider uses the same software and setups across all the data centers.

I am not a very experienced network debugging person. Any hints how to approach this?


Last edited by fberger on Sun Aug 20, 2017 7:25 pm; edited 2 times in total
Back to top
View user's profile Send private message
mike155
Veteran
Veteran


Joined: 17 Sep 2010
Posts: 1004
Location: Frankfurt, Germany

PostPosted: Sun Aug 20, 2017 11:40 am    Post subject: Reply with quote

Your provider should have given you 1) an IP address 2) a local net (typically a netmask) and 3) a gateway. The IP address of the gateway must be inside the local net. If it's not, you get the message "Network is unreachable".

Check your interface settings and make sure that the gateway IP address is inside the local net of the interface.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 42596
Location: 56N 3W

PostPosted: Sun Aug 20, 2017 1:04 pm    Post subject: Reply with quote

bug_report,

Or you need a static route to the gateway.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
chiefbag
Guru
Guru


Joined: 01 Oct 2010
Posts: 542
Location: The Kingdom

PostPosted: Sun Aug 20, 2017 1:55 pm    Post subject: Reply with quote

Are you sure your new vm has eth0 as the interface?
If you have synced the image from another machine you may be now on eth1 as there will already be a udev entry for the old MAC address as eth0.
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1717

PostPosted: Sun Aug 20, 2017 3:20 pm    Post subject: Reply with quote

Quote:
I assume that the cloud provider uses the same software and setups across all the data centers.
Don't assume that. It's basically impossible to change an already deployed datacenter, so building a new datacenter is a good time to use all the knowledge you collected from your failures.

Quote:
default via <Gateway IP> ... RTNETLINK answers: Network is unreachable

You seem to have a wrong netmask. Can you set a route to your gateway manually?
Something like:
ip route add <gateway>/32 dev eth0
This command states your demands in a rather explicit way, so kernel shouldn't complain that it doesn't know what you tried to imply.
Back to top
View user's profile Send private message
fberger
Tux's lil' helper
Tux's lil' helper


Joined: 04 Dec 2006
Posts: 84
Location: Germany

PostPosted: Sun Aug 20, 2017 7:10 pm    Post subject: Reply with quote

Hey, thanks for the hints.

bug_report wrote:
Check your interface settings and make sure that the gateway IP address is inside the local net of the interface.

That was the first thing I checked. IP is x.y.z.239, gateway is x.y.z.1, so they should be on the same net.

chiefbag wrote:
Are you sure your new vm has eth0 as the interface?
If you have synced the image from another machine you may be now on eth1 as there will already be a udev entry for the old MAC address as eth0.

As I can bring up eth0 with the given IP, I suspect the current virtual networking devices is registered as eth0.

Also, I can bring up eth0 with `ifconfig`, while I cannot bring up an eth1 this way.

szatox wrote:
Don't assume that. It's basically impossible to change an already deployed datacenter, so building a new datacenter is a good time to use all the knowledge you collected from your failures.

True, but the provider explicitly advertises transfer of services between the datacenters, plus they all share the same web UI. It is possible, but not likely that the provider deploys different software below the virtual servers. I'll keep that investigation as a last resort, but I suspect the error to be somewhere else.

szatox wrote:
You seem to have a wrong netmask. Can you set a route to your gateway manually?
Something like:
ip route add <gateway>/32 dev eth0
This command states your demands in a rather explicit way, so kernel shouldn't complain that it doesn't know what you tried to imply.

Setting that works, and yields
Code:
$ route -n
Kernel IP routing table
Destination  Gateway  Genmask          Flags  Metric  Ref  Use  Iface
x.y.z.1      0.0.0.0  255.255.255.255  UH     0       0      0  eth0

As a result, I can ping the gateway. And subsequently I can set a default route via that gateway and access the internet. Yay! Thanks!

Now I have to figure out how to set the netmask correctly, and get a persistant configuration for that.
Back to top
View user's profile Send private message
fberger
Tux's lil' helper
Tux's lil' helper


Joined: 04 Dec 2006
Posts: 84
Location: Germany

PostPosted: Sun Aug 20, 2017 7:25 pm    Post subject: Reply with quote

Setting
Code:
config_eth0="<IP>/24"

in /etc/conf.d/net solves the issue. Thanks a ton!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum