0

I need to override DNS for a few hostnames on a Linux Centos 7 machine. I do not have write access to the file, however. What can I do in this case?

JoshK
  • 109
  • 2
    Which application which application needs to do the override? – Eduardo Trápani Apr 26 '20 at 04:18
  • You can clear the DNS cache on the system(s) that need to resolve it differently and configure them to resolve the IP address to a different name assuming that you have the sudo/admin rights to do so. – Nasir Riley Apr 26 '20 at 04:20
  • Does this help https://unix.stackexchange.com/questions/10438/can-i-create-a-user-specific-hosts-file-to-complement-etc-hosts – GMaster Apr 26 '20 at 04:23
  • The ultimate end-client is the amazon aws client. – JoshK Apr 26 '20 at 04:26
  • No, the HOSTALIASES approach didn't work and the other idea they suggested in the post I think still needs write to /etc/hosts – JoshK Apr 26 '20 at 04:34
  • So what access do you have? Can you edit other files in /etc/? Can you run a local DNS server/proxy? Can you override the DHCP server for this machine? Can you start the application(s) that need those DNS? If your situation is "I don't have root rights, I can't change the VM configuration, I am just a simple user" there won't be much you can do... – dirkt Apr 26 '20 at 06:44
  • Yeah, just standard user rights. I guess I'm out of luck. – JoshK Apr 26 '20 at 15:31

1 Answers1

0

Do you have access to change the DNS server locally, with dhcpcd or other? If not, and if you don't have r/w access to /etc, then there's nothing you can do for dns host mapping on the local host short of finding a privilege escalation vector to accomplish it.
You could however go upstream to the next dns server and make your changes there.

Or, depending on your needs, maybe setting an environment variable for the shell is enough, such as:

export google="172.217.15.110"

# and then subsequently commands like the following will work, 
vimb $google
ping $google
nmap $google
... etc