Showing posts with label dns. Show all posts
Showing posts with label dns. Show all posts

Dec 6, 2012

Override DNS on a Linux system without root

I had this problem for a long time, and no one ever proposed a good solution. Recently I got a new answer on my, almost 2 year old, Unix and Linux StackExchange question. This information seems very obscure and so I thought I'd share it, if you too have had this problem and were unable to find this, or at least found finding it hard, consider upvoting the answer.

Problem

You're using a Linux system that you don't have root on, you need to override the DNS of the system. You usually want to do this because you're testing a service (web site) that does not have a proper hostname, but needs one in order to function properly. In the hosting world this comes up often enough.

Solution

You can set the HOSTALIASES environment variable before running your client program. HOSTALIASES is an environment variable that points to a file that is essentially alias value pairs.


$ echo "foo www.google.com" > ~/my_hosts
$ HOSTALIASES=~/my_hosts wget foo
See hostname(7).

Apr 29, 2011

Adding and Deleting subdomains with Plesk on the Command Line

Plesk has the disadvantage that everything is done through the
database. So we can't just modify Bind's Zone files.

To add an A record of a subdomain you have to do the following:

/usr/local/psa/bin/dns -a domain.tld -a subdomain -ip 127.0.0.1

the first -a is for add to zone which is why it must specify the top
level domen, the second is for A record, and must not contain the full
domain only the subdomain. If you use the full domain
subdomain.domain.tld you will end up with a record like
subdomain.domain.tld.domain.tld because plesk does not allow you to
terminate with a .. Thank you plesk for a shitty interface. The record
this create's looks like

subdomain.domain.tld. IN A 127.0.0.1

To delete this record you would use the following

/usr/local/psa/bin/dns -d domain.tld -a subdomain -ip 127.0.0.1

you'll note that it's the exact same thing except you replace the
first -a which is for add, with -d for delete.