Bug 106902 - Suggest, setting nameservers in rc.conf
Summary: Suggest, setting nameservers in rc.conf
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: Doug Barton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-19 08:20 UTC by Dominic Fandrey
Modified: 2006-12-30 21:10 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dominic Fandrey 2006-12-19 08:20:17 UTC
I find it useful to init my resolv.conf upon boot time, especially because it gets changed all the time on my notebook. And I'm not running a DHCP server at home. Maybe others find it useful as well. So here is my suggester rc script, called resolv.

I think the only change required to put it into base, would be to move the defaults into /etc/defaults/rc.conf.

Fix: 

#!/bin/sh

# PROVIDE: resolv
# BEFORE: NETWORKING

: ${resolv_enable="NO"}
: ${resolv_nameserver=""}
: ${resolv_search=""}

. /etc/rc.subr

name="resolv"
rcvar=`set_rcvar`

resolv="/etc/resolv.conf"

resolv_start() {
	echo "# Nameservers set by resolv." > "$resolv"
	for nameserver in $resolv_nameserver; {
		echo "nameserver	$nameserver" >> "$resolv"
	}
	for search in $resolv_search; {
		echo "search	$search" >> "$resolv"
	}
}

start_cmd=resolv_start

load_rc_config $name
run_rc_command "$1"
Comment 1 Remko Lodder freebsd_committer 2006-12-19 09:19:28 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-rc

This is something for the -rc team.
Comment 2 Doug Barton freebsd_committer 2006-12-20 18:23:07 UTC
State Changed
From-To: open->feedback


I don't see this as a generally useful idea, but perhaps you 
can say more about the conditions under which your resolv.conf 
changes, and why you need to rewrite it at boot time? 

Thanks,
Comment 3 Doug Barton freebsd_committer 2006-12-20 18:23:07 UTC
Responsible Changed
From-To: freebsd-rc->dougb


I'll manage the feedback.
Comment 4 Dominic Fandrey 2006-12-20 19:06:16 UTC
Doug Barton wrote:
> Synopsis: Suggest, setting nameservers in rc.conf
> 
 > I don't see this as a generally useful idea, but perhaps you
> can say more about the conditions under which your resolv.conf
> changes, and why you need to rewrite it at boot time?
> 
> Thanks,
> 
> Doug

While taking it around to other places I connect to different networks via wireless, so my rc.conf gets changed often by dhclient and vpnc. But at home I prefer to use cable LAN and there's no DHCP server running (it's a static network, no need for that). I can set the IP/subnet and the gateway in rc.conf, but I have to get the nameserver into the resolv.conf and there's simply not a convenient way to do this.
If I'd make it read only, I wouldn't be able to use wireless any more. And I like the idea of having the network configuration in one place (rc.conf).
Even if I want to reset it on runtime I only have to type
# rcstart resolv
(I'm using sysutils/bsdadminscripts), so for me it's a really just the most convenient way to reset the resolv.conf.
Comment 5 Doug Barton freebsd_committer 2006-12-20 19:53:03 UTC
[LoN]Kamikaze wrote:
> Doug Barton wrote:
>> Synopsis: Suggest, setting nameservers in rc.conf
>>
>  > I don't see this as a generally useful idea, but perhaps you
>> can say more about the conditions under which your resolv.conf
>> changes, and why you need to rewrite it at boot time?
>>
>> Thanks,
>>
>> Doug
> 
> While taking it around to other places I connect to different networks via wireless, so my rc.conf gets changed often by dhclient and vpnc. But at home I prefer to use cable LAN and there's no DHCP server running (it's a static network, no need for that). I can set the IP/subnet and the gateway in rc.conf, but I have to get the nameserver into the resolv.conf and there's simply not a convenient way to do this.
> If I'd make it read only, I wouldn't be able to use wireless any more. And I like the idea of having the network configuration in one place (rc.conf).
> Even if I want to reset it on runtime I only have to type
> # rcstart resolv
> (I'm using sysutils/bsdadminscripts), so for me it's a really just the most convenient way to reset the resolv.conf.
> 

If someone else chimes in and says, "Yes, that sounds like a really
useful idea that I can see XYZ applications for" then I'd be likely to
say let's go ahead and add it.

Meanwhile, I have a similar situation, and what I do to fix it is use
an /etc/rc.local script that looks like this:

#!/bin/sh
PATH=/bin:/usr/bin:/sbin
export PATH
for ip in `ifconfig | awk '/inet / {print $2}'`; do
        case "${ip}" in
        127.0.0.1|0.0.0.0) ;;
        <my home network>.*)	Do a bunch of stuff ;;
	*)			Do other stuff ;;
	esac
done
exit 0

I obviously think rc.d is a great tool, but I don't think trying to
shoehorn every system administration problem into it is a good idea.

hth,

Doug

-- 

    This .signature sanitized for your protection
Comment 6 Doug Barton freebsd_committer 2006-12-30 21:09:33 UTC
State Changed
From-To: feedback->closed


No one else has spoken up indicating that this would be 
a generally useful idea, so we'll leave this in the 
archive for now.  

Doug