From nobody Mon Apr 8 03:16:47 2024 X-Original-To: freebsd-net@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VCZ590TgBz5Fxw4 for ; Mon, 8 Apr 2024 03:17:01 +0000 (UTC) (envelope-from antonyyudin@gmail.com) Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VCZ575Dhdz4Ttp for ; Mon, 8 Apr 2024 03:16:59 +0000 (UTC) (envelope-from antonyyudin@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of antonyyudin@gmail.com designates 209.85.166.179 as permitted sender) smtp.mailfrom=antonyyudin@gmail.com Received: by mail-il1-f179.google.com with SMTP id e9e14a558f8ab-36a0f64f5e0so10298065ab.3 for ; Sun, 07 Apr 2024 20:16:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712546218; x=1713151018; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=V5jlJENhq8EQ3BboFp/qviqiOAB4EiMCY8LMz5/+MzE=; b=SNII8CNLJdhyiJwj4rUPBEPrSmxfFBapm/+4U+SjCSpKNMA82CDtIyRQqhNRdWbodw a9BtEY6sZI7LG5Y7BHg0G3gM040l8MK9ydzi/eZ89tIkzhNM9Z0vN2j7L+tkhfXH5gDC FKQQCZ71YVrPUkhtovmqtrgDeuGYaVWvpXcQlF2KsU0wtQNoo2k2qbXCmqfXczHFdqJ9 3KgNf+tzmAykkvGrEQy9Vxwcm2FvDY+YP79oHQ3sEpKsk/LbO2h7JklsKRTaifDCoNgx H3tXrXh5LW/3D46t0PHGsKSxxTkQfqGDkdlVa2MuWt9J9EITLjg77MpSYArB45orveP3 XeEA== X-Gm-Message-State: AOJu0Yx79O/TLSuqCzuqkqVPtCavOyI88WAN0vrDUjeZCuCIpeXQXpFQ lupfGCJgn/hQ1oPpi9dMizBnH9dWKmQHJMpsh7vPH/kg18FoJywkY8eo/x67 X-Google-Smtp-Source: AGHT+IHZuGDuKFdfcmnnf4xMQtd2uVRjMwkUmAyxi+weDCRRTxy3+Mn7DV9UJ6QMiBl+vXsCfeLbgA== X-Received: by 2002:a05:6e02:2487:b0:36a:16ba:a0b5 with SMTP id bt7-20020a056e02248700b0036a16baa0b5mr8394296ilb.17.1712546218376; Sun, 07 Apr 2024 20:16:58 -0700 (PDT) Received: from mail-io1-f44.google.com (mail-io1-f44.google.com. [209.85.166.44]) by smtp.gmail.com with ESMTPSA id b30-20020a026f5e000000b0047f13b719besm2279570jae.88.2024.04.07.20.16.58 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Apr 2024 20:16:58 -0700 (PDT) Received: by mail-io1-f44.google.com with SMTP id ca18e2360f4ac-7d0486cf91aso224874139f.1 for ; Sun, 07 Apr 2024 20:16:58 -0700 (PDT) X-Received: by 2002:a92:ca48:0:b0:36a:29b9:cfb5 with SMTP id q8-20020a92ca48000000b0036a29b9cfb5mr71571ilo.24.1712546218068; Sun, 07 Apr 2024 20:16:58 -0700 (PDT) List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@freebsd.org MIME-Version: 1.0 From: Anton Yudin Date: Sun, 7 Apr 2024 23:16:47 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: How to ignore a default route for one of the dhclient-ed interface? To: freebsd-net@freebsd.org Content-Type: multipart/alternative; boundary="000000000000fd5e3d06158d3cbc" X-Spamd-Bar: - X-Spamd-Result: default: False [-1.93 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; SUBJECT_ENDS_QUESTION(1.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.93)[-0.935]; FORGED_SENDER(0.30)[contact@antonyudin.com,antonyyudin@gmail.com]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[antonyudin.com]; RCPT_COUNT_ONE(0.00)[1]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; PREVIOUSLY_DELIVERED(0.00)[freebsd-net@freebsd.org]; TO_DN_NONE(0.00)[]; FROM_NEQ_ENVFROM(0.00)[contact@antonyudin.com,antonyyudin@gmail.com]; MISSING_XM_UA(0.00)[]; MLMMJ_DEST(0.00)[freebsd-net@freebsd.org]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.166.179:from]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; RCVD_IN_DNSWL_NONE(0.00)[209.85.166.179:from,209.85.166.44:received] X-Rspamd-Queue-Id: 4VCZ575Dhdz4Ttp --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
Hello.

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

=C2=A0 I tried to set the following in /etc= /dhclient.conf
---------------8<------------------------
=C2=A0 interface "wan1" {
=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 ignore routers;
=C2=A0 }
---------------8&= lt;------------------------
=C2=A0 but the default route still ge= ts set.

=C2=A0 I ended up creating a /etc/dhclient= -enter-hooks with a very hacky code that overrides the "route" co= mmand:
---------------8<------------------------
route() {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if [ "X$interface" =3D = "Xwan1" -a "X$2" =3D "Xdefault" =C2=A0]; then=
=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"
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 else
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 /sbin/route $1 $2 $3 $4
=C2=A0 =C2=A0 =C2=A0 =C2=A0 fi
}
---------------8<------------------------

<= div>Is there a better way of doing this?

Thanks.
--000000000000fd5e3d06158d3cbc--