Home Forums Software InstaDMG Scripts for setting DNS search suffix and such..

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #371685
    jlevitsk
    Participant

    Since network interfaces don’t exist until the image runs the first time I was wondering if anyone could share how they configure things like DNS suffix search order? Or really anything else. I have a little tweaks StartupItem that I’m injecting to try and set things… just trying to save time if someone else already looked in to the different pmset things to set power stuff and how to set DNS suffixes… all that jazz…

    thanks in advance for any and all replies…

    #371691
    Patrick Gallagher
    Participant

    Search domains can be set with networksetup.

    networksetup -setsearchdomains “Built-in Ethernet” dept1.company.com dept2.company.com

    #371975
    benfeea1
    Participant

    The problem I ran into was that different Macs have different names for the network ports.
    Some call it “Built-in Ethernet” others call it “Ethernet 1” Then of course there are wireless connections.

    I came up with this to find all the ethernet port and configure them.

    This runs as a StartupItem.

    ———————————————

    #!/bin/sh
    #
    # The purpose of this script is to configure the search doamin, and
    # AppleTalk for each network service.
    #
    # Ensure we are running this script as root
    if [ “`whoami`” != “root” ] ; then
    echo “script must be run as root”
    exit
    fi
    #
    ## Variables
    searchdomain1=”yoursearchdomain.com”

    # set working directory.
    cd /
    # create a file of the Network Services.
    networksetup -listallnetworkservices > private/tmp/NetworkServices1.ls
    # Remove any line that begins with “An asterisk”, any line that begins with “*”,
    # and any line that is blank from NetworkServices1.ls and save it as NetworkServices.ls
    sed -e ‘/^[An asterisk]/d’ -e ‘/^[*]/d’ -e ‘/^$/d’ private/tmp/NetworkServices1.ls > private/tmp/NetworkServices.ls
    rm private/tmp/NetworkServices1.ls
    echo The NetworkServices on this system are `cat private/tmp/NetworkServices.ls`
    #
    # Begin loop
    # Configure the Network Settings
    ConfigureNetworkSettings () {

    while read NetworkServicesfromls; do
    #
    networksetup -setsearchdomains “$NetworkServicesfromls” $searchdomain1
    networksetup -setappletalk “$NetworkServicesfromls” on

    echo configured $NetworkServicesfromls
    done
    }

    # end loop
    # run the loop using the list created from `networksetup -listallnetworkservices`
    ConfigureNetworkSettings < /private/tmp/NetworkServices.ls rm /private/tmp/NetworkServices.ls #Harikari srm -rf /Library/StartupItems/JHUAPLNetworkSettings exit 0

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Comments are closed