1

The obvious answer is yes, I suppose, but my VPS provider doesn't seem to agree.

I've just uploaded a Ubuntu 20.04 instance, and the provider is telling me:

IP address: 77.xxx.yyy.zzz/32
Gateway: 10.xxx.yyy.zzz

I can't get this to work - could it work?

They have almost zero instructions, but they have a suggested /etc/network/interfaces file with this inconsistency. I haven't tried it, because my current image doesn't have ifupdown installed (I thought it was obsolete), and it would take a couple of hours to prepare and upload a new image, for something which I suspect isn't going to work.

I can get the network I/F up trivially with:

# ip addr add 77.xxx.yyy.zzz/32 dev ens192
# ip link set dev ens192 up

But if I set the gateway as follows I get 'Nexthop has invalid gateway':

# ip route add default via 10.xxx.yyy.zzz
1
  • 2
    Yes, the gateway needs to be in the same subnet, although hosting providers can do "tricks" to save address space. It's best to contact them for instructions. But host configuration is off topic here.
    – Ron Trunk
    Commented Feb 2, 2022 at 15:54

2 Answers 2

3

The next-hop address must be reachable, which means you need a route to ("covering") it. In this case a simple ip route add 10.x.y.z/32 dev ens192 first would get you there. That says that host is on that link.

(This is a bad way to run a data center.)

PS: This is phrased in linux terms, but the same can be done to virtually any platform. i.e. (IOS) ip route 10.x.y.z 255.255.255.255 G0/0 (hint: I actually have such a route for traffic to a cable modem internal network.)

3
  • That has, much to my surprise, fixed everything. Network up now.
    – EML
    Commented Feb 2, 2022 at 17:22
  • The good way™ to run that data center would be to use a /31 P2P link subnet.
    – Zac67
    Commented Feb 2, 2022 at 17:59
  • That sounds like it would waste an IP address for every address allocated, no hosting provider is going to do that with today's prices. Commented Feb 3, 2022 at 11:52
1

A gateway is a host on the network that knows how to reach other networks. If the gateway is configured on a different network, you would need a gateway to reach the gateway, and it does not work that way. It also smacks of the host trying to direct traffic on different network, and that is undesirable.

Remember that each hop makes its own independent routing decisions based on the packet destination address, so the gateway to reach your gateway on your configuration may not be the direction the first-hop router will send the packet. It has no way to know that you intend to send the packet to some other intermediate hop because there is nothing in the packet header to say that.

Also, remember that host/server configurations are off-topic here.

2
  • Thanks. It had just ocurred to me that serverfault/superuser might have been a better place - can you recommend one?
    – EML
    Commented Feb 2, 2022 at 15:55
  • Server Fault, as here, is for business networks, and Super User is for personal networks.
    – Ron Maupin
    Commented Feb 2, 2022 at 15:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.