Iptables – Blocking domain via ufw and iptables

domain-nameipiptablesubuntu-12.04ufw

Does anyone know a way to block the domain name of a website (www.firstlightfcu.org) while still allowing access to the site using the IP address (174.122.168.43)? I tried blocking the website using iptables which worked perfectly and then allowing the IP address using ufw. The site is blocked altogether whether I use IP address or domain name to access it. I know this is supposed to be possible but I guess I'm missing something and I'm a new user with ubuntu. Any help pointing me in the right direction would be greatly appreciated.

Best Answer

If it's a question of your students, then they might want it for their own computer. They can modify their etc/hosts file and map that domain to a different IP address like:

127.0.0.1    www.firstlightfcu.org   # localhost
192.168.1.5  return.empty.example    # just some other address

Depending on what they map the domain name to, they will see different error messages, timeouts or just nothing.

Be aware, though, that many web servers are not reachable by their IP address alone, because that IP address hosts more than one domain. So the web server will give you one of those domains it hosts, not necessarily the domain you (they) want.

You may want to read https://pi-hole.net/ to learn more about such techniques to modify browser experience.

Related Topic