How to ignore a default route for one of the dhclient-ed interface?

Anton Yudin <[email protected]>
Newsgroups gmane.os.freebsd.devel.net
Message-ID <CAAokbZ0t+YdU1bjfd+yhnTjUw82puWBJHs3rBxwS-+kTkERz+g@mail.gmail.com>
Hello.

  I'm running a FreeBSD 14 with two interfaces that use DHCP.
  I would like to make one of the interfaces to never set the default route.
  Right now the first interface to be fully up sets the default route.

  I tried to set the following in /etc/dhclient.conf
---------------8<------------------------
  interface "wan1" {
      ignore routers;
  }
---------------8<------------------------
  but the default route still gets set.

  I ended up creating a /etc/dhclient-enter-hooks with a very hacky code
that overrides the "route" command:
---------------8<------------------------
route() {
        if [ "X$interface" = "Xwan1" -a "X$2" = "Xdefault"  ]; then
                echo "ignore route $1 $2 $3 $4" | logger -t "enter-hooks"
        else
                /sbin/route $1 $2 $3 $4
        fi
}
---------------8<------------------------

Is there a better way of doing this?

Thanks.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.