Home > sysadmin > Edit dns records with sed or vi (search and replace)

Edit dns records with sed or vi (search and replace)

You can easily replace an existing IP with and new IP in a dns record using sed. Here is the way
you do it.
sed -e ’s#xx.xx.xx.xx#yy.yy.yy.yy#g’ domain.com > new.domain.com
where xx.xx.xx.xx is the existing IP and yy.yy.yy.yy is the new IP
Using vi is similar. Here is the syntax:
vi yourzone.com . For instance, to change IP addresses:
<ESC>
:%s/xxx.xxx.xxx.xxx/yyy.yyy.yyy.yyy/g (where xxx is original IP and yyy is new IP)
<ESC> ZZ (to save file)

Categories: sysadmin
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: