Skip to content

Instantly share code, notes, and snippets.

Last active April 6, 2018 06:51
  • Star 5 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save socketwiz/d6fe23d19180a1ad8b5a to your computer and use it in GitHub Desktop.
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
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?

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