Default IPv6 route not restored

Hi!

One part of my application is in charge of modifying the network configuration through the SystemConfiguration library. More specifically, I temporarily add entries under
  1. State:/Network/Service/Temp/DNS

  2. State:/Network/Service/Temp/IPv4

  3. State:/Network/Service/Temp/IPv6

And then remove them when I'm done, expecting the network configuration to return to the one active before this procedure.
I have noticed (at least in macOS Catalina) that the Default IPv6 route does not get properly restored if I do this. I can get it back by turning Off and On the network adapter, but I believe that should normally not be necessary.

The steps to reproduce this are:

1) Configure a manual IPv6 address for the network adapter, for example:

Code Block
Router: 2001:db8:abcd:12::1
Address: 2001:db8:abcd:12::7
Prefix Length: 64


2) Check that the default IPv6 route is present through 'netsat -nr'

Code Block language
Internet6:
Destination               Gateway             Flags     Netif Expire
default                 2001:db8:abcd:12::1       UGc       en0    
default                 fe80::%utun0          UGcI     utun0    
default                 fe80::%utun1          UGcI     utun1    


3) Add an IPv6 entry using scutil

Code Block language
d.init
d.add Addresses * 2001:db8:abcd:12::7
d.add InterfaceName en0
d.add PrefixLength * 64
d.add Router 2001:db8:abcd:12::1
set State:/Network/Service/Temp/IPv6


4) Default IPv6 route is still present

Code Block language
Internet6:
Destination               Gateway             Flags     Netif Expire
default                 2001:db8:abcd:12::1       UGc       en0    
default                 fe80::%utun0          UGcI     utun0    
default                 fe80::%utun1          UGcI     utun1    


5) Remove Temp entry
Code Block language
remove State:/Network/Service/Temp/IPv6 


6) Default IPv6 route is gone

Code Block language
Internet6:
Destination               Gateway             Flags     Netif Expire
default                 fe80::%utun0          UGcI     utun0    
default                 fe80::%utun1          UGcI     utun1    


7) Restart network adapter

8) Default IPv6 route reappears
Code Block language
Internet6:
Destination               Gateway             Flags     Netif Expire
default                 2001:db8:abcd:12::1       UGc       en0    
default                 fe80::%utun0          UGcI     utun0    
default                 fe80::%utun1          UGcI     utun1    


So, I wanted to know if I'm correctly assuming that the default route should not disappear after removing the IPv6 entry, and if there's any workaround I could use from within my application other than manually restarting the network adapter.

Thanks!
Disregard this post
I've been able to get the same behavior in macOS Big Sur 11.2

Hi guys; I'm facing same issue. The global entry exists after removing temporary entry with ipv6 information, so the default route should be restored, but this is not happening. Is there someone from Apple who can provide some information?

Basically I have the following scenario:

  • I have an app that internally makes a copy of the global ipv6 configuration in a new entry (through network configuration). This is because it is required to add a new default route.
  • When the app deletes the temporary entry it created before, at which point the default ipv6 route disappears. This is also true for ipv4, but the problem only happens with ipv6.
  • After that, I can verify that the global entry is present in the global configuration, however the operating system does not reestablish the default route.

Besides implementing the network restart as a workaround, another way to reestablish the default route is by adding an entry thru scutil but without deleting it. With this I manage to recover the route, however, and for some reason, it would not be working on all macs equally. When the Wi-Fi connection is mixed mode (ipv4/6), it is not possible to retrieve the local link route through scutil.

Is there a way to refresh the ipv6 configuration without having to go up and down the network interface? The operating system requires that all network configuration go through the Network Configuration, however it seems to be a bit limited, since it is not possible to restore the default route even having the global configuration.

Default IPv6 route not restored
 
 
Q