Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

node.js iptables module help needed

phi0xphi0x Posts: 1Member
edited May 1 in JavaScript

Hi there,

I found this node.js iptables module. (node-iptables) I want to modify it(if it even needs modifying) so that it can do more than what it already does but I'm not a very good programmer..wondering if anyone can give me some help to get my task completed.

I have a internal website where I want to have users go to the website and have the website automatically find the clients IP address, show the address to the client, have the client confirm it then send the IP address information over to my other server that will run node.js and accept the IP information which then it will add or remove the IP address that is presented to it.

my iptable rules usually are like so: iptables -A INPUT -s x.x.x.x/32 -j ACCEPT

if you see node-iptables it has an example: https://github.com/pkrumins/node-iptables

" var iptables = require('iptables');

    iptables.allow({
        protocol : tcp,
        src : '10.1.1.5',
        dport : 34567,
        sudo : true
    });

    iptables.drop({
        protocol : 'tcp',
        dport : 34567,
        sudo : true
    });

This allows connections to port 34567 from 10.1.1.5 and drops connections from the same port from everyone else."

would this be what I use? to get the same affect as: iptables -A INPUT -s x.x.x.x/32 -j ACCEPT

 var iptables = require('iptables');

    iptables.allow({
        src : 'x.x.x.x/32',
        sudo : true
    });

If that is the correct code for what I want, how would I go about later updating the IP address and removing the old IP from iptables with this script? I see there is a export deleterule function I believe.

How would you write the removal of 'x.x.x.x/32' from iptables via node-iptables script?

Does the script itself need to be modified to have that feature?

any help would be much appreciated. thanks!

Sign In or Register to comment.