1

Suppose I have an internal service running on port 7676, how would I (On CentOS) block port 7676 from external sources, so that it can only be accessed locally - AKA 127.0.0.1, not using, for example, 64.222.33.44 - the external IP.

1
  • 1
    You use iptables. Read man iptables to learn how.
    – dawud
    Jun 21, 2014 at 22:27

3 Answers 3

3

You could use iptables for this. What you have go do is insert a DROP rule into the INPUT chain for packets with a destination address of your external IP 64.222.33.44 and a destination port of 7676.

2

If the service software allows binding to specific IP addresses, you can bind it to 127.0.0.1 address.

This means it will listen to requests only arriving via the localhost interface.

2
iptables -A INPUT -p tcp --dport 7676 -s 64.222.33.44 -j ACCEPT

iptables -A INPUT -p tcp --dport 7676 -j DROP

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .