How to redirect out going traffic to an IP address to another host name

hosts

How can I redirect an IP say 203.130.48.8-bj-cnc or 203.130.48.8 to Google.com in host file (or other places)?

It looks like host file doesn't redirect an ip address (only the domain names).

Best Answer

Since 203.130.48.8-bj-cnc (subtype ip address) and 203.130.48.8 (traditional ip address) are "ip address" instead of "alias," adding them in host file will not do anything. The system will bypass the rules you set up.

The only way to redirect ip request is to use third party software like little snitch. They are usually not free. This is because Unix based system will go through ip address directly when requesting instead of wasting time on capture them to enhance performance. Third party software basically reduce the overall efficiency by query ip requests.

Another way to do it is to set up rules in your gateway, that's only if your gateway can do it and if you have a gateway to begin with.

I know host file is probably the most convenient way to deal with this, but it simply won't work. Move on, stop wasting time on it.