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.

In Linux (fedora or cent OS, etc), I want to say if one program tries to download from one url, it goes to my host (my url) instead of what it tries to go. Something like /etc/hosts, but /etc/hosts is host to ip instead.

Thanks!

share|improve this question
    
Could you please clarify or give a specific example? I can't understand what you are trying to do here. –  terdon Mar 28 '13 at 12:29
    
Yes. something.com/link.zip to theother.net/link.zip , I want to convert a global archive to my local archive without changing the requester's code (url). I mean the program wants to go to something.com, but goes to theother.net (translation). –  Mustafa Asghari Mar 28 '13 at 12:48
add comment

1 Answer

You can install Dnsmasq. and configure it to override the upstream DNS servers for particular names. There are Dnsmasq packages for almost every Linux distro. See this blog post for simple instructions on how to set it up. It's easy to do.

For example, you can configure Dnsmasq to override any particular host name, say cnn.com so that any program on your computer, or that uses your computer for DNS, will see bbcnews.com instead of cnn.com.

If your own host names are configured in /etc/hosts, then in /etc/nsswitch.conf change the line

hosts:          files dns

to

hosts:          dns files

in order to give DNS preference over the /etc/hosts configuration.

share|improve this answer
    
Can I use Dnsmasq to redirect from one internet address/host to another internet host which is mine? Not only to local, but my own internet address. –  Mustafa Asghari Mar 29 '13 at 8:40
    
@MustafaAsghari: I added more explanation to my answer. I hope that helps answer the question better. –  Jonathan Ben-Avraham Mar 29 '13 at 9:31
    
I successfully installed dnsmasq, it works fine, however my efforts to override upstream dns failed. Can you give me the example of configuration (go to bbc.co.uk instead of cnn.com) here, plz? –  Mustafa Asghari Mar 29 '13 at 11:49
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.