It turns out that editing /etc/hosts
is enough to add an entry of DNS.
Is there a built-in cmd , where we can:
add host
cmd:
$ sudo mycmd 10.103.23.34 myme.com
Result :
10.103.23.34 myme.com
Add hostname
cmd :
$ sudo mycmd 10.103.23.34 omac.org
Result :
10.103.23.34 myme.com omac.org
Modify IP
cmd :
$ sudo mycmd 10.103.23.18 omac.org
Result :
10.103.23.18 myme.com omac.org
After seeking for CLI for
/etc/hosts
, we find : https://github.com/macmade/host-managerAmazing :
I tried to get the host-manager tool listed above to work but it looks like maybe it's for Windows or macOS? It was trying to cross compile and didn't look right for Ubuntu. I found this tool 'Hostess' though which works great and seems to do exactly what the OP was looking for:
https://github.com/cbednarski/hostess
Just to add to other suggestions - there's one more option which exists in standard Ubuntu package repositories -
hostsed
(github page + docs here). As a result install is as easy asapt install hostsed
.