VMware Cloud Community
terran0925
Contributor
Contributor
Jump to solution

Setting up Alternate DNS server command

I have a line in the scripted install that uses:

network --bootproto static --ip x.x.x.x --netmask 255.255.255.0 --gateway x.x.x.x --nameserver x.x.x.x

To set the primary DNS server of the ESX. Is there an extra switch to allow me to set the alternate dns server as well?

If there isn't, can I put another line in the post install process to add it in? Thanks.

0 Kudos
1 Solution

Accepted Solutions
sbeaver
Leadership
Leadership
Jump to solution

This will rewrite the file completely...

echo "search network.com" > /etc/resolve.conf
echo "nameserver 202.54.1.10" >> /etc/resolve.conf
echo "nameserver 202.54.1.11" >> /etc/resolve.conf

If you just want to add to it then always use >>

when you use > it overwrites the file

Steve Beaver

VMware Communities User Moderator

VMware vExpert 2009

====

Co-Author of "VMware ESX Essentials in the Virtual Data Center"

(ISBN:1420070274) from Auerbach

Come check out my blog:

Come follow me on twitter

*Virtualization is a journey, not a project.*

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**

View solution in original post

0 Kudos
5 Replies
dickybird
Enthusiast
Enthusiast
Jump to solution

All networking information must be on one line, so only one DNS server may be specified.

0 Kudos
sbeaver
Leadership
Leadership
Jump to solution

The file that has the DNS info is /etc/resolv.conf so you can echo the info and pipe to that file in the %post

Steve Beaver

VMware Communities User Moderator

VMware vExpert 2009

====

Co-Author of "VMware ESX Essentials in the Virtual Data Center"

(ISBN:1420070274) from Auerbach

Come check out my blog:

Come follow me on twitter

*Virtualization is a journey, not a project.*

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
0 Kudos
terran0925
Contributor
Contributor
Jump to solution

Hi Steve,

Yup, I found the file while waiting for a response but do you know how I can add an extra line after the primary name server?

I was thinking about using the sed command to search and replace but I don't know what the line break symbol is. I was thinking something like:

sed -i.bak -e "s/nameserver 10.0.0.50 nameserver 10.0.0.50 LINE BREAK nameserver 10.0.0.51/g'

..or if there's an easier way to do it? Thanks. Last piece before I try the scripted install again.

0 Kudos
sbeaver
Leadership
Leadership
Jump to solution

This will rewrite the file completely...

echo "search network.com" > /etc/resolve.conf
echo "nameserver 202.54.1.10" >> /etc/resolve.conf
echo "nameserver 202.54.1.11" >> /etc/resolve.conf

If you just want to add to it then always use >>

when you use > it overwrites the file

Steve Beaver

VMware Communities User Moderator

VMware vExpert 2009

====

Co-Author of "VMware ESX Essentials in the Virtual Data Center"

(ISBN:1420070274) from Auerbach

Come check out my blog:

Come follow me on twitter

*Virtualization is a journey, not a project.*

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
0 Kudos
terran0925
Contributor
Contributor
Jump to solution

Thank you for your continuing help Steve! Worked like a charm. No onwards to test this script out! Smiley Happy

0 Kudos