How can I clear the PREROUTING rules in my iptables?











up vote
1
down vote

favorite












Long ago I created some prerouting rules in my iptables. I have a script in ~/myuser/Downlaods,
owned by root



 #!/bin/bash
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8069
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8070
iptables-save


I have commented out these lines and renamed the file and changed ownership to a non-root user.



I think I must have added it to some other script (rc.local, systemd,etc...) because after I clear the iptables, save them and reboot, the rules come back.



I have tried:



$ sudo iptables -t nat -D PREROUTING 2
$ sudo iptables -t nat -D PREROUTING 1
$ sudo iptables-save


And this works temporarily. At this point the iptables are all empty. Then I reboot:



$ sudo reboot


After the reboot I get:
$ sudo iptables -L -n -t nat



Chain PREROUTING (policy ACCEPT)
target prot opt source destination
REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 8069
REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:443 redir ports 8070


The other chains are empty.



I set systemd log level to DEBUG in the config file, and while there are thousands of lines for the boot, I don't see anything (mainly using grep) that refers to iptables or PREROUTING.



I'm running Ubuntu 18.04.1 LTS.



I ran $ sudo grep -rnw 'etc/init.d/' -e 'PREROUTING' and it didn't return any results.



I ran $ sudo grep -rnw 'etc/init.d/' -e '8069' and it didn't return any results.



/etc/rc.local does not exist, so it's not running from there.



Where else can I look for this?










share|improve this question
























  • Install netfilter-persistent then remove those rules and run sudo dpkg-reconfigure iptables-persistent
    – George Udosen
    Dec 4 at 20:52










  • @GeorgeUdosen that worked. Thanks. If you put that in as an answer, I'll accept it.
    – user3347569
    Dec 4 at 21:03










  • Ok I have posted an answer!
    – George Udosen
    Dec 4 at 21:16















up vote
1
down vote

favorite












Long ago I created some prerouting rules in my iptables. I have a script in ~/myuser/Downlaods,
owned by root



 #!/bin/bash
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8069
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8070
iptables-save


I have commented out these lines and renamed the file and changed ownership to a non-root user.



I think I must have added it to some other script (rc.local, systemd,etc...) because after I clear the iptables, save them and reboot, the rules come back.



I have tried:



$ sudo iptables -t nat -D PREROUTING 2
$ sudo iptables -t nat -D PREROUTING 1
$ sudo iptables-save


And this works temporarily. At this point the iptables are all empty. Then I reboot:



$ sudo reboot


After the reboot I get:
$ sudo iptables -L -n -t nat



Chain PREROUTING (policy ACCEPT)
target prot opt source destination
REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 8069
REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:443 redir ports 8070


The other chains are empty.



I set systemd log level to DEBUG in the config file, and while there are thousands of lines for the boot, I don't see anything (mainly using grep) that refers to iptables or PREROUTING.



I'm running Ubuntu 18.04.1 LTS.



I ran $ sudo grep -rnw 'etc/init.d/' -e 'PREROUTING' and it didn't return any results.



I ran $ sudo grep -rnw 'etc/init.d/' -e '8069' and it didn't return any results.



/etc/rc.local does not exist, so it's not running from there.



Where else can I look for this?










share|improve this question
























  • Install netfilter-persistent then remove those rules and run sudo dpkg-reconfigure iptables-persistent
    – George Udosen
    Dec 4 at 20:52










  • @GeorgeUdosen that worked. Thanks. If you put that in as an answer, I'll accept it.
    – user3347569
    Dec 4 at 21:03










  • Ok I have posted an answer!
    – George Udosen
    Dec 4 at 21:16













up vote
1
down vote

favorite









up vote
1
down vote

favorite











Long ago I created some prerouting rules in my iptables. I have a script in ~/myuser/Downlaods,
owned by root



 #!/bin/bash
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8069
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8070
iptables-save


I have commented out these lines and renamed the file and changed ownership to a non-root user.



I think I must have added it to some other script (rc.local, systemd,etc...) because after I clear the iptables, save them and reboot, the rules come back.



I have tried:



$ sudo iptables -t nat -D PREROUTING 2
$ sudo iptables -t nat -D PREROUTING 1
$ sudo iptables-save


And this works temporarily. At this point the iptables are all empty. Then I reboot:



$ sudo reboot


After the reboot I get:
$ sudo iptables -L -n -t nat



Chain PREROUTING (policy ACCEPT)
target prot opt source destination
REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 8069
REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:443 redir ports 8070


The other chains are empty.



I set systemd log level to DEBUG in the config file, and while there are thousands of lines for the boot, I don't see anything (mainly using grep) that refers to iptables or PREROUTING.



I'm running Ubuntu 18.04.1 LTS.



I ran $ sudo grep -rnw 'etc/init.d/' -e 'PREROUTING' and it didn't return any results.



I ran $ sudo grep -rnw 'etc/init.d/' -e '8069' and it didn't return any results.



/etc/rc.local does not exist, so it's not running from there.



Where else can I look for this?










share|improve this question















Long ago I created some prerouting rules in my iptables. I have a script in ~/myuser/Downlaods,
owned by root



 #!/bin/bash
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8069
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8070
iptables-save


I have commented out these lines and renamed the file and changed ownership to a non-root user.



I think I must have added it to some other script (rc.local, systemd,etc...) because after I clear the iptables, save them and reboot, the rules come back.



I have tried:



$ sudo iptables -t nat -D PREROUTING 2
$ sudo iptables -t nat -D PREROUTING 1
$ sudo iptables-save


And this works temporarily. At this point the iptables are all empty. Then I reboot:



$ sudo reboot


After the reboot I get:
$ sudo iptables -L -n -t nat



Chain PREROUTING (policy ACCEPT)
target prot opt source destination
REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 8069
REDIRECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:443 redir ports 8070


The other chains are empty.



I set systemd log level to DEBUG in the config file, and while there are thousands of lines for the boot, I don't see anything (mainly using grep) that refers to iptables or PREROUTING.



I'm running Ubuntu 18.04.1 LTS.



I ran $ sudo grep -rnw 'etc/init.d/' -e 'PREROUTING' and it didn't return any results.



I ran $ sudo grep -rnw 'etc/init.d/' -e '8069' and it didn't return any results.



/etc/rc.local does not exist, so it's not running from there.



Where else can I look for this?







iptables systemd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 4 at 20:45









George Udosen

19.1k94266




19.1k94266










asked Dec 4 at 20:12









user3347569

83




83












  • Install netfilter-persistent then remove those rules and run sudo dpkg-reconfigure iptables-persistent
    – George Udosen
    Dec 4 at 20:52










  • @GeorgeUdosen that worked. Thanks. If you put that in as an answer, I'll accept it.
    – user3347569
    Dec 4 at 21:03










  • Ok I have posted an answer!
    – George Udosen
    Dec 4 at 21:16


















  • Install netfilter-persistent then remove those rules and run sudo dpkg-reconfigure iptables-persistent
    – George Udosen
    Dec 4 at 20:52










  • @GeorgeUdosen that worked. Thanks. If you put that in as an answer, I'll accept it.
    – user3347569
    Dec 4 at 21:03










  • Ok I have posted an answer!
    – George Udosen
    Dec 4 at 21:16
















Install netfilter-persistent then remove those rules and run sudo dpkg-reconfigure iptables-persistent
– George Udosen
Dec 4 at 20:52




Install netfilter-persistent then remove those rules and run sudo dpkg-reconfigure iptables-persistent
– George Udosen
Dec 4 at 20:52












@GeorgeUdosen that worked. Thanks. If you put that in as an answer, I'll accept it.
– user3347569
Dec 4 at 21:03




@GeorgeUdosen that worked. Thanks. If you put that in as an answer, I'll accept it.
– user3347569
Dec 4 at 21:03












Ok I have posted an answer!
– George Udosen
Dec 4 at 21:16




Ok I have posted an answer!
– George Udosen
Dec 4 at 21:16










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










To fix your situation install netfilter-persistent and then proceed to remove those rules again with your previous commands.



Now to get iptables to reload and be duly informed of the new state of iptables rules you either do:



sudo iptables-save > /etc/iptables/rules.v4
sudo ip6tables-save > /etc/iptables/rules.v6 # for ipv6


Or:



sudo dpkg-reconfigure iptables-persistent





share|improve this answer





















    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',
    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%2f1098483%2fhow-can-i-clear-the-prerouting-rules-in-my-iptables%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    To fix your situation install netfilter-persistent and then proceed to remove those rules again with your previous commands.



    Now to get iptables to reload and be duly informed of the new state of iptables rules you either do:



    sudo iptables-save > /etc/iptables/rules.v4
    sudo ip6tables-save > /etc/iptables/rules.v6 # for ipv6


    Or:



    sudo dpkg-reconfigure iptables-persistent





    share|improve this answer

























      up vote
      1
      down vote



      accepted










      To fix your situation install netfilter-persistent and then proceed to remove those rules again with your previous commands.



      Now to get iptables to reload and be duly informed of the new state of iptables rules you either do:



      sudo iptables-save > /etc/iptables/rules.v4
      sudo ip6tables-save > /etc/iptables/rules.v6 # for ipv6


      Or:



      sudo dpkg-reconfigure iptables-persistent





      share|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        To fix your situation install netfilter-persistent and then proceed to remove those rules again with your previous commands.



        Now to get iptables to reload and be duly informed of the new state of iptables rules you either do:



        sudo iptables-save > /etc/iptables/rules.v4
        sudo ip6tables-save > /etc/iptables/rules.v6 # for ipv6


        Or:



        sudo dpkg-reconfigure iptables-persistent





        share|improve this answer












        To fix your situation install netfilter-persistent and then proceed to remove those rules again with your previous commands.



        Now to get iptables to reload and be duly informed of the new state of iptables rules you either do:



        sudo iptables-save > /etc/iptables/rules.v4
        sudo ip6tables-save > /etc/iptables/rules.v6 # for ipv6


        Or:



        sudo dpkg-reconfigure iptables-persistent






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 4 at 21:09









        George Udosen

        19.1k94266




        19.1k94266






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f1098483%2fhow-can-i-clear-the-prerouting-rules-in-my-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

            flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

            Mangá

             ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕