2

On 18.04. I'm trying to configure my server with 2 vlan interfaces. Each vlan interface will have a separate IP Address on a separate subnet, and both will be linked to same physical interface. When I configure the vlan interfaces, I have connectivity to each different subnet through the vlans, but I am unable to add any additional routes. I need to add a default route with a next-hop on one of the subnets (vlan2000), and then a static route to a single, unattached subnet through the other vlan (vlan1000). Here is my netplan config file:

network:
renderer: NetworkManager
version: 2
ethernets:
    enp0s31f6: 
        routes:
            - to: 0.0.0.0/0
              via: 192.168.100.2
              metric: 100
            - to: 192.168.1.0/24
              via: 172.16.100.1
              metric: 10
vlans:
    vlan1000:
        id: 1000
        link: enp0s31f6
        addresses: [ "172.16.100.2/30" ]
    vlan2000:
        id: 2000
        link: enp0s31f6
        addresses: [ "192.168.100.2/24" ]

I have also tried adding the applicable routes under each vlan hierarchy with no luck -- for example:

    vlans:
    vlan1000:
        id: 1000
        link: enp0s31f6
        addresses: [ "172.16.100.2/30" ]
        routes:
          - to: 0.0.0.0/0
          via: 192.168.100.2
          metric: 100

With both of these, after applying the config I get the following error:

Traceback (most recent call last):
  File "/usr/sbin/netplan", line 23, in <module>
    netplan.main()
  File "/usr/share/netplan/netplan/cli/core.py", line 50, in main
    self.run_command()
  File "/usr/share/netplan/netplan/cli/utils.py", line 130, in run_command
    self.func()
  File "/usr/share/netplan/netplan/cli/commands/apply.py", line 43, in run
    self.run_command()
  File "/usr/share/netplan/netplan/cli/utils.py", line 130, in run_command
    self.func()
  File "/usr/share/netplan/netplan/cli/commands/apply.py", line 93, in command_apply
    stderr=subprocess.DEVNULL)
  File "/usr/lib/python3.6/subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['udevadm', 'test-builtin', 'net_setup_link', '/sys/class/net/vlan1000']' returned non-zero exit status 4.

If I then apply it again, it goes through, but none of the routes are added to the routing table. If i remove the route statements entirely, it applies with no errors. I don't know much about netplan but that seems like the issue. So i'm assuming I'm doing something in the config incorrectly. Where am i supposed to add statis routes for vlan interfaces?

FTR, when I add the static routes manually:

 sudo ip route add 192.168.1.0/24 via 172.16.100.1 dev vlan1000

everything works as I'm expecting it to. My concern is that i don't believe those manually added routes will persist after a restart. If there is an easier work around to make those routes persist I am open to that.

Thanks,

0
vlans:
vlan1000:
    id: 1000
    link: enp0s31f6
    addresses: [ "172.16.100.2/30" ]
    routes:
      - to: 0.0.0.0/0
      via: 192.168.100.2
      metric: 100

Indentation aside, this config would be incorrect because you're trying here to add a route to an interface that is not the interface holding the route to its gateway. The 0.0.0.0/0 route would need to be listed under the vlan2000 interface, given that is the network where your route is to the gateway (192.168.100.2).

But also, according to your config, 192.168.100.2 is a local address, which means it is incorrect to use it as a gateway. You do not have the whole of the Internet (0.0.0.0/0) directly connected to your host address on this vlan. Your route needs to set up with the IP address of your router as the via value, not your local address.

  • I guess it was just that typo that was causing the issue. I am now seeing both the routes. Thanks for the help. – AMatechak Oct 29 at 15:17

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.