Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
CoreOS cloud-config for DigitalOcean with iptables firewall
# generate a new token for each unique cluster from
# specify the initial size of your cluster with ?size=X
# multi-region and multi-cloud deployments need to use $public_ipv4
advertise-client-urls: http://$private_ipv4:2379,http://$private_ipv4:4001
initial-advertise-peer-urls: http://$private_ipv4:2380
# listen on both the official ports and the legacy ports
# legacy ports can be omitted if your application doesn't depend on them
listen-peer-urls: http://$private_ipv4:2380
public-ip: $private_ipv4 # used for fleetctl ssh command
- name: etcd2.service
command: start
- name: fleet.service
command: start
- name: iptables-restore.service
enable: true
command: start
- path: /var/lib/iptables/rules-save
permissions: 0644
owner: 'root:root'
content: |
-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 -i eth1 -p tcp -s,, --dport 4001 -j ACCEPT
-A INPUT -i eth1 -p tcp -s,, --dport 2379 -j ACCEPT
-A INPUT -i eth1 -p tcp -s,, --dport 2380 -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
# the last line of the file needs to be a blank line or a comment

This comment has been minimized.

Copy link
Owner Author

socketwiz commented Dec 6, 2015

To create a token: curl -w "\n" ""

Where 3 is set to the number of hosts you are going to create. If you don't create at least that many hosts etcd2 will not come up.


This comment has been minimized.

Copy link

robyoung commented Apr 13, 2016

I think -A INPUT -p icmp -m icmp --icmp-type 0 -j ACCEPT should be -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT. The ICMP type 0 is for the echo response which is allowed by the OUTPUT ACCEPT. See

Incidentally human names can be provided for the ICMP types (echo-request, destination-unreachable and time-exceeded).


This comment has been minimized.

Copy link

nmdias commented Jan 22, 2017

@socketwiz where are you defining the $private_ipv4 variable? I can't seem to find documentation on using variables. Could you point me in the right direction?


This comment has been minimized.

Copy link

thomaswardiii commented Jan 31, 2017

@nmdias $private_ipv4 is a substituted variable that DigitalOcean replaces on their own. It's not and should not be defined by the user, but rather is replaced with the droplet's Private IPv4 address by DigitalOcean's infrastructure that creates the droplets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.