Error in network definition unicast route must include both a to and via ip

Trying to setup multicast route to interface in Ubuntu 18.04.2 Netplan's syntax does not allow something like: routes: - to: 224.0.0.0/4 dev: eno1 this config does not work: addresses: - 19...

Trying to setup multicast route to interface in Ubuntu 18.04.2 Netplan’s syntax does not allow something like:

routes:
 - to: 224.0.0.0/4
   dev: eno1

this config does not work:

addresses:
 - 192.160.0.1/24
routes:
 - to: 224.0.0.0/4
   via: 192.168.0.1

how to set-up multicast route correctly?

asked Jul 23, 2019 at 7:02

user363600's user avatar

user363600user363600

411 silver badge4 bronze badges

On Ubuntu 20.04, If you only setup to: you would receive a warning saying:

Error in network definition: unicast route must include both a 'to' and 'via' IP

It seems to assume that the route is a unicast route. However via is not necessary when adding a multicast route.

The correct configuration is:

    ens224:
      addresses:
      - 192.160.0.1/24
      routes:
      - to: 224.0.0.0/4
        scope: link

This will result in the following route to be added:

224.0.0.0/4 dev ens224 proto static scope link

scope: is described at:
http://manpages.ubuntu.com/manpages/focal/man5/netplan.5.html
and more precisely at:
http://manpages.ubuntu.com/manpages/focal/man8/ip-route.8.html

              scope SCOPE_VAL
                     the scope of the destinations covered by the route prefix.  SCOPE_VAL may be
                     a number or a string from the file /etc/iproute2/rt_scopes.  If this
                     parameter is omitted, ip assumes scope global for all gatewayed unicast
                     routes, scope link for direct unicast and broadcast routes and scope host
                     for local routes.

answered Dec 22, 2020 at 17:18

yurtesen's user avatar

yurtesenyurtesen

5084 silver badges9 bronze badges

The docs are not super clear indeed but we’ve had some luck with the following:

routes:
  - to: 224.0.0.0/4
    via: 0.0.0.0

answered Jul 25, 2019 at 0:10

ASabourin's user avatar

1

I’m trying to replicate in Netplan the equivalent of

ip -6 r a 2605:6400:1:fed5::1 dev eth0

There’s no «via» address. I’ve tried:

      routes:
        - to: "2605:6400:1:fed5::1"
          on-link: true

But unfortunately, netplan comes back with an error

Error in network definition //etc/netplan/01-netcfg.yaml line 13 column 8: unicast route must include both a 'to' and 'via' IP

Is there a fake ‘via’ address I should use? It seems netplan doesn’t even have post-up hooks so I can’t work around the problem.

asked May 8, 2019 at 12:10

GDR's user avatar

In versions of netplan >= 0.40 you can use:

eth0:
  routes:
    - to: "2605:6400:1:fed5::1"
      scope: link

In older versions you can use the «::» catch-all:

eth0:
  routes:
    - to: "2605:6400:1:fed5::1"
      via: "::"
      on-link: true

answered May 8, 2019 at 12:25

Gerrit's user avatar

GerritGerrit

1,4778 silver badges8 bronze badges

5

Trying to setup multicast route to interface in Ubuntu 18.04.2 Netplan’s syntax does not allow something like:

routes:
 - to: 224.0.0.0/4
   dev: eno1

this config does not work:

addresses:
 - 192.160.0.1/24
routes:
 - to: 224.0.0.0/4
   via: 192.168.0.1

how to set-up multicast route correctly?

Answer

On Ubuntu 20.04, If you only setup to: you would receive a warning saying:

Error in network definition: unicast route must include both a 'to' and 'via' IP

It seems to assume that the route is a unicast route. However via is not necessary when adding a multicast route.

The correct configuration is:

    ens224:
      addresses:
      - 192.160.0.1/24
      routes:
      - to: 224.0.0.0/4
        scope: link

This will result in the following route to be added:

224.0.0.0/4 dev ens224 proto static scope link

scope: is described at:
http://manpages.ubuntu.com/manpages/focal/man5/netplan.5.html
and more precisely at:
http://manpages.ubuntu.com/manpages/focal/man8/ip-route.8.html

              scope SCOPE_VAL
                     the scope of the destinations covered by the route prefix.  SCOPE_VAL may be
                     a number or a string from the file /etc/iproute2/rt_scopes.  If this
                     parameter is omitted, ip assumes scope global for all gatewayed unicast
                     routes, scope link for direct unicast and broadcast routes and scope host
                     for local routes.

Attribution
Source : Link , Question Author : user363600 , Answer Author : yurtesen

Ezoic

On Ubuntu 20.04, If you only setup to: you would receive a warning saying:

Error in network definition: unicast route must include both a 'to' and 'via' IP

It seems to assume that the route is a unicast route. However via is not necessary when adding a multicast route.

The correct configuration is:

    ens224:
      addresses:
      - 192.160.0.1/24
      routes:
      - to: 224.0.0.0/4
        scope: link

This will result in the following route to be added:

224.0.0.0/4 dev ens224 proto static scope link

scope: is described at:
http://manpages.ubuntu.com/manpages/focal/man5/netplan.5.html
and more precisely at:
http://manpages.ubuntu.com/manpages/focal/man8/ip-route.8.html

              scope SCOPE_VAL
                     the scope of the destinations covered by the route prefix.  SCOPE_VAL may be
                     a number or a string from the file /etc/iproute2/rt_scopes.  If this
                     parameter is omitted, ip assumes scope global for all gatewayed unicast
                     routes, scope link for direct unicast and broadcast routes and scope host
                     for local routes.


glib warning on netplan-try with wrong config

Bug #1938263 reported by
Alex
on 2021-07-28

This bug affects 2 people

Affects Status Importance Assigned to Milestone


netplan

Triaged

Medium


Unassigned

Bug Description

Hello! Not sure if it is a bug or not, but:
While learning netplan, I’ve made a wrong config, then check it with netplan-try, and get the error below.

(generate:1255): GLib-WARNING **: 07:45:34.289: GError set over the top of a previous GError or uninitialized memory.
This indicates a bug in someone’s code. You must ensure an error is NULL before it’s set.
The overwriting error message was: /etc/netplan/00-installer-config.yaml:13:14: Error in network definition: unicast route must include both a ‘to’ and ‘via’ IP
             — to: 0.0.0.0/0
             ^
/etc/netplan/00-installer-config.yaml:17:21: Error in network definition: IP family mismatch in route to fe80::1
               via: fe80::1
                    ^
An error occurred: the configuration could not be generated
Reverting.
Warning: Stopping systemd-networkd.service, but it can still be activated by:
  systemd-networkd.socket

My config is (addresses were replaced):

network:
    version: 2
    renderer: networkd
    ethernets:
        eth0:
            addresses:
                — 192.46.XXX.XXX/24
                — 2a01:7e01:e001:23e:152c:a51c:beef:beer/64
            nameservers:
                addresses: [8.8.8.8, 1.1.1.1]
            routes:
             — to: 0.0.0.0/0
               via: 192.XXX.XXX.1
               metric: 100
             — to: 0.0.0.0/0
               via: fe80::1
               metric: 200

Trying config de network in Ubuntu Server

i use nano

text:

network:
  version:
  renderer: networkd
  ethernets:
    ens160:
       dhcp: no
       adresses: [172.00.000.000/24]
       gateway: [172.00.000.1]
       nameservers:
          addressess:
          - 172.00.000.2
          - 172.00.000.3

When i try : sudo netplan apply

ERROR

Error im network definition: espected scalar
       gateway4: [172.00.000.1]

if i remove square bracket in gateway

ERROR: Ivalid YAML: inconsistent identation: 
   #   gateway4: 172.00.000.1

Thanks!!!!

Artur Meinild's user avatar

asked Jun 13, 2022 at 16:03

Gastón's user avatar

2

The error you got «expected scalar gateway4:» means that it expected a single value not in [], so removing the brackets was the correct solution. The second error about inconsistent indentation came because YAML is very picky about exactly how you indent all the lines, and you have to re-check your indentation to be sure it’s correct and consistent.

This may work, not tested (with spelling mistakes fixed):

network:
  version:
  renderer: networkd
  ethernets:
    ens160:
      dhcp: no
      addresses: [172.00.000.000/24]
      gateway4: 172.00.000.1
      nameservers:
        addresses:
        - 172.00.000.2
        - 172.00.000.3

answered Jun 13, 2022 at 16:12

Esther's user avatar

EstherEsther

2,8099 silver badges20 bronze badges

2

In addition to Esther’s answer, let me point out that the gateway4 and gateway6 options are deprecated, and should (for future reference) instead be replaced with default routes — like in this example:

network:
    version: 2
    renderer: networkd
    ethernets:
        enp3s0:
            addresses:
                - 10.10.10.2/24
            nameservers:
                search: [mydomain, otherdomain]
                addresses: [10.10.10.1, 1.1.1.1]
            routes:
                - to: default
                  via: 10.10.10.1

answered Jun 13, 2022 at 16:20

Artur Meinild's user avatar

Artur MeinildArtur Meinild

15.3k15 gold badges40 silver badges75 bronze badges

1

  • Печать

Страницы: [1]   Вниз

Тема: Ошибка при сохранении конфигурации  (Прочитано 621 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн
iiwanc

Здравствуйте!
Заранее прошу прощения, если задаю глупые вопросы.
С Ubuntu впервые работаю.

Установил Ubuntu Server 18.04.4 LTS 64-bit
Нужно поменять IP, сделать его статичным.
При сохранении конфигурации появляется ошибка:

/etc/netplan/50-cloud-init.yaml:1:9: error in network definition expected mapping (check indentation)
network:
Пишу в файл:

network:
  ethernets:
    ens160:
      addresses:
        - 198.0.0.174/24
      dhcp4: false
      gateway4: "198.0.0.100"
      nameservers:
        addresses:
          - "8.8.8.8"
          - "8.8.4.4"
  renderer: networkd
  version: 2

Буду благодарен помощи.
Переход на новую строку начинал с помощью стрелки, не через Enter.
Поставил отступы пробелами. Но ошибку не победил.
Помогите, пожалуйста, понять, что делаю не так.


ТС не появлялся на Форуме более трех месяцев по состоянию на 19/03/2021 (последняя явка: 07/04/2020). Модератором раздела принято решение закрыть тему.
—zg_nico

« Последнее редактирование: 19 Марта 2021, 14:06:39 от zg_nico »


Онлайн
andytux

Нетплан не прощает вольностей. Что-то мне кажется, что кавычки лишние.


Оффлайн
iiwanc

На самом деле там нет ковычек. Стоят квадратные скобки.
Не пойму как прикрепить скрин здесь.
Даю на него ссылку с Я. Диска https://yadi.sk/i/HInBrFNrEctvzQ

Изображения оформляются в виде превью, а не просто гиперссылкой, ведущей неведомо куда. Отправлено уведомление в ЛС о допущенном нарушении. Стоковый тег пользователя пассивизирован, зачеркнут. Изображение перезалито, и оформлено в соответствии с предписаниями Руководства.
 —zg_nico

« Последнее редактирование: 31 Марта 2020, 00:05:28 от zg_nico »


Онлайн
ALiEN175

yaml:1:9

первая строка, девятый символ (судя по приведённому тексту — это пробел). Yaml очень чувствителен к пробелам. Уберите лишние.

ASUS P5K-C :: Intel Xeon E5450 @ 3.00GHz :: 8 GB DDR2 :: Radeon R7 260X :: XFCE
ACER 5750G :: Intel Core i5-2450M @ 2.50GHz :: 6 GB DDR3 :: GeForce GT 630M :: XFCE


Оффлайн
iiwanc

Записал видео, на котором видно, что удаляю двоеточие после network.
Потом пишу двоеточие и курсор мигает возле него, но клавишу пробела или какую другую не нажимал.
Видео https://youtu.be/2tho0kJsUNE


Пользователь добавил сообщение 30 Марта 2020, 20:16:23:


Нет вариантов?
Думаю переустанавливать ОС

« Последнее редактирование: 30 Марта 2020, 20:16:23 от iiwanc »


Оффлайн
Usermaster

Смущает тот факт что на скриншоте файл 99-disable-network-config.cfg
Маска подсети у Вас походу не указана.

Здесь [ссылка] почитайте.

Кстати при отсутствии нужного фалйа .yml, его можно сгенерировать.

sudo netplan generate

« Последнее редактирование: 31 Марта 2020, 09:51:08 от Usermaster »


  • Печать

Страницы: [1]   Вверх

Понравилась статья? Поделить с друзьями:
  • Error in network definition invalid ip family 1
  • Error in network definition expected sequence addresses
  • Error in network definition expected mapping check indentation nameservers
  • Error in network definition address is missing prefixlength
  • Error in na fail default