Ubuntu /etc/hosts addresses in the form *.*.*.*

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
5
down vote

favorite












Let's say a website does not have a domain name like www.google.com and the only way to connect to it is to use an IP address like 216.58.212.68. If I add an entry in /etc/hosts that looks likes 0.0.0.0 216.58.212.68, will it block connections to that website? Would a web browser be blocked from visiting it too?



Additionally, would this also apply to local addresses like 192.168.0.1?







share|improve this question


























    up vote
    5
    down vote

    favorite












    Let's say a website does not have a domain name like www.google.com and the only way to connect to it is to use an IP address like 216.58.212.68. If I add an entry in /etc/hosts that looks likes 0.0.0.0 216.58.212.68, will it block connections to that website? Would a web browser be blocked from visiting it too?



    Additionally, would this also apply to local addresses like 192.168.0.1?







    share|improve this question
























      up vote
      5
      down vote

      favorite









      up vote
      5
      down vote

      favorite











      Let's say a website does not have a domain name like www.google.com and the only way to connect to it is to use an IP address like 216.58.212.68. If I add an entry in /etc/hosts that looks likes 0.0.0.0 216.58.212.68, will it block connections to that website? Would a web browser be blocked from visiting it too?



      Additionally, would this also apply to local addresses like 192.168.0.1?







      share|improve this question














      Let's say a website does not have a domain name like www.google.com and the only way to connect to it is to use an IP address like 216.58.212.68. If I add an entry in /etc/hosts that looks likes 0.0.0.0 216.58.212.68, will it block connections to that website? Would a web browser be blocked from visiting it too?



      Additionally, would this also apply to local addresses like 192.168.0.1?









      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 12 at 23:31









      isanae

      13716




      13716










      asked Aug 12 at 14:04









      Bjorn

      573




      573




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          14
          down vote



          accepted










          No. The hosts file doesn't affect any routing. It only affects name lookups. Since 216.58.212.68 is an IP address, the system won't look it up in the hosts table.



          Read here for more info on the hosts file: http://manpages.ubuntu.com/manpages/trusty/man5/hosts.5.html



          If you want to block connections to an IP address from your system, there are a couple of ways to do that, like:




          1. Blackhole traffic using the route command:



            route add 216.58.212.68 gw 127.0.0.1 lo



          2. Reject traffic using the route command:



            route add -host 216.58.212.68 reject



          3. Null route using the ip command:



            ip route add blackhole 216.58.212.68/32


          Now, if you want to block traffic to a system by name, you can add a fake entry to your hosts file pointing that name to the loopback address:



          127.0.0.1 badactor.evil.com


          Then any traffic trying to get to that host from your system will be faked out – as long as your system is set to use the hosts file lookup prior to DNS. Any specifically DNS based lookups will still work, although you could use a DNSMASQ server like a Pi Hole to block even DNS lookups.



          Make sure you read the man pages for the route and ip commands, so you'll understand how to make these commands persistent across reboots if you need them to be.






          share|improve this answer






















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f462137%2fubuntu-etc-hosts-addresses-in-the-form%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            14
            down vote



            accepted










            No. The hosts file doesn't affect any routing. It only affects name lookups. Since 216.58.212.68 is an IP address, the system won't look it up in the hosts table.



            Read here for more info on the hosts file: http://manpages.ubuntu.com/manpages/trusty/man5/hosts.5.html



            If you want to block connections to an IP address from your system, there are a couple of ways to do that, like:




            1. Blackhole traffic using the route command:



              route add 216.58.212.68 gw 127.0.0.1 lo



            2. Reject traffic using the route command:



              route add -host 216.58.212.68 reject



            3. Null route using the ip command:



              ip route add blackhole 216.58.212.68/32


            Now, if you want to block traffic to a system by name, you can add a fake entry to your hosts file pointing that name to the loopback address:



            127.0.0.1 badactor.evil.com


            Then any traffic trying to get to that host from your system will be faked out – as long as your system is set to use the hosts file lookup prior to DNS. Any specifically DNS based lookups will still work, although you could use a DNSMASQ server like a Pi Hole to block even DNS lookups.



            Make sure you read the man pages for the route and ip commands, so you'll understand how to make these commands persistent across reboots if you need them to be.






            share|improve this answer


























              up vote
              14
              down vote



              accepted










              No. The hosts file doesn't affect any routing. It only affects name lookups. Since 216.58.212.68 is an IP address, the system won't look it up in the hosts table.



              Read here for more info on the hosts file: http://manpages.ubuntu.com/manpages/trusty/man5/hosts.5.html



              If you want to block connections to an IP address from your system, there are a couple of ways to do that, like:




              1. Blackhole traffic using the route command:



                route add 216.58.212.68 gw 127.0.0.1 lo



              2. Reject traffic using the route command:



                route add -host 216.58.212.68 reject



              3. Null route using the ip command:



                ip route add blackhole 216.58.212.68/32


              Now, if you want to block traffic to a system by name, you can add a fake entry to your hosts file pointing that name to the loopback address:



              127.0.0.1 badactor.evil.com


              Then any traffic trying to get to that host from your system will be faked out – as long as your system is set to use the hosts file lookup prior to DNS. Any specifically DNS based lookups will still work, although you could use a DNSMASQ server like a Pi Hole to block even DNS lookups.



              Make sure you read the man pages for the route and ip commands, so you'll understand how to make these commands persistent across reboots if you need them to be.






              share|improve this answer
























                up vote
                14
                down vote



                accepted







                up vote
                14
                down vote



                accepted






                No. The hosts file doesn't affect any routing. It only affects name lookups. Since 216.58.212.68 is an IP address, the system won't look it up in the hosts table.



                Read here for more info on the hosts file: http://manpages.ubuntu.com/manpages/trusty/man5/hosts.5.html



                If you want to block connections to an IP address from your system, there are a couple of ways to do that, like:




                1. Blackhole traffic using the route command:



                  route add 216.58.212.68 gw 127.0.0.1 lo



                2. Reject traffic using the route command:



                  route add -host 216.58.212.68 reject



                3. Null route using the ip command:



                  ip route add blackhole 216.58.212.68/32


                Now, if you want to block traffic to a system by name, you can add a fake entry to your hosts file pointing that name to the loopback address:



                127.0.0.1 badactor.evil.com


                Then any traffic trying to get to that host from your system will be faked out – as long as your system is set to use the hosts file lookup prior to DNS. Any specifically DNS based lookups will still work, although you could use a DNSMASQ server like a Pi Hole to block even DNS lookups.



                Make sure you read the man pages for the route and ip commands, so you'll understand how to make these commands persistent across reboots if you need them to be.






                share|improve this answer














                No. The hosts file doesn't affect any routing. It only affects name lookups. Since 216.58.212.68 is an IP address, the system won't look it up in the hosts table.



                Read here for more info on the hosts file: http://manpages.ubuntu.com/manpages/trusty/man5/hosts.5.html



                If you want to block connections to an IP address from your system, there are a couple of ways to do that, like:




                1. Blackhole traffic using the route command:



                  route add 216.58.212.68 gw 127.0.0.1 lo



                2. Reject traffic using the route command:



                  route add -host 216.58.212.68 reject



                3. Null route using the ip command:



                  ip route add blackhole 216.58.212.68/32


                Now, if you want to block traffic to a system by name, you can add a fake entry to your hosts file pointing that name to the loopback address:



                127.0.0.1 badactor.evil.com


                Then any traffic trying to get to that host from your system will be faked out – as long as your system is set to use the hosts file lookup prior to DNS. Any specifically DNS based lookups will still work, although you could use a DNSMASQ server like a Pi Hole to block even DNS lookups.



                Make sure you read the man pages for the route and ip commands, so you'll understand how to make these commands persistent across reboots if you need them to be.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Aug 13 at 10:00









                Anthony Geoghegan

                7,21633751




                7,21633751










                answered Aug 12 at 14:21









                Tim Kennedy

                13.4k22949




                13.4k22949



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f462137%2fubuntu-etc-hosts-addresses-in-the-form%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery