0

I have the following configuration:

network:
    version: 2
    renderer: networkd
    ethernets:
            enp2s0:
                    dhcp4: yes
                    dhcp4-overrides:
                            hostname: f42252vm
                    gateway4: 192.168.110.1
                    routes:
                            - to: 192.168.110.0/24
                              via: 192.168.110.1
                              metric: 100
                            - to: 192.168.109.0/24
                              via: 192.168.110.1
                              metric: 100
                            - to: 192.168.111.0/24
                              via: 192.168.110.1
                              metric: 100
                    routing-policy:
                            - from: 192.168.110.8/24
                    dhcp6: yes
                    dhcp6-overrides:
                            hostname: f42252vm
                    wakeonlan: true
            enp3s0:
                    dhcp4: yes
                    dhcp4-overrides:
                            hostname: f42252v8
                            use-routes: false
                    gateway4: 192.168.108.1
                    routes:
                            - to: 0.0.0.0/0
                              via: 192.168.108.1
                              metric: 200
                            - to: 192.168.108.0/24
                              via: 192.168.108.1
                              metric: 200
                    routing-policy:
                            - from: 192.168.108.0/24
                    dhcp6: yes
                    dhcp6-overrides:
                            hostname: f42252v8
                            use-routes: false
    bridges: {}
    vlans:
            enp2s0.110:
                    id: 110
                    link: enp2s0
            enp3s0.108:
                    id: 108
                    link: enp3s0

Problem: When sending something from "192.168.110.8/24" to the internet it is marked with vlan 108 - which is wrong. But when adding the route "0.0.0.0/0" to interface enp2s0 I get some error on the whole network and vlan 110 ist blocked completely.

How can I add a route to the internet (or some type of default route) for enp2s0 which will then use vlan 110 - hopefully?

Thanks

Regards Karl-Heinz

averlon
  • 101
  • How are the vlans setup? See this to add a route: https://askubuntu.com/questions/168033/how-to-set-static-routes-in-ubuntu-server – SimpliFixed Sep 30 '20 at 16:18

2 Answers2

0

According to your configuration, you have not configured any IP addresses on either of the vlans. Therefore they are not used at all for routing traffic. You should simply drop this from the config, as you appear to be using vlan-tagged ports on your switch which handle vlans internally to the switch and transparently to the host.

Also, you are declaring a gateway on both interfaces, which is almost always incorrect. This is equivalent to a to: 0.0.0.0/0 route, without a routing policy.

Further, I see that you have enabled both dhcp and static addressing on both interfaces. This may sometimes be correct, but without knowing what information the DHCP servers are sending (particularly on enp2s0, where you have not declared use-routes: false, it is impossible to know how this interacts with your statically-declared network config.

I would suggest that the following config is likely much closer to what you're looking for:

network:
    version: 2
    renderer: networkd
    ethernets:
        enp2s0:
                dhcp4: yes
                dhcp4-overrides:
                        hostname: f42252vm
                routes:
                        - to: 0.0.0.0/0
                          via: 192.168.110.1
                          table: 110
                        - to: 192.168.109.0/24
                          via: 192.168.110.1
                        - to: 192.168.111.0/24
                          via: 192.168.110.1
                routing-policy:
                        - from: 192.168.110.8/24
                          table: 110
                        - to: 192.168.109.0/24
                          table: 253
                        - to: 192.168.111.0/24
                          table: 253
                dhcp6: yes
                dhcp6-overrides:
                        hostname: f42252vm
                wakeonlan: true
        enp3s0:
                dhcp4: yes
                dhcp4-overrides:
                        hostname: f42252v8
                        use-routes: false
                routes:
                        - to: 0.0.0.0/0
                          via: 192.168.108.1
                          table: 108
                        - to: 192.168.108.0/24
                          via: 192.168.108.1
                          table: 108
                routing-policy:
                        - from: 192.168.108.0/24
                          table: 108
                dhcp6: yes
                dhcp6-overrides:
                        hostname: f42252v8
                        use-routes: false

I am assuming that you want traffic to 192.168.109/24 and 192.168.111/24 to always be routed via enp2s0, and am therefore assigning a routing policy of table: 253 for these which should cause requests to these subnets to be handled in the default routing table (as per /etc/iproute2/rt_tables).

slangasek
  • 5,562
0

I have currently changed to:

network:
    version: 2
    renderer: networkd
    ethernets:
            enp2s0:
                    dhcp4: yes
                    dhcp4-overrides:
                            hostname: f42252vm
                            use-routes: false
                    routes:
                            - to: 0.0.0.0/0
                              via: 192.168.110.1
                              metric: 100
                            - to: 192.168.110.0/24
                              via: 192.168.110.1
                              metric: 100
                            - to: 192.168.109.0/24
                              via: 192.168.109.1
                              metric: 100
                            - to: 192.168.111.0/24
                              via: 192.168.111.1
                              metric: 100
                    routing-policy:
                            - from: 192.168.110.8/24
                    dhcp6: yes
                    dhcp6-overrides:
                            hostname: f42252vm
                            use-routes: false
                    wakeonlan: true
            enp3s0:
                    dhcp4: yes
                    dhcp4-overrides:
                            hostname: f42252v8
                            use-routes: false
                    gateway4: 192.168.108.1
                    routes:
                            - to: 0.0.0.0/0
                              via: 192.168.108.1
                              metric: 200
                            - to: 192.168.108.0/24
                              via: 192.168.108.1
                              metric: 200
                    routing-policy:
                            - from: 192.168.108.0/24
                    dhcp6: yes
                    dhcp6-overrides:
                            hostname: f42252v8
                            use-routes: false
    bridges: {}
    vlans:
            enp2s0.110:
                    id: 110
                    link: enp2s0
            enp3s0.108:
                    id: 108
                    link: enp3s0

This seems to work. At least it does not create any error messages on my router anymore.

I will have a deeper look into the setup with tables - which I did not know so far and still do not know what this does. I will check the docu.

Thanks for help.

averlon
  • 101