|
OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|||
Changing nameservers on the fly
Firstly, I am using a snapshot of OpenBSD, a.k.a. OpenBSD 5.10.
Secondly, I wish to know if it is at all possible to change nameservers on the fly when I am already connected to the internet. If it is possible, should I change the nameservers in dhclient.conf, resolv.conf or resolv.conf.tail? Obviously the procedure should not require a reboot. Has some kind soul already written a script to automate the process? (I was unable to find the answers in the man pages. Hence this post.) |
|
|||
OpenBSD-current, in the future is going to become OpenBSD 6.0.
DNS servers configuration is in resolv.conf, but it can be overwritten by dhclient(8), so you must prevent that by for example dhclient.conf. I don't know in depth how libraries and programs handle resolv.conf internally, though. I don't know if they, in this regard, are fully stateless. Maybe they will for some seconds or minutes still using old nameservers. You can also use Unbound resolver found in base. You can change configuration file and reload configuration using rcctl(8). This still doesn't guarantee immediate results in all programs, because programs can cache some entries internally, but it will not require them to spot changes in resolv.conf. |
|
||||
Thanks for the detailed explanation.
But as the famous Bard once wrote, a rose by any other name will still smell as sweet, don't you agree? Quote:
Quote:
Quote:
I wish to change nameservers for a session only, that is, only for the duration while I am surfing the internet. Can I do something like the following? 1. My dhclient.conf has the following line: supersede domain-name-servers 8.8.8.8 2. As soon as my machine is connected to the internet, I edit dhclient.conf by doing the following: #supersede domain-name-servers 8.8.8.8; supersede domain-name-servers 50.116.40.226; I save dhclient.conf and don't reboot my machine. Next when I type the name of a website into my browser's search field, will DNS resolution be performed by 50.116.40.226 or 8.8.8.8 ? Quote:
|
|
|||
You machine is still going to have old nameserver in resolv.conf. You need to manually run dhclient(8) after that to alter resolv.conf.
|
|
|||
Quote:
According to the man page (URL: http://man.openbsd.org/OpenBSD-current/man8/dhclient.8), I can issue signal HUP. Do I issue a command like the following? sudo HUP dhclient |
|
|||
I just type into terminal dhclient and it works, but maybe there is better method.
I think signal sending is done through kill(1) command |
|
||||
You can re-run dhclient(8), but per its man page a HUP signall is preferred. pkill(1) may be more convenient to a scripted solution than kill(1), since dhclient(8) does not store a PID in /var/run to find with a script.
Last edited by jggimi; 3rd April 2016 at 06:29 PM. Reason: typo |
|
|||
Quote:
sudo pkill -HUP dhclient Is the above command syntactically correct? Once I have killed dhclient(8), how do I restart it? Or, does it restart automatically by itself? |
|
||||
pkill and kill don't kill, per se. They send signals. Which by default is SIGTERM, "terminate."
In this case, you are sending a SIGHUP, "hang up." With that signal, dhclient will not terminate. It will reload its configuration file, and renew leases. |
|
|||
Quote:
sudo has been moved from the base installation to ports as security/sudo. The replacement in OpenBSD's base installation is called doas(1). The doas.conf(5) manpage will describe the differing grammar. |
|
|||
Code:
doas pkill -1 -o dhclient Code:
doas pkill -HUP -o dhclient Code:
doas pkill -SIGHUP -o dhclient Last edited by e1-531g; 3rd April 2016 at 09:30 PM. Reason: Added another variant. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
PKG_PATH not changing | Roydd85 | OpenBSD Packages and Ports | 12 | 7th April 2016 01:30 AM |
Changing IDE to SCSI | felix001 | FreeBSD General | 3 | 19th May 2009 11:52 AM |
Setting up nameservers | paran0iaX | OpenBSD General | 11 | 13th March 2009 12:16 PM |
Changing resolution | Cloud | General software and network | 3 | 27th June 2008 06:03 PM |
nameservers | c0mrade | General software and network | 8 | 27th May 2008 01:41 AM |