Below shell script is useful for securing two node elasticsearch cluster. To apply suitable iptables rules, just run it on each of the ES Nodes.
With this script rules are applied for:
Allowing traffic on loopback adapters.
Allowing ES Nodes to communicate each other.
Allowing incoming ssh connections.
Allowing incoming icmp (ping) requests.
Allowing outgoing DNS requests.
Allowing Access to Elasticsearch HTTP Interface.
Dropping all other traffic.