0

Edit: The VM was moved from one hyper-v to another. In the first hyper-v it had a different IP, Mask and Gateway, and it worked. Then I moved it to the new hyper-v and changed the network details. I used a static MAC address also provided by the cloud provider.

I have assigned them info to /etc/netplan/50-cloud-init.yaml Then executed netplan apply However network is unreachable. Is there any posibiliy to let ubuntu allow different subnet for the gateway?

Edit to provide the 50-cloud-init.yaml config file:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp: no
      addresses:
        - IP/MASK
      gateway4: GATEWAY_IP
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]

It's strange that route -s doesn't output any route at all:

Kernel IP routing table
Destination    Gateway    Genmask    Flags Metric Ref  Use  Iface
  • Please post your full netplan config in the question. – slangasek Jun 3 at 18:05
  • edited: more details provided, including the network config file. – catalin Jun 3 at 19:18
0

Reading the netplan docummentation, I managed to make it work by using routes and on-link features. After applying the following, it works:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp: no
      addresses:
        - IP/32
      routes:
        - to: 0.0.0.0/0
          via: <GATEWAY_IP>
          on-link: true
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]
| improve this answer | |
  • Yes, I expected on-link would be the piece that was missing from your config. Note that the gateway4 here is redundant and broken, you should omit it in favor of the routes: section. – slangasek Jun 4 at 22:27
  • True, I have removed the gateway4: field, since we have it in the routes section too. thank you! – catalin Jun 5 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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