Date: Sun, 7 Apr 2024 23:16:47 -0400 From: Anton Yudin <contact@antonyudin.com> To: freebsd-net@freebsd.org Subject: How to ignore a default route for one of the dhclient-ed interface? Message-ID: <CAAokbZ0t%2BYdU1bjfd%2ByhnTjUw82puWBJHs3rBxwS-%2BkTkERz%2Bg@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
--000000000000fd5e3d06158d3cbc Content-Type: text/plain; charset="UTF-8" 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. --000000000000fd5e3d06158d3cbc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>Hello.</div><div><br></div><div>=C2=A0 I'm runnin= g a FreeBSD 14 with two interfaces that use DHCP.</div><div>=C2=A0 I would = like to make one of the interfaces to never set the default route.</div><di= v>=C2=A0 Right now the first interface to be fully up sets the default rout= e.<br></div><div><br></div><div>=C2=A0 I tried to set the following in /etc= /dhclient.conf<br></div><div>---------------8<------------------------</= div><div>=C2=A0 interface "wan1" {</div><div>=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 ignore routers;</div><div>=C2=A0 }</div><div>---------------8&= lt;------------------------</div><div>=C2=A0 but the default route still ge= ts set.</div><div><br></div><div>=C2=A0 I ended up creating a /etc/dhclient= -enter-hooks with a very hacky code that overrides the "route" co= mmand:</div><div>---------------8<------------------------<br></div><div= >route() {<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 if [ "X$interface" =3D = "Xwan1" -a "X$2" =3D "Xdefault" =C2=A0]; then= <br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 echo "igno= re route $1 $2 $3 $4" | logger -t "enter-hooks"<br>=C2=A0 = =C2=A0 =C2=A0 =C2=A0 else<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 /sbin/route $1 $2 $3 $4<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 fi<br>}</= div><div>---------------8<------------------------</div><div><br></div><= div>Is there a better way of doing this?</div><div><br></div><div>Thanks.</= div></div> --000000000000fd5e3d06158d3cbc--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAAokbZ0t%2BYdU1bjfd%2ByhnTjUw82puWBJHs3rBxwS-%2BkTkERz%2Bg>