Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Allow rc.conf to setup resolv.conf via resolvconf(8).
details: https://anonhg.NetBSD.org/src/rev/5836e27c03b2
branches: trunk
changeset: 991720:5836e27c03b2
user: roy <roy%NetBSD.org@localhost>
date: Fri Jul 27 15:31:02 2018 +0000
description:
Allow rc.conf to setup resolv.conf via resolvconf(8).
This allows all static network config to be in rc.conf rather than
spread across files.
diffstat:
etc/rc.d/network | 35 ++++++++++++++++++++++++++++++++++-
share/man/man5/rc.conf.5 | 28 ++++++++++++++++++++++++++--
2 files changed, 60 insertions(+), 3 deletions(-)
diffs (121 lines):
diff -r 22e368ba70bd -r 5836e27c03b2 etc/rc.d/network
--- a/etc/rc.d/network Fri Jul 27 15:15:30 2018 +0000
+++ b/etc/rc.d/network Fri Jul 27 15:31:02 2018 +0000
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: network,v 1.74 2018/06/29 12:34:15 roy Exp $
+# $NetBSD: network,v 1.75 2018/07/27 15:31:02 roy Exp $
#
# PROVIDE: network
@@ -52,6 +52,7 @@
have_inet6 &&
network_start_ipv6_autoconf
network_wait_dad
+ network_start_resolv
network_start_local
}
@@ -454,6 +455,32 @@
fi
}
+network_start_resolv()
+{
+ resconf=
+
+ if [ -n "$dns_domain" ]; then
+ resconf="${resconf}domain $dns_domain$nl"
+ fi
+ if [ -n "$dns_search" ]; then
+ resconf="${resconf}search $dns_search$nl"
+ fi
+ for n in $dns_nameservers; do
+ resconf="${resconf}nameserver $n$nl"
+ done
+ if [ -n "$dns_sortlist" ]; then
+ resconf="${resconf}sortlist $dns_sortlist$nl"
+ fi
+ if [ -n "$dns_options" ]; then
+ resconf="${resconf}options $dns_options$nl"
+ fi
+ if [ -n "$resconf" ]; then
+ resconf="# Generated by /etc/rc.d/network$nl$resconf"
+ echo 'Configuring resolv.conf'
+ printf %s "$resconf" | resolvconf -m "${dns_metric:-0}" -a network
+ fi
+}
+
network_start_local()
{
# XXX this must die
@@ -467,6 +494,7 @@
echo "Stopping network."
network_stop_local
+ network_stop_resolv
network_stop_aliases
[ "$net_interfaces" != NO ] &&
network_stop_interfaces
@@ -481,6 +509,11 @@
fi
}
+network_stop_resolv()
+{
+ resolvconf -f -d network
+}
+
network_stop_aliases()
{
echo "Deleting aliases."
diff -r 22e368ba70bd -r 5836e27c03b2 share/man/man5/rc.conf.5
--- a/share/man/man5/rc.conf.5 Fri Jul 27 15:15:30 2018 +0000
+++ b/share/man/man5/rc.conf.5 Fri Jul 27 15:31:02 2018 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: rc.conf.5,v 1.171 2018/07/13 21:46:58 maya Exp $
+.\" $NetBSD: rc.conf.5,v 1.172 2018/07/27 15:31:02 roy Exp $
.\"
.\" Copyright (c) 1996 Matthew R. Green
.\" All rights reserved.
@@ -55,7 +55,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd July 14, 2018
+.Dd July 27, 2018
.Dt RC.CONF 5
.Os
.Sh NAME
@@ -248,6 +248,30 @@
A space separated list of interface names.
These interfaces will be configured down when going from multiuser to single-user
mode or on system shutdown.
+.It Sy dns_domain
+A string.
+Sets domain in
+.Pa /etc/resolv.conf .
+.It Sy dns_search
+A string.
+Sets search in
+.Pa /etc/resolv.conf .
+.It Sy dns_nameservers
+A string of space seperated domain name servers.
+Sets nameserver for each value in
+.Pa /etc/resolv.conf .
+.It Sy dns_sortlist
+A string.
+Sets sortlist in
+.Pa /etc/resolv.conf .
+.It Sy dns_options
+A string.
+Sets options in
+.Pa /etc/resolv.conf .
+.It Sy dns_metric
+An unsigned integer.
+Sets the priority of the above DNS to other sources, lowest wins.
+Defaults to 0.
.Pp
This is important for some stateful interfaces, for example PPP over ISDN
connections that cost money by connection time or PPPoE interfaces which
Home |
Main Index |
Thread Index |
Old Index