How To Add "options" To A Dynamically Created /etc/resolv.conf

This document (7011591) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 11
SUSE Linux Enterprise Server 10
SUSE Linux Enterprise Server 9
SUSE Linux Enterprise Desktop

Situation

Some administrators wish to use DHCP for obtaining server addresses (although not recommended).  When using DHCP to configure the resolv.conf some needed options may not be added (as DHCP doesn't handle the options) or they are overwritten.  This document is to show one way to add resolv.conf options to a dynamically created resolv.conf.  While this Technical Information Document (TID) was created for the purpose of showing how to do this on servers, this can easily be applied to SLED and other workstations.

Resolution

The example below may contain options not available on all systems.  See the man page for the resolv.conf to determine what options are valid on your system.
 
Under the /etc/sysconfig/network/ directory are a couple of sub directories called if-up.d and if-down.d.  These directories contain scripts that get executed after bringing the network up/down.  For this example, create a file under the if-up.d directory called resolvOptions.  Place the following content into it:
#! /bin/sh
check=$(grep options /etc/resolv.conf)
if ["$check" == ""]; then
    echo 'options timeout:1 attempts:2' >> /etc/resolv.conf
fi
 
This script will be executed after bringing and interface up, or after restarting it.  It will check the resolv.conf for "options" that have already been configured.  If there, it will not add them again.  If they aren't there, then it will add the line being echoed at the latter end of the script.

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:7011591
  • Creation Date: 08-Jan-2013
  • Modified Date:24-Mar-2021
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Join Our Community

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.


SUSE Customer Support Quick Reference Guide SUSE Technical Support Handbook Update Advisories
Support FAQ

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.

Go to Customer Center