Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My problem: Need DNS to be resolved through my remote machine while also using it as a proxy.

So I have a REMOTE that I can access from LOCAL via SERVER. This REMOTE can access a host TARGET_HOST. TARGET_HOST is setup in REMOTE's host file like so: 123.123.123.123 TARGET_HOST

I want to be able to access (in the browser & my application) TARGET_HOST from LOCAL. I have setup a 'proxy' like so:

LOCAL to SERVER:
ssh -L 4567:LOCAL:4568 user@SERVER

SERVER to REMOTE:
ssh -D 4568 user@REMOTE

LOCAL's network config is setup to use a proxy on localhost through port 4567.

So, everything is great and I can see TARGET_HOST in my browser. The problem I have is that the DNS doesn't resolve from LOCAL and therefore some code I have going on in my application, fails. Can anyone help me? Can anyone suggest a better method?

share|improve this question
    
Down vote, no explanation. At least let me know what's wrong with the question. –  Moz Morris Mar 29 '12 at 15:55
    
it is very hard to read because of the massive use of boldfont and paragraphs. the actual question is not very clear, too. –  Baarn Mar 29 '12 at 15:59
    
Thank you, I've removed boldfont (I was hoping that would actually make it easier to read, sorry) –  Moz Morris Mar 29 '12 at 16:02
    
I've also put the problem right to the top, any help gratefully received. –  Moz Morris Mar 29 '12 at 16:05
    
have you installed a dns server on REMOTE and set it as default for LOCALs network? –  Baarn Mar 29 '12 at 16:08
show 1 more comment

1 Answer

As I understand your question, you want your DNS requests to be resolved on the remote machine. That can be done, but the returned addresses aren't guaranteed to use your ssh tunnel. It will go out the local network. Is that what you really want? The easiest solution is to just hard code the address names with their ip addresses in your /etc/hosts. The hard way is to forward the DNS requests, you'll need to modify /etc/resolv.conf to use nameserver 127.0.0.1, so that dns requests can be captured locally. Then using ssh, you need to forward local port 53 to remote port 53. Where remote is the ip address of the machine that can resolve your dns requests. The problem is that you can't forward this port as non root user. You can get around this by forwarding some random port, say 20000 to remote port 53. Then use netcat as root to forward udp 53 to localhost 20000.

share|improve this answer
    
Ronan, I will give this a try but the data must go through the SSH. –  Moz Morris Mar 29 '12 at 18:01
    
If you need the data from resolved addresses to go through the tunnel, then there is no point to forward the DNS requests through port 53. There is no easy way to do this without having to map a local port to the remote address for each host. Why not use a vpn? A vpn acts like a ssh tunnel but terminates as an interface so packets can be routed through it transparently. –  Ronan Mar 29 '12 at 18:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.