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.

Terra
  • 13
  • 3

3 Answers3

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.

user9517
  • 115,471
  • 20
  • 215
  • 297
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.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
2
iptables -A INPUT -p tcp --dport 7676 -s 64.222.33.44 -j ACCEPT

iptables -A INPUT -p tcp --dport 7676 -j DROP
dawud
  • 15,096
  • 3
  • 42
  • 61
Innovator
  • 507
  • 2
  • 11