Last active
April 19, 2021 03:04
-
-
Save jimmycuadra/fe79ae8857f3f0d0cae1 to your computer and use it in GitHub Desktop.
CoreOS cloud-config for DigitalOcean with iptables firewall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
coreos: | |
etcd: | |
# generate a new token for each unique cluster from https://discovery.etcd.io/new | |
discovery: https://discovery.etcd.io/<token> | |
# multi-region deployments, multi-cloud deployments, and droplets without | |
# private networking need to use $public_ipv4 | |
addr: $private_ipv4:4001 | |
peer-addr: $private_ipv4:7001 | |
fleet: | |
public-ip: $private_ipv4 | |
units: | |
- name: etcd.service | |
command: start | |
- name: fleet.service | |
command: start | |
- name: iptables-restore.service | |
enable: true | |
write_files: | |
- path: /var/lib/iptables/rules-save | |
permissions: 0644 | |
owner: root:root | |
content: | | |
*filter | |
:INPUT DROP [0:0] | |
:FORWARD DROP [0:0] | |
:OUTPUT ACCEPT [0:0] | |
-A INPUT -i lo -j ACCEPT | |
-A INPUT -i eth1 -j ACCEPT | |
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT | |
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT | |
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT | |
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT | |
-A INPUT -p icmp -m icmp --icmp-type 0 -j ACCEPT | |
-A INPUT -p icmp -m icmp --icmp-type 3 -j ACCEPT | |
-A INPUT -p icmp -m icmp --icmp-type 11 -j ACCEPT | |
COMMIT |
I came up with a file that addresses some of the concerns mentioned here and fixes another problem that I was having. iptables doesn't seem to want to start if the rules-save file doesn't end with a newline. I was not successful in coming up with a cloud-config that would write a newline but it turns out that a comment line works as well: https://gist.github.com/socketwiz/d6fe23d19180a1ad8b5a
If anyone sees any problems with my cloud-config, please let me know.
@sjlu @socketwiz @oliver006 Any solution found for the private network security concern?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@oliver006 did you ever find a solution to locking down the private networking interface?