core icon indicating copy to clipboard operation
core copied to clipboard

IPv6 static route does not get installed.

Open diekgait opened this issue 8 years ago • 7 comments

I've created an IPv6 gateway: image The gateway is reachable:

root@firewall:~ # ndp -a | grep 43d
fe80::20c:29ff:fe89:e43d%em0         00:0c:29:89:e4:3d    em0 13s       R R

I've also added a static route: image But for some reason the route does not get installed:

root@firewall:~ # netstat -rn6
Routing tables

Internet6:
Destination                       Gateway                       Flags     Netif Expire
default                           2a02:58:c9:8100::d913:1010    UGS     wan_stf
::1                               link#5                        UH          lo0
2a02:58:c9:8100::                 link#11                       UHS         lo0
2a02:58:c9:8100::/56              link#11                       U       wan_stf
2a02:58:c9:8101::/64              link#2                        U           em0
2a02:58:c9:8101::1                link#2                        UHS         lo0
fe80::%em0/64                     link#2                        U           em0
fe80::1:1%em0                     link#2                        UHS         lo0
fe80::%em1/64                     link#3                        U           em1
fe80::21b:21ff:fe90:3b23%em1      link#3                        UHS         lo0
fe80::%lo0/64                     link#5                        U           lo0
fe80::1%lo0                       link#5                        UHS         lo0
fe80::6ef0:49ff:fede:8ece%ovpns1  link#8                        UHS         lo0
fe80::%em0_vlan50/64              link#9                        U      em0_vlan
fe80::21b:21ff:fe90:3b22%em0_vlan50 link#9                      UHS         lo0
fe80::%em0_vlan70/64              link#10                       U      em0_vlan
fe80::21b:21ff:fe90:3b22%em0_vlan70 link#10                     UHS         lo0

What could be the cause for this?

diekgait avatar Jul 18 '18 15:07 diekgait

please check system log for errors, maybe route / ifconfig throws an error at some point

fichtner avatar Jul 18 '18 15:07 fichtner

Only errors I get are:

Jul 19 17:39:00 | opnsense: /usr/local/etc/rc.routing_configure: The command '/usr/local/bin/rrdtool update /var/db/rrd/V6_VYOS01-quality.rrd N:U:U' returned exit code '127', the output was 'sh: /usr/local/bin/rrdtool: not found'
-- | --
Jul 19 17:39:00 | opnsense: /usr/local/etc/rc.routing_configure: RRD create failed exited with 127, the error is: sh: /usr/local/bin/rrdtool: not found
Jul 19 17:39:00 | opnsense: /usr/local/etc/rc.routing_configure: The command '/usr/local/bin/rrdtool update /var/db/rrd/VYOS01-quality.rrd N:U:U' returned exit code '127', the output was 'sh: /usr/local/bin/rrdtool: not found'
Jul 19 17:39:00 | opnsense: /usr/local/etc/rc.routing_configure: RRD create failed exited with 127, the error is: sh: /usr/local/bin/rrdtool: not found

diekgait avatar Jul 19 '18 15:07 diekgait

@diekgait as this affects 6RD have you tried this on 18.7.3? There was an error due to the extra 6RD (wan_stf) interface and the routing code not matching it properly.

fichtner avatar Sep 22 '18 21:09 fichtner

Recently I had a similar issue like @diekgait had.

Scenario:

  • Interface v6: fe80::224/64
  • Gateway on that interface: fe80::228
  • Added a (public v6) static route based on that gateway but it was not show in the routing table.

Turns out https://github.com/opnsense/core/blob/master/src/etc/inc/system.inc#L613 performs a call like /sbin/route add -inet6 '2a01:xxxx::228/128' 'fe80::228' which leads into the error message route: writing to routing socket: Network is unreachable add host 2a01:xxxx::228/128: gateway fe80::228 fib 0: Network is unreachable (unfortunately this error (return code 1) isn't logged anywhere).

The reason for this error is that the route-command does not know to which interface fe80::228 belongs to. IPv6 requires a Zone-ID (or Scope-ID) suffix (like %ifname) for link-local addresses for that reason. A proper route-call therefore would be for example/sbin/route add -inet6 '2a01:xxxx::228/128' 'fe80::228%vtnet3'.

So changing Gateway address from fe80::228 to fe80::228%vtnet3 fixed the issue for me. However this results in that this gateway can't used for default route anymore since the code for creating a default route already pays attention to the Zone-ID ( https://github.com/opnsense/core/blob/master/src/etc/inc/system.inc#L415 ) and therefore it results into a twice appended Zone-ID (fe80::228%vtnet3%vtnet3).

Since by creating a gateway OPNsense always knows (unless it's a "far gateway") the interface which the given gateway-address belongs to. So the best way would be to prevent the insertion of a Zone-ID suffix in the UI and add the "link-local-check" used by the default-route function to the static-route function, too. I could create a pull-request if wished.

PS: Of course its reasonable to check if there are other places in the code where a Zone-ID-suffix for link-local IPv6 Adresses is needed.

descilla avatar Nov 22 '18 22:11 descilla

@descilla thanks for the analysis! normally this works with the scope being correctly appended when required, but there seems to be an ancient bug at play in this particular function. Can you try the following patch? c7b18721ce

# opnsense-patch c7b18721ce

Cheers, Franco

fichtner avatar Nov 23 '18 06:11 fichtner

@fichtner Thanks for your quick response. Your patch works as expected.

Greetings, Simon

descilla avatar Nov 23 '18 09:11 descilla

Hi Simon,

Thanks a lot, will make sure it lands in 18.7.9.

Cheers, Franco

fichtner avatar Nov 23 '18 09:11 fichtner