I am running a Fedora Core server that is acting as the router for several computers. I would like several websites to be redirected to a certain IP address. I know this can be accomplished with the hosts file, like the example below:
I tried this in the hosts file but it seems to only work on the local machine and not the clients. Does anyone know how to "push" this to the clients or an alternative method of accomplishing this task?
I think you might want to look into iptables and FORWARD rules.
If you run your own DNS server on the FC5 machine, and have every other machine on the network use the server for it's DNS, then you can make your server provide whatever IP address you like in response to any request it receives from the lan.
Take a look at the man pages for 'bind'.
Am I on the right track?
iptables -t nat -A PREROUTING -p tcp -d www.google.com --dport 80 -j DNAT --to 18.104.22.168
So if I try to go to www.google.com it should take me to 22.214.171.124. This doesn't seem to be working.
There used to be an little app called DNSmasq that did just what you are looking for - used the hosts table as a lookup for answering DNS queries (and sent anything that didn't match to your usual DNS service). I have an old version if you can't find uptodate anywhere.
in your firewall iptables rule collection, the nat/PREROUTING
rule is good.
but not enough... you should also have these rules somewhere appropriate:
iptables -A INPUT -i $EXTERNAL_IF -p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -i $EXTERNAL_IF -p tcp --dport 80 -j ACCEPT
where EXTERNAL_IF=eth0 for eg.