Configuring IPTABLES to work with AWS hosts (like *.crashlytics.com)

The problem

-A FORWARD -s xx.xx.xx.xx -d settings.crashlytics.com -j ACCEPT

Why’s that?

-A FORWARD -s xx.xx.xx.xx -d dns.resolved.ip.address -j ACCEPT

Why it’s wrong?

dig settings.crashlytics.com; <<>> DiG 9.9.4-RedHat-9.9.4-38.el7_3.3 <<>> settings.crashlytics.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34220
;; flags: qr rd ra; QUERY: 1, ANSWER: 9, AUTHORITY: 4, ADDITIONAL: 1;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;settings.crashlytics.com.      IN      A;; ANSWER SECTION:
settings.crashlytics.com. 60    IN      CNAME   settings-crashlytics-1410998606.us-east-1.elb.amazonaws.com.
settings-crashlytics-1410998606.us-east-1.elb.amazonaws.com. 60 IN A 54.197.241.124
settings-crashlytics-1410998606.us-east-1.elb.amazonaws.com. 60 IN A 54.225.212.15
settings-crashlytics-1410998606.us-east-1.elb.amazonaws.com. 60 IN A 50.19.89.237
settings-crashlytics-1410998606.us-east-1.elb.amazonaws.com. 60 IN A 54.225.152.187
settings-crashlytics-1410998606.us-east-1.elb.amazonaws.com. 60 IN A 23.23.254.42
settings-crashlytics-1410998606.us-east-1.elb.amazonaws.com. 60 IN A 23.23.96.14
settings-crashlytics-1410998606.us-east-1.elb.amazonaws.com. 60 IN A 50.19.85.98
settings-crashlytics-1410998606.us-east-1.elb.amazonaws.com. 60 IN A 50.16.244.33;; AUTHORITY SECTION:
us-east-1.elb.amazonaws.com. 300 IN     NS      ns-934.awsdns-52.net.
us-east-1.elb.amazonaws.com. 300 IN     NS      ns-1793.awsdns-32.co.uk.
us-east-1.elb.amazonaws.com. 300 IN     NS      ns-235.awsdns-29.com.
us-east-1.elb.amazonaws.com. 300 IN     NS      ns-1119.awsdns-11.org.;; Query time: 224 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Sep 08 14:32:48 CEST 2017
;; MSG SIZE  rcvd: 388

The solution

What steps have to be done by the script?

IPTABLES configuration file structure

*nat
...
rules
COMMIT
# AWS CRON
# AWS CRON END

The code

Feedback?


Pawel Urban blog

Pawel Urban personal blog — Java, Kotlin, Android and software engineering in general

Paweł Urban

Written by

Senior Android Developer @ Objectivity | Freelancer | Trainer

Pawel Urban blog

Pawel Urban personal blog — Java, Kotlin, Android and software engineering in general