I want to block some sites on my ubuntu system.So, I added some lines to the /etc/hosts
, which are
127.0.1.1 www.reddit.com
127.0.1.1 www.facebook.com
This now successfully blocks the website but I want to redirect to another URL when I go to one of the URL I mentioned above, I found that you need to change the 127.0.1.1
to IP of website
to make it work but I can't convert URL such as https://i.imgur.com/6FxzzCT.png to IP address.
It would be really helpful if someone can let be convert any URL to IP address.
What you are trying to do is not possible. Well, at least not how you are trying to do it.
In your desired URL (
https://i.imgur.com/6FxzzCT.png
), only this part has a specific IP address:i.imgur.com
.In a simplified form, when you enter that whole link in your browser (
https://i.imgur.com/6FxzzCT.png
). You are sending a request to151.101.16.193
asking for6FxzzCT.png
file using HTTPS protocol.Using
/etc/hosts
you can only set predefined IP addresses per hosts but you can't handle HTTP requests.What you might be able to do is to run a simple HTTP server on
localhost
serving a picture or a random picture atindex.html
or whatever predefined default page. Then redirect every site you like to127.0.0.1
using/etc/hosts
. Now your page is waiting there to bring up some random picture.