Code Monkey home page Code Monkey logo

terraform-tailscale's Introduction

Header

General outline of the project

This project is meant to configure an existing tailnet with custom DNS, keys and ACLs.

  1. Configure a custom DNS server other than MagicDNS. That's done in order to resolve requests for an internally configured proxy.
  2. Disable key expity on crucial infrastructure nodes like the DNS server, Docker server, etc.
  3. Set ACL rules to prevent unwanted communication between nodes. This is useful when your tailnet has different people and you don't want them to see the rest of the network. The ACL are based on node tags.
  4. Tag nodes. They are tagged recursively, based on a naming convention. The name of each node has:
    • The type of node - server, client, device
    • The access stage - whether or not this node should be public or private. A public node can be accessed by all other nodes on the network, opposed to a private one.
    • The access role - insider and outsider. You, the admin are an insider. Your SO are insiders. The discord friend you gave access to, is an outsider. They can see only public nodes.
    • The location - personally, I use a 3-letter abbr for different cities as my nodes are all accross the country.
    • The name - Docker, adguard, pihole, gitea. Initials for people - John Doe > jd.

πŸ“ƒ Prerequisites

  1. A Tailscale network with some devices
  2. A Tailscale API key
  3. A device naming convention like so: type-access-role-location-name

πŸ“ Naming components

  1. Type*
    • server
    • laptop
    • phone
  2. Access*
    • public
    • private
  3. Role*
    • insider
    • outsider
  4. Location
    • London > lon
    • Sofia > sof
  5. Name
    • docker
    • adguard
    • John Doe > jd

⚠️ * If you are using other type, access and role tags, you need to define them in the ACL config under tagOwners. Otherwise they will not be applied.

πŸ”€ Possible combinations

All nodes require type, access and role defined. By combining them, you can achieve a basic but sufficient in most cases accsess control.

type-access-role-location-name

server-public-insider-sof-docker
laptop-private-outsider-sof-jd

Π•ΠΉΡŒΠΏΠ·Π²Π΅

πŸ’‘ Commands used in this project

terraform init -upgrade

terraform apply -auto-approve

terraform apply -destroy -auto-approve

πŸ“ Variables used in this project

Rename the variables.auto.tfvars.example to variables.auto.tfvars and fill it in.

TAILSCALE_TAILNET = "[email protected]"
# https://login.tailscale.com/admin/settings/keys
# Temp API key. 90 days since 25/04/2023
TAILSCALE_API_KEY = "tskey-api-yourapikeyhere"

TAILSCALE_DNS_SRV = "server-public-insider-your-dns-server-name"

TAILSCALE_ACL = {
    
    # https://tailscale.com/kb/1018/acls/#tag-owners
    # It's important to define all the tags that you are going to use in the machine names here.
    "tagOwners": {
      "tag:server":   ["[email protected]"],
      "tag:laptop":   ["[email protected]"],
      "tag:phone":    ["[email protected]"],
      "tag:outsider": ["[email protected]"],
      "tag:insider":  ["[email protected]"],
      "tag:public":   ["[email protected]"],
      "tag:private":  ["[email protected]"],
    },
   
    # https://tailscale.com/kb/1068/acl-tags/#acls
    "acls" : [
      # Match absolutely everything.
      # {"action": "accept", "src": ["*"], "dst": ["*:*"]},
      {
        "action": "accept",
        "src":    ["tag:insider"],
        "dst":    ["tag:public:*", "tag:private:*"],
      },
      {
        "action": "accept",
        "src":    ["tag:outsider"],
        "dst":    ["tag:public:443", "tag:public:80", "tag:public:53"],
      },
    ],
  }

πŸ“– Relevant Documentation

🌟 Terraform Docker Provider

🌟 Terraform Tailscale Provider

🌟 Tailscale Docs

🌟 Misc useful resources

terraform-tailscale's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.