I want to set a dns record that my browser will use, but I don't have root access, so I can't modify /etc/hosts. I need to do this for testing vhosts with apache, whose dns hasn't yet been set up. I have access to firefox, and chrome, so if there's a plugin that could facilitate it; or other options are helpful.

update: the alternative to overriding the dns is probably modifying the HTTP headers, if the correct ones are sent to apache, the correct content should be returned.

The last line is unclear. Also, wouldn't this fit more in SF?
–
TshepangFeb 4 '11 at 8:40

@tshepang ... no because I need to do this on a linux desktop?
–
xenoterracide♦Feb 4 '11 at 10:03

1

Still not so clear. What does "or other options are helpful" mean exactly? Don't make me guess.
–
TshepangFeb 4 '11 at 10:53

2

@tshepang I don't know what I'm looking for... if I knew why would I be asking? there might be options that I haven't considered. I feel like you're asking me to explain how apache virtual hosts, http, and dns work together.
–
xenoterracide♦Feb 6 '11 at 5:20

I don't think so from the way it's worded.. what I really need to do is modify the HTTP headers that are sent... as an alternative option to hacking around using hosts
–
xenoterracide♦Feb 6 '11 at 5:14

I poked around the SO solution (TamperData) but I didn't see how to modify the host in that. I wonder if the live http headers thing really does allow me to modify headers, it says it's a viewer.
–
xenoterracide♦Feb 6 '11 at 5:18

I think the Modify Headers extension listed down a bit in the SO one works... if you use Host hostname... in it... not yet tested... outside of breaking sites using it.
–
xenoterracide♦Feb 6 '11 at 5:32

I think the best way to do this would be to set up a SOCKS5 proxy and tell firefox to send the DNS requests over the SOCKS5 proxy (network.proxy.socks_remote_dns). You could set up a socks5 proxy with openssh fairly easily (the -D option) and have a remote host running with a custom /etc/hosts, or something like DNSMasq for more complex DNS settings. Effectively, though, this is pushing the configuration of the DNS settings to a system you can make system-wide changes to.

If you have to do some tests you need a test machine, whatever is a virtual machine or a real one, so you have to ask your Unix admin (or hosting provider) how you can put in place a development environment.

You can also install a VM on your PC, install a Linux distribution, Apache and test your changes (it's not as hard as it sounds)

Update

To better explain, each application is written using the standard libraries, this way nobody has to rewrite the low level library and functions like the gethostbyname().

These functions normally are set to use file (/etc/hosts) and DNS, so, unlucky, if you need that your browser will resolve a name than the one is set in the /etc/hosts you don't have too many alternatives.

You can set up your own DNS server and ask who has root rights to change the /etc/resolve.conf

You can install a proxy server like DeleGate and set some rules for your VirtualHost

-1 worded poorly and patronizing. I AM the hosting provider, and it's the damn customers site on our server that I need to test. We have a network boot linux that I do not have admin access to, and I don't believe I can boot a VM on it.
–
xenoterracide♦Feb 4 '11 at 10:01

@xenoterracide there is not too much to say. It's really not feasible what you are asking for, except you change the way a SOCKET is created.
–
tmowFeb 4 '11 at 13:01

well as the hosting provider... I have "sudo rights" actually, I have real root on every box, and full access to everything... except my desktop (eyeroll) but if they haven't wanted to change their nameservers yet.. I can't help that...
–
xenoterracide♦Feb 6 '11 at 5:02

1

with LD_PRELOAD you can 'override' specific 'low level' functions and do what you want, eg. telling the program about your own '/etc/hosts' on open() and any other low level call .. as long as dynamic loading of code is invovled (.so)
–
akiraFeb 6 '11 at 5:34