Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What I need is to configure a Linux machine, so that when user of that machine goes to www.somesite.com he/she is redirected to, say,

What is the best way to achieve it?

share|improve this question
up vote 4 down vote accepted

Linux has the same host file. Just edit:


Depending on your system a command like this will open up that file:

$ sudo nano /etc/hosts

Just put lines like this in there and save:


For example:    www.anothersite.com wwwanother
share|improve this answer
How to achieve the reverse? – Acute Sep 2 '13 at 16:53
That file will convert www.anothersite.com or wwwanother to which is what you are looking for. – Drav Sloan Sep 2 '13 at 17:42
should I restart after editing the hosts file? – Acute Sep 2 '13 at 21:22
You should flush your dns cache blog.sudobits.com/2012/07/12/… and restart your browser. But reboot is another option. – fclad Sep 3 '13 at 4:46
@fclad installing the nscd made the things work. – Acute Sep 3 '13 at 7:37

If you want to override entries on more than one machine, then you could set up a DNS proxy such as Unbound or DNSmasq.

share|improve this answer

Your Answer


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.