Allow IPs to access Debian server on port

15 pts.
Tags:
Debian
IP address
Can any one let me know how to allow only few IPs to access a particular port on Debian server? Other IPs should be blocked?

Software/Hardware used:
Debian,

Answer Wiki

Thanks. We'll let you know when a new response is added.

I don’t know how ips work but I click add port and it works every time try restarting your computer works every time

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Subhendu Sen

    If understood correctly, you wanted to open a port on the server, while it to be reachable only from specific/ selected ip addresses. If this is the case, you can use iptables with -I command. You can check man page of iptables.

    79,860 pointsBadges:
    report
  • gajulavijay
    I can able to add iptables -I INPUT -p udp -m udp -s 123.4.88.6 --dport 3189 -j ACCEPT

    but  the entry is disappearing after server reboot.

    Is there any possible way to store those rules permanently? If so please let me know.

    I am using Debian 8 Server. 
    15 pointsBadges:
    report
  • Subhendu Sen
    If you want to run this command at the start up, you can write a script and put this one in/etc/init.d and make it executable. Or if you want to run this particular time/sequence, try for crontab. Check manual for crontab.
    79,860 pointsBadges:
    report
  • Rogniat
    You can also iptables-persistent package or save the rules in a file:


     iptables-save > /etc/iptables.up.rules
    To make sure the iptables rules are started on a reboot we'll create a new file:


     editor /etc/network/if-pre-up.d/iptables
    Add these lines to it:

     #!/bin/sh
     /sbin/iptables-restore < /etc/iptables.up.rules

    Give the correct permisisons rights:


     chmod +x /etc/network/if-pre-up.d/iptables

    And you rules will be loaded when you reboot!
    10 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: