What is MASQUERADE in the context of iptables?Two Network cards and ip forwardingForward port to local ip +...

How to use Mathematica to do a complex integrate with poles in real axis?

Why did Democrats in the Senate oppose the Born-Alive Abortion Survivors Protection Act (2019 S.130)?

Does every functor from Set to Set preserve products?

Scripture(s) saying not to look at the sun during his rising and setting time

New package vs new version?

What is a good reason for every spaceship to carry a weapon on board?

Do authors have to be politically correct in article-writing?

How do I draw the dashed lines as shown in this figure

Which communication protocol is used in AdLib sound card?

Why did Luke use his left hand to shoot?

Is a new Boolean field better than a null reference when a value can be meaningfully absent?

What is the wife of a henpecked husband called?

How should I handle players who ignore the session zero agreement?

Why would space fleets be aligned?

In Linux what happens if 1000 files in a directory are moved to another location while another 300 files were added to the source directory?

Can you tell from a blurry photo if focus was too close or too far?

Is it possible to grant users sftp access without shell access? If yes, how is it implemented?

Has any human ever had the choice to leave Earth permanently?

If I delete my router's history can my ISP still provide it to my parents?

Why do neural networks need so many training examples to perform?

Why are the books in the Game of Thrones citadel library shelved spine inwards?

Why is working on the same position for more than 15 years not a red flag?

Line of Bones to Travel and Conform to Curve (Like Train on a Track, Snake...)

Dilemma of explaining to interviewer that he is the reason for declining second interview



What is MASQUERADE in the context of iptables?


Two Network cards and ip forwardingForward port to local ip + portAccess VPN from home is fine but not outside via 3GRouting and Ip setupHow to use my ubuntu server as router?Masquerade over USB Ethernet ProblemWhat iptables rules are needed to allow an nfs share on 16.04?Ubuntu 16.04. Iptables on postrouting do not recognize docker0 bridgeubuntu iptables NAT & Router & Port ForwardingStuck on “Setting up VPN Linux Tutorial”: replace “eth0” with the internet connection from server16.04 iptables NAT weird behavior keeps working when removed













24















In iptables many times I see the target MASQUERADE. What is that? I searched and found lots of things. But I need someone to explain to me what MASQUERADE is in an easy to understand way?



An example (taken from this answer) is:




sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE










share|improve this question





























    24















    In iptables many times I see the target MASQUERADE. What is that? I searched and found lots of things. But I need someone to explain to me what MASQUERADE is in an easy to understand way?



    An example (taken from this answer) is:




    sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE










    share|improve this question



























      24












      24








      24


      7






      In iptables many times I see the target MASQUERADE. What is that? I searched and found lots of things. But I need someone to explain to me what MASQUERADE is in an easy to understand way?



      An example (taken from this answer) is:




      sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE










      share|improve this question
















      In iptables many times I see the target MASQUERADE. What is that? I searched and found lots of things. But I need someone to explain to me what MASQUERADE is in an easy to understand way?



      An example (taken from this answer) is:




      sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE







      networking firewall iptables






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 14 '17 at 19:15









      Bruno Bronosky

      50349




      50349










      asked May 15 '14 at 16:07









      Mohammad Reza RezwaniMohammad Reza Rezwani

      3,6992461110




      3,6992461110






















          3 Answers
          3






          active

          oldest

          votes


















          22














          It is an algorithm dependant on the iptables implementation that allows one to route traffic without disrupting the original traffic.



          I use the masquerade algorithm when I want to create a virtual wifi adapter and share my wifi.



          Im NOT talking about sharing Ethernet connection through your wifi, Im talking about sharing the wifi connection through your wifi via masquerading it to a virtual adapter. This in effect lets you share your wifi connection through wifi.



          .



          .



          Read this and scroll down to MASQUERADE: http://billauer.co.il/ipmasq-html.html



          Read this for more in depth: http://oreilly.com/openbook/linag2/book/ch11.html





          All those questions about "Connectify for linux" can be solved by implementing the MASQUERADE algo.





          For a direct example visit this page: http://pritambaral.com/2012/05/connectify-for-linux-wireless-hotspot/



          I HAVE NOT READ THE LAST LINK!!!! But the following is an accurate excerpt/example.



          sudo sysctl -w net.ipv4.ip_forward=1
          sudo iptables -A FORWARD -i wlan0 -j ACCEPT
          sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE


          I really dislike how search engines make the algorithm out to be some evil type of hack.. I use it merely so share my internet with my android phones.



          FINAL EDIT: this link is the bestest http://gsp.com/cgi-bin/man.cgi?section=3&topic=libalias






          share|improve this answer


























          • like your first link that was --exactly-- what I am looking for :)

            – Mohammad Reza Rezwani
            May 15 '14 at 16:29





















          31














          MASQUERADE is an iptables target that can be used instead of SNAT target (source NAT) when external ip of the inet interface is not known at the moment of writing the rule (when server gets external ip dynamically).






          share|improve this answer
























          • What should be used when the IP address is known?

            – Luc
            Nov 28 '16 at 8:55






          • 3





            @Luc, SNAT target (source network address translation) with defining source ip that should be placed instead of original source ip in the ip packet from original host. Like this -j SNAT --to-source xx.xx.xx.xx where xx.xx.xx.xx is the external ip of the desired interface. And I can't say that it should be used when external ip is known. I'd prefer to use MASQUERADE instead of SNAT to make rules flexible and not bound to specific external ip that I have at the moment.

            – Sergey P. aka azure
            Dec 6 '16 at 10:08



















          0














          We have virtualBox and created VM. I have host as windows and VM as Ubuntu.



          I am trying to ping external world IP both from guest and host.



          Both are working fine.



          Guest (VM) has enp0s3 i.e 10.0.2.15<==> 8.8.8.8 ... working fine but does NAT worked at VM before sending it to host IP.



          Host has eth0 172.19.3.16 <===> 8.8.8.8 ...working as expected.



          My question here is: How reply packet in first and second working i.e one reaching VM and second host interface?





          share








          New contributor




          Sastry Sista is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            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',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f466445%2fwhat-is-masquerade-in-the-context-of-iptables%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            22














            It is an algorithm dependant on the iptables implementation that allows one to route traffic without disrupting the original traffic.



            I use the masquerade algorithm when I want to create a virtual wifi adapter and share my wifi.



            Im NOT talking about sharing Ethernet connection through your wifi, Im talking about sharing the wifi connection through your wifi via masquerading it to a virtual adapter. This in effect lets you share your wifi connection through wifi.



            .



            .



            Read this and scroll down to MASQUERADE: http://billauer.co.il/ipmasq-html.html



            Read this for more in depth: http://oreilly.com/openbook/linag2/book/ch11.html





            All those questions about "Connectify for linux" can be solved by implementing the MASQUERADE algo.





            For a direct example visit this page: http://pritambaral.com/2012/05/connectify-for-linux-wireless-hotspot/



            I HAVE NOT READ THE LAST LINK!!!! But the following is an accurate excerpt/example.



            sudo sysctl -w net.ipv4.ip_forward=1
            sudo iptables -A FORWARD -i wlan0 -j ACCEPT
            sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE


            I really dislike how search engines make the algorithm out to be some evil type of hack.. I use it merely so share my internet with my android phones.



            FINAL EDIT: this link is the bestest http://gsp.com/cgi-bin/man.cgi?section=3&topic=libalias






            share|improve this answer


























            • like your first link that was --exactly-- what I am looking for :)

              – Mohammad Reza Rezwani
              May 15 '14 at 16:29


















            22














            It is an algorithm dependant on the iptables implementation that allows one to route traffic without disrupting the original traffic.



            I use the masquerade algorithm when I want to create a virtual wifi adapter and share my wifi.



            Im NOT talking about sharing Ethernet connection through your wifi, Im talking about sharing the wifi connection through your wifi via masquerading it to a virtual adapter. This in effect lets you share your wifi connection through wifi.



            .



            .



            Read this and scroll down to MASQUERADE: http://billauer.co.il/ipmasq-html.html



            Read this for more in depth: http://oreilly.com/openbook/linag2/book/ch11.html





            All those questions about "Connectify for linux" can be solved by implementing the MASQUERADE algo.





            For a direct example visit this page: http://pritambaral.com/2012/05/connectify-for-linux-wireless-hotspot/



            I HAVE NOT READ THE LAST LINK!!!! But the following is an accurate excerpt/example.



            sudo sysctl -w net.ipv4.ip_forward=1
            sudo iptables -A FORWARD -i wlan0 -j ACCEPT
            sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE


            I really dislike how search engines make the algorithm out to be some evil type of hack.. I use it merely so share my internet with my android phones.



            FINAL EDIT: this link is the bestest http://gsp.com/cgi-bin/man.cgi?section=3&topic=libalias






            share|improve this answer


























            • like your first link that was --exactly-- what I am looking for :)

              – Mohammad Reza Rezwani
              May 15 '14 at 16:29
















            22












            22








            22







            It is an algorithm dependant on the iptables implementation that allows one to route traffic without disrupting the original traffic.



            I use the masquerade algorithm when I want to create a virtual wifi adapter and share my wifi.



            Im NOT talking about sharing Ethernet connection through your wifi, Im talking about sharing the wifi connection through your wifi via masquerading it to a virtual adapter. This in effect lets you share your wifi connection through wifi.



            .



            .



            Read this and scroll down to MASQUERADE: http://billauer.co.il/ipmasq-html.html



            Read this for more in depth: http://oreilly.com/openbook/linag2/book/ch11.html





            All those questions about "Connectify for linux" can be solved by implementing the MASQUERADE algo.





            For a direct example visit this page: http://pritambaral.com/2012/05/connectify-for-linux-wireless-hotspot/



            I HAVE NOT READ THE LAST LINK!!!! But the following is an accurate excerpt/example.



            sudo sysctl -w net.ipv4.ip_forward=1
            sudo iptables -A FORWARD -i wlan0 -j ACCEPT
            sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE


            I really dislike how search engines make the algorithm out to be some evil type of hack.. I use it merely so share my internet with my android phones.



            FINAL EDIT: this link is the bestest http://gsp.com/cgi-bin/man.cgi?section=3&topic=libalias






            share|improve this answer















            It is an algorithm dependant on the iptables implementation that allows one to route traffic without disrupting the original traffic.



            I use the masquerade algorithm when I want to create a virtual wifi adapter and share my wifi.



            Im NOT talking about sharing Ethernet connection through your wifi, Im talking about sharing the wifi connection through your wifi via masquerading it to a virtual adapter. This in effect lets you share your wifi connection through wifi.



            .



            .



            Read this and scroll down to MASQUERADE: http://billauer.co.il/ipmasq-html.html



            Read this for more in depth: http://oreilly.com/openbook/linag2/book/ch11.html





            All those questions about "Connectify for linux" can be solved by implementing the MASQUERADE algo.





            For a direct example visit this page: http://pritambaral.com/2012/05/connectify-for-linux-wireless-hotspot/



            I HAVE NOT READ THE LAST LINK!!!! But the following is an accurate excerpt/example.



            sudo sysctl -w net.ipv4.ip_forward=1
            sudo iptables -A FORWARD -i wlan0 -j ACCEPT
            sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE


            I really dislike how search engines make the algorithm out to be some evil type of hack.. I use it merely so share my internet with my android phones.



            FINAL EDIT: this link is the bestest http://gsp.com/cgi-bin/man.cgi?section=3&topic=libalias







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 15 '14 at 16:37

























            answered May 15 '14 at 16:15









            Banned_UserBanned_User

            6931715




            6931715













            • like your first link that was --exactly-- what I am looking for :)

              – Mohammad Reza Rezwani
              May 15 '14 at 16:29





















            • like your first link that was --exactly-- what I am looking for :)

              – Mohammad Reza Rezwani
              May 15 '14 at 16:29



















            like your first link that was --exactly-- what I am looking for :)

            – Mohammad Reza Rezwani
            May 15 '14 at 16:29







            like your first link that was --exactly-- what I am looking for :)

            – Mohammad Reza Rezwani
            May 15 '14 at 16:29















            31














            MASQUERADE is an iptables target that can be used instead of SNAT target (source NAT) when external ip of the inet interface is not known at the moment of writing the rule (when server gets external ip dynamically).






            share|improve this answer
























            • What should be used when the IP address is known?

              – Luc
              Nov 28 '16 at 8:55






            • 3





              @Luc, SNAT target (source network address translation) with defining source ip that should be placed instead of original source ip in the ip packet from original host. Like this -j SNAT --to-source xx.xx.xx.xx where xx.xx.xx.xx is the external ip of the desired interface. And I can't say that it should be used when external ip is known. I'd prefer to use MASQUERADE instead of SNAT to make rules flexible and not bound to specific external ip that I have at the moment.

              – Sergey P. aka azure
              Dec 6 '16 at 10:08
















            31














            MASQUERADE is an iptables target that can be used instead of SNAT target (source NAT) when external ip of the inet interface is not known at the moment of writing the rule (when server gets external ip dynamically).






            share|improve this answer
























            • What should be used when the IP address is known?

              – Luc
              Nov 28 '16 at 8:55






            • 3





              @Luc, SNAT target (source network address translation) with defining source ip that should be placed instead of original source ip in the ip packet from original host. Like this -j SNAT --to-source xx.xx.xx.xx where xx.xx.xx.xx is the external ip of the desired interface. And I can't say that it should be used when external ip is known. I'd prefer to use MASQUERADE instead of SNAT to make rules flexible and not bound to specific external ip that I have at the moment.

              – Sergey P. aka azure
              Dec 6 '16 at 10:08














            31












            31








            31







            MASQUERADE is an iptables target that can be used instead of SNAT target (source NAT) when external ip of the inet interface is not known at the moment of writing the rule (when server gets external ip dynamically).






            share|improve this answer













            MASQUERADE is an iptables target that can be used instead of SNAT target (source NAT) when external ip of the inet interface is not known at the moment of writing the rule (when server gets external ip dynamically).







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered May 15 '14 at 16:21









            Sergey P. aka azureSergey P. aka azure

            1,096911




            1,096911













            • What should be used when the IP address is known?

              – Luc
              Nov 28 '16 at 8:55






            • 3





              @Luc, SNAT target (source network address translation) with defining source ip that should be placed instead of original source ip in the ip packet from original host. Like this -j SNAT --to-source xx.xx.xx.xx where xx.xx.xx.xx is the external ip of the desired interface. And I can't say that it should be used when external ip is known. I'd prefer to use MASQUERADE instead of SNAT to make rules flexible and not bound to specific external ip that I have at the moment.

              – Sergey P. aka azure
              Dec 6 '16 at 10:08



















            • What should be used when the IP address is known?

              – Luc
              Nov 28 '16 at 8:55






            • 3





              @Luc, SNAT target (source network address translation) with defining source ip that should be placed instead of original source ip in the ip packet from original host. Like this -j SNAT --to-source xx.xx.xx.xx where xx.xx.xx.xx is the external ip of the desired interface. And I can't say that it should be used when external ip is known. I'd prefer to use MASQUERADE instead of SNAT to make rules flexible and not bound to specific external ip that I have at the moment.

              – Sergey P. aka azure
              Dec 6 '16 at 10:08

















            What should be used when the IP address is known?

            – Luc
            Nov 28 '16 at 8:55





            What should be used when the IP address is known?

            – Luc
            Nov 28 '16 at 8:55




            3




            3





            @Luc, SNAT target (source network address translation) with defining source ip that should be placed instead of original source ip in the ip packet from original host. Like this -j SNAT --to-source xx.xx.xx.xx where xx.xx.xx.xx is the external ip of the desired interface. And I can't say that it should be used when external ip is known. I'd prefer to use MASQUERADE instead of SNAT to make rules flexible and not bound to specific external ip that I have at the moment.

            – Sergey P. aka azure
            Dec 6 '16 at 10:08





            @Luc, SNAT target (source network address translation) with defining source ip that should be placed instead of original source ip in the ip packet from original host. Like this -j SNAT --to-source xx.xx.xx.xx where xx.xx.xx.xx is the external ip of the desired interface. And I can't say that it should be used when external ip is known. I'd prefer to use MASQUERADE instead of SNAT to make rules flexible and not bound to specific external ip that I have at the moment.

            – Sergey P. aka azure
            Dec 6 '16 at 10:08











            0














            We have virtualBox and created VM. I have host as windows and VM as Ubuntu.



            I am trying to ping external world IP both from guest and host.



            Both are working fine.



            Guest (VM) has enp0s3 i.e 10.0.2.15<==> 8.8.8.8 ... working fine but does NAT worked at VM before sending it to host IP.



            Host has eth0 172.19.3.16 <===> 8.8.8.8 ...working as expected.



            My question here is: How reply packet in first and second working i.e one reaching VM and second host interface?





            share








            New contributor




            Sastry Sista is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.

























              0














              We have virtualBox and created VM. I have host as windows and VM as Ubuntu.



              I am trying to ping external world IP both from guest and host.



              Both are working fine.



              Guest (VM) has enp0s3 i.e 10.0.2.15<==> 8.8.8.8 ... working fine but does NAT worked at VM before sending it to host IP.



              Host has eth0 172.19.3.16 <===> 8.8.8.8 ...working as expected.



              My question here is: How reply packet in first and second working i.e one reaching VM and second host interface?





              share








              New contributor




              Sastry Sista is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.























                0












                0








                0







                We have virtualBox and created VM. I have host as windows and VM as Ubuntu.



                I am trying to ping external world IP both from guest and host.



                Both are working fine.



                Guest (VM) has enp0s3 i.e 10.0.2.15<==> 8.8.8.8 ... working fine but does NAT worked at VM before sending it to host IP.



                Host has eth0 172.19.3.16 <===> 8.8.8.8 ...working as expected.



                My question here is: How reply packet in first and second working i.e one reaching VM and second host interface?





                share








                New contributor




                Sastry Sista is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.










                We have virtualBox and created VM. I have host as windows and VM as Ubuntu.



                I am trying to ping external world IP both from guest and host.



                Both are working fine.



                Guest (VM) has enp0s3 i.e 10.0.2.15<==> 8.8.8.8 ... working fine but does NAT worked at VM before sending it to host IP.



                Host has eth0 172.19.3.16 <===> 8.8.8.8 ...working as expected.



                My question here is: How reply packet in first and second working i.e one reaching VM and second host interface?






                share








                New contributor




                Sastry Sista is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.








                share


                share






                New contributor




                Sastry Sista is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered 6 mins ago









                Sastry SistaSastry Sista

                1




                1




                New contributor




                Sastry Sista is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                Sastry Sista is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                Sastry Sista is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f466445%2fwhat-is-masquerade-in-the-context-of-iptables%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    List of shipwrecks in 1808...

                    Is there a lightweight tool to crop images quickly?Cropping Images using Command Line Tools OnlyHow to crop...

                    Unit packagekit.service is masked Announcing the arrival of Valued Associate #679: Cesar...