Search code examples
macosnetwork-programmingroutesipv6bsd

how to config default ipv6 route using route command


My system is macOS, I try to use /sbin/route to confing some custom route, I know 0.0.0.0 is the default ipv4 route, so I can delete/change/add the default ipv4 route by running route delete 0.0.0.0.

Then I searched wiki and I found the default route address of ipv6 is :: or ::/0, I try to delete the route by running route delete :: or route delete ::/0, It returns route: bad address: ::.

My ipv6 route table is:

Internet6:
Destination                             Gateway                         Flags         Netif Expire
default                                 fe80::3600:a3ff:fed3:93e5%en0   UGcI            en0
default                                 fe80::%utun0                    UGcI          utun0
::1                                     ::1                             UHL             lo0

The question is what is the default value and how I can change it?


Solution

  • In this case default means ::/0. When manipulating IPv6 routes with the route command don't forget to specify -inet6 so that it knows you're talking about the IPv6 routing table.

    The following commands should all work for you:

    sudo route delete -inet6 default
    sudo route delete -inet6 ::/0
    sudo route delete -inet6 default fe80::3600:a3ff:fed3:93e5%en0
    sudo route delete -inet6 ::/0 fe80::3600:a3ff:fed3:93e5%en0
    

    They should all remove the default IPv6 route entry from your en0 interface.