SlideShare uma empresa Scribd logo
1 de 24
OpenBSD and AWS
September 23rd 2017EuroBSDcon
@eurobsdcon
Who am I?
2
Laurent Bernaille @d2si
• Linux background, getting to know OpenBSD
• Cloud enthusiast
• Love discovering, building (and breaking…) new things
@lbernail
@eurobsdcon
What is this presentation/demo about?
OpenBSD and AWS
• The first OpenBSD image and the ongoing work
• The integration in the AWS ecosystem
OpenBSD and microservices
• How we can leverage OpenBSD for cloud applications
• Examples and demo
OpenBSD and me
• A recent but interesting journey
@eurobsdcon
OpenBSD on AWS
First image by @ajacoutot (December 2015, in 5.9)
• Not straightforward due to Xen support (network, disk in particular)
• Intro: http://blog.d2-si.fr/2016/02/15/openbsd-on-aws/
• Details: https://github.com/ajacoutot/aws-openbsd
• More details: http://www.openbsd.org/papers/bsdcan2016-xen.pdf
=> The image worked, but without EBS (disk) support at first
=> Xen support was not perfect
An AWS hypervisor update broke the AMI (late 2016)
Fixed in 6.1, thanks to Mike Belopuhov and @esdenera
Many improvements in 6.2 (performances)
@eurobsdcon
Let's have a look
@eurobsdcon
Where does my public key come from?
AWS exposes a metadata web server at http://169.254.169.254
@eurobsdcon
OK but how did it get into authorized_keys?
Linux distributions rely on cloud-init
• http://cloudinit.readthedocs.io/
• Origin in ubuntu cloud
• Cloud-init does a lot of things and is very Linux specific
Enters ec2-init by @ajacoutot
• Minimal cloud-init implementation
• https://github.com/ajacoutot/aws-openbsd
When is it run?
• By netstart (very early in the boot process)
@eurobsdcon
A quick look at ec2-init
mock_pf open
if [[ $(mock meta-data/instance-id) != $(cat /var/db/ec2-init 2>/dev/null) ]]; then
ec2_instanceid
ec2_pubkey
ec2_hostname
ec2_userdata
ec2_fingerprints
sysclean
fi
mock_pf close
open pf to allow access to metadata server
check if already configured
write instance id to db file to set instance as "configured"
write public key in authorized_keys file
set hostname from AWS metadata
execute userdata (more on that later)
write rc.firsttime script to display ssh fingerprints after boot
clean up instance (remove old ssh keys, logs, dhcp data)
@eurobsdcon
What about this ec2-user?
Standard behavior on AWS
• No connection as root
• ec2-user is used for Amazon Linux, Redhat, Fedora, Centos, FreeBSD
• Debian uses "admin" and ubuntu, "ubuntu"
ec2-user has unlimited doas with "nopass"
$ cat /etc/doas.conf
permit nopass ec2-user
@eurobsdcon
Let's use this instance
Install terraform
$ pkg_info -Q terraform
terraform-0.9.2
$ doas pkg_add terraform
Terraform?
• Describe infrastructure components and build them
• « puppet » for infrastructure
• Alternatives: cloudformation / heat
OK let's set up something with it
$ doas pkg_add git
$ git clone git@github.com:lbernail/eurobsdcon2017.git
$ terraform init
$ terraform plan
$ terraform apply
@eurobsdcon
Under the hood
Bastion
eu-west-1a
Public subnets
Private subnets
eu-west-1b
Public subnets
Private subnets
resource "aws_vpc" "main" {
cidr_block = "10.100.0.0/16"
}
resource "aws_subnet" "public" {
vpc_id = "${aws_vpc.main.id}"
cidr_block = "10.100.1.0/24"
tags { Name = "Main" }
}
resource "aws_instance" "bastion" {
ami = "${var.bastion_ami}"
instance_type = "t2.micro”
subnet_id = "${aws_subnet.public.id}"
vpc_security_group_ids = [ "${aws_security_group.bastion.id}" ]
tags { Name = "bastion" }
}
@eurobsdcon 12
Bastion
Public subnets
NAT
GW
Public subnets Public subnets
What did we just build?
Private subnets Private subnetsPrivate subnets
@eurobsdcon 13
Bastion
Public subnets
NAT
GW
Public subnets Public subnets
CAg
(UI)
CS
Let’s create a consul cluster
10.0.128.100
consul0
CS
10.0.129.100
consul1
CS
10.0.130.100
consul2
10.0.128.200
consul-agent
@eurobsdcon
A quick intro to consul
From Hashicorp (authors of vagrant, packer, terraform, vault)
Used for microservices
• Service discovery
• Key-value store for configuration
Resilient
• Distributed system
• Built on RAFT
@eurobsdcon
Let's look at it
$ ssh 10.0.128.100
$ consul members
@eurobsdcon
OK but how did it all get configured?
Userdata: script to bootstrap AWS instances (executed by ec2-init)
$ ftp -MVo - http://169.254.169.254/latest/user-data
#!/bin/sh
pkg_add consul
cat > /etc/consul.d/config.json <<EOF
{
"bootstrap_expect": 3,
"server": true,
"node_name": "consul0",
"retry_join_ec2" :
{
"tag_key": "ConsulCluster",
"tag_value": "Consul"
}
}
EOF
rcctl enable consul
cat >> /etc/rc.firsttime <<EOF
rcctl start consul
EOF
install consul
this node is a server called consul0
it will wait for 2 other servers to bootstrap cluster
rely on AWS API to discover members
- instances have a "tag"
- instances have a role granting them access to AWS APIs
"enable" writes to /etc/rc.conf.local
but rc parses rc.conf.local very early so consul won't start
=> we use rc.firsttime
@eurobsdcon
What can we do with this?
Dynamic VPN configuration with consul-template
• A companion tool to Consul
• Watches for key changes in Consul
• Generates a file from a template
• Optionally executes a command when the file changes
Let's build a VPN gateway
$ cd ../vpn
$ terraform init
$ terraform apply
@eurobsdcon 18
Bastion
Public subnets
NAT
GW
Public subnets Public subnets
CAg
(UI)
CS
New architecture
10.0.128.100
consul0
CS
10.0.129.100
consul1
CS
10.0.130.100
consul2
10.0.128.200
consul-agent
VPN
10.0.0.10
@eurobsdcon
What is this VPN server? 1/2
$ ftp -MVo - http://169.254.169.254/latest/user-data
#!/bin/sh
rcctl enable ipsec
rcctl enable isakmpd
rcctl set isakmpd flags -K
install -m 0600 /dev/null /etc/ipsec.conf
pkg_add consul
cat > /etc/consul.d/config.json <<EOF
{
"server": false,
"node_name": "vpn",
"retry_join_ec2" :
{
"tag_key": "ConsulCluster",
"tag_value": "Consul"
}
}
EOF
enable ipsec
install consul
configure it as a client
@eurobsdcon
What is this VPN server? 2/2
pkg_add consul-template
cat > /etc/consul-template.d/default.conf << EOF
consul {
address = "127.0.0.1:8500"
}
template {
source = "/etc/consul-template.d/ipsec.ctmpl"
destination = "/etc/ipsec.conf"
perms = 0600
command = "ipsecctl -f /etc/ipsec.conf || echo Invalid ipsec configuration"
}
EOF
# Template
cat > /etc/consul-template.d/ipsec.ctmpl << 'EOF'
{{ range tree "vpn" | explode -}}
{{ if and .cidrblock .endpoint .psk -}}
ike esp from 10.0.0.0/16 to {{ .cidrblock }} 
peer {{ .endpoint }} 
srcid 34.252.210.92 
psk "{{ .psk }}"
{{ end -}}
{{ end }}
EOF
install consul-template
use local consul
Template configuration
- template file
- target
- command to execute on change
template file to generate ipsec.conf
@eurobsdcon
The template file
{{ range tree "vpn" | explode -}}
{{ if and .cidrblock .endpoint .psk -}}
ike esp from 10.0.0.0/16 to {{ .cidrblock }} 
peer {{ .endpoint }} 
psk "{{ .psk }}"
srcid 34.252.210.92 
{{ end -}}
{{ end }}
get all keys under "vpn"
iterate over them
transform items in maps
if we have values for all necessary keys
generate ipsec configuration
configuration keys
local public IP (injected by terraform)
vpn/
/us/
/cidrblock = 172.30.0.0/16
/endpoint = 32.32.32.32
/psk = demo
ike esp from 10.0.0.0/16 to 172.30.0.0/16 
peer 32.32.32.32 
psk "demo" 
srcid 34.252.210.92
@eurobsdcon
Let's look at this
$ consul members
$ rcctl check consul consul_template
$ cat /etc/consul-template.d/ipsec.ctmpl
$ doas cat /etc/ipsec.conf
$ doas ipsecctl -s all
@eurobsdcon
Building our VPN
Bastion
Public subnets
NAT
GW
Public subnets Public subnets
CAg
(UI)
CS
10.0.128.100
consul0
CS
10.0.129.100
consul1
CS
10.0.130.100
consul2
10.0.128.200
consul-agent
VPN
10.0.0.10
Ireland, 10.0.0.0/16
Virginia, 172.30.0.0/16
EIP: 34.252.210.92
Demo 172.30.x.y
allow ICMP from 10.0.0.0/16
@eurobsdcon
Conclusion and perspectives
What could be improved in this example
• Security of consul: SSL / ACL
My (limited) usage of OpenBSD on AWS
• VPN Gateways
• DNS proxies
• And now consul
• Many potential other use-cases
Look at / Fork the code of this demo on github
https://github.com/lbernail/eurobsdcon2017
Questions ? @lbernail

Mais conteúdo relacionado

Mais procurados

AWSome Day 2016 - Module 1: AWS Introduction and History
AWSome Day 2016 - Module 1: AWS Introduction and HistoryAWSome Day 2016 - Module 1: AWS Introduction and History
AWSome Day 2016 - Module 1: AWS Introduction and History
Amazon Web Services
 
[AWSマイスターシリーズ] AWS Billingについて
[AWSマイスターシリーズ] AWS Billingについて[AWSマイスターシリーズ] AWS Billingについて
[AWSマイスターシリーズ] AWS Billingについて
Amazon Web Services Japan
 
EUDI wallets with OpenID for verifiable credentials (OID4VCI/OID4VP)
EUDI wallets with OpenID for verifiable credentials (OID4VCI/OID4VP)EUDI wallets with OpenID for verifiable credentials (OID4VCI/OID4VP)
EUDI wallets with OpenID for verifiable credentials (OID4VCI/OID4VP)
Lal Chandran
 

Mais procurados (20)

Cloud Computing with AWS & Other Cloud Platforms
Cloud Computing with AWS & Other Cloud PlatformsCloud Computing with AWS & Other Cloud Platforms
Cloud Computing with AWS & Other Cloud Platforms
 
Running Microsoft SharePoint On AWS - Smartronix and AWS - Webinar
Running Microsoft SharePoint On AWS - Smartronix and AWS - WebinarRunning Microsoft SharePoint On AWS - Smartronix and AWS - Webinar
Running Microsoft SharePoint On AWS - Smartronix and AWS - Webinar
 
Cost efficiencies and security best practices with Amazon S3 storage - STG301...
Cost efficiencies and security best practices with Amazon S3 storage - STG301...Cost efficiencies and security best practices with Amazon S3 storage - STG301...
Cost efficiencies and security best practices with Amazon S3 storage - STG301...
 
[AWS Builders] AWS상의 보안 위협 탐지 및 대응
[AWS Builders] AWS상의 보안 위협 탐지 및 대응[AWS Builders] AWS상의 보안 위협 탐지 및 대응
[AWS Builders] AWS상의 보안 위협 탐지 및 대응
 
AWSome Day 2016 - Module 1: AWS Introduction and History
AWSome Day 2016 - Module 1: AWS Introduction and HistoryAWSome Day 2016 - Module 1: AWS Introduction and History
AWSome Day 2016 - Module 1: AWS Introduction and History
 
Enterprise Governance: Build Your AWS Landing Zone (ENT351-R1) - AWS re:Inven...
Enterprise Governance: Build Your AWS Landing Zone (ENT351-R1) - AWS re:Inven...Enterprise Governance: Build Your AWS Landing Zone (ENT351-R1) - AWS re:Inven...
Enterprise Governance: Build Your AWS Landing Zone (ENT351-R1) - AWS re:Inven...
 
Building a Data Lake on AWS
Building a Data Lake on AWSBuilding a Data Lake on AWS
Building a Data Lake on AWS
 
[AWSマイスターシリーズ] AWS Billingについて
[AWSマイスターシリーズ] AWS Billingについて[AWSマイスターシリーズ] AWS Billingについて
[AWSマイスターシリーズ] AWS Billingについて
 
S3 Event Notifications やってみた
S3 Event Notifications やってみたS3 Event Notifications やってみた
S3 Event Notifications やってみた
 
Networking Many VPCs: Transit and Shared Architectures - NET404 - re:Invent 2017
Networking Many VPCs: Transit and Shared Architectures - NET404 - re:Invent 2017Networking Many VPCs: Transit and Shared Architectures - NET404 - re:Invent 2017
Networking Many VPCs: Transit and Shared Architectures - NET404 - re:Invent 2017
 
B4. SORACOM で守る IoT のエンドツーエンド・セキュリティ | SORACOM Technology Camp 2020
B4. SORACOM で守る IoT のエンドツーエンド・セキュリティ | SORACOM Technology Camp 2020B4. SORACOM で守る IoT のエンドツーエンド・セキュリティ | SORACOM Technology Camp 2020
B4. SORACOM で守る IoT のエンドツーエンド・セキュリティ | SORACOM Technology Camp 2020
 
AWS를 활용한 글로벌 아키텍처 운용 전략 - 김상필 솔루션즈 아키텍트:: AWS Cloud Track 2 Advanced
AWS를 활용한 글로벌 아키텍처 운용 전략 - 김상필 솔루션즈 아키텍트:: AWS Cloud Track 2 AdvancedAWS를 활용한 글로벌 아키텍처 운용 전략 - 김상필 솔루션즈 아키텍트:: AWS Cloud Track 2 Advanced
AWS를 활용한 글로벌 아키텍처 운용 전략 - 김상필 솔루션즈 아키텍트:: AWS Cloud Track 2 Advanced
 
AWS 初心者向けWebinar Amazon Web Services料金の見積り方法 -料金計算の考え方・見積り方法・お支払方法-
AWS 初心者向けWebinar Amazon Web Services料金の見積り方法 -料金計算の考え方・見積り方法・お支払方法-AWS 初心者向けWebinar Amazon Web Services料金の見積り方法 -料金計算の考え方・見積り方法・お支払方法-
AWS 初心者向けWebinar Amazon Web Services料金の見積り方法 -料金計算の考え方・見積り方法・お支払方法-
 
현대백화점 리테일테크랩과 AWS Prototyping 팀 개발자가 들려주는 인공 지능 무인 스토어 개발 여정 - 최권열 AWS 프로토타이핑...
현대백화점 리테일테크랩과 AWS Prototyping 팀 개발자가 들려주는 인공 지능 무인 스토어 개발 여정 - 최권열 AWS 프로토타이핑...현대백화점 리테일테크랩과 AWS Prototyping 팀 개발자가 들려주는 인공 지능 무인 스토어 개발 여정 - 최권열 AWS 프로토타이핑...
현대백화점 리테일테크랩과 AWS Prototyping 팀 개발자가 들려주는 인공 지능 무인 스토어 개발 여정 - 최권열 AWS 프로토타이핑...
 
Amazon Virtual Private Cloud
Amazon Virtual Private CloudAmazon Virtual Private Cloud
Amazon Virtual Private Cloud
 
AWS Black Belt Techシリーズ Amazon WorkDocs / Amazon WorkMail
AWS Black Belt Techシリーズ Amazon WorkDocs / Amazon WorkMailAWS Black Belt Techシリーズ Amazon WorkDocs / Amazon WorkMail
AWS Black Belt Techシリーズ Amazon WorkDocs / Amazon WorkMail
 
CCS335 – CLOUD COMPUTING.pptx
CCS335 – CLOUD COMPUTING.pptxCCS335 – CLOUD COMPUTING.pptx
CCS335 – CLOUD COMPUTING.pptx
 
(2014년) Active Active 데이터센터
(2014년) Active Active 데이터센터(2014년) Active Active 데이터센터
(2014년) Active Active 데이터센터
 
IAM Roles Anywhereのない世界とある世界(2022年のAWSアップデートを振り返ろう ~Season 4~ 発表資料)
IAM Roles Anywhereのない世界とある世界(2022年のAWSアップデートを振り返ろう ~Season 4~ 発表資料)IAM Roles Anywhereのない世界とある世界(2022年のAWSアップデートを振り返ろう ~Season 4~ 発表資料)
IAM Roles Anywhereのない世界とある世界(2022年のAWSアップデートを振り返ろう ~Season 4~ 発表資料)
 
EUDI wallets with OpenID for verifiable credentials (OID4VCI/OID4VP)
EUDI wallets with OpenID for verifiable credentials (OID4VCI/OID4VP)EUDI wallets with OpenID for verifiable credentials (OID4VCI/OID4VP)
EUDI wallets with OpenID for verifiable credentials (OID4VCI/OID4VP)
 

Semelhante a Discovering OpenBSD on AWS

Semelhante a Discovering OpenBSD on AWS (20)

Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013
 
Amazon Web Services and Docker: from developing to production
Amazon Web Services and Docker: from developing to productionAmazon Web Services and Docker: from developing to production
Amazon Web Services and Docker: from developing to production
 
Automating aws infrastructure and code deployments using Ansible @WebEngage
Automating aws infrastructure and code deployments using Ansible @WebEngageAutomating aws infrastructure and code deployments using Ansible @WebEngage
Automating aws infrastructure and code deployments using Ansible @WebEngage
 
Agile Brown Bag - Vagrant & Docker: Introduction
Agile Brown Bag - Vagrant & Docker: IntroductionAgile Brown Bag - Vagrant & Docker: Introduction
Agile Brown Bag - Vagrant & Docker: Introduction
 
Docker Multi-arch All The Things
Docker Multi-arch All The ThingsDocker Multi-arch All The Things
Docker Multi-arch All The Things
 
Infrastructureascode slideshare-160331143725
Infrastructureascode slideshare-160331143725Infrastructureascode slideshare-160331143725
Infrastructureascode slideshare-160331143725
 
Infrastructureascode slideshare-160331143725
Infrastructureascode slideshare-160331143725Infrastructureascode slideshare-160331143725
Infrastructureascode slideshare-160331143725
 
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
 
OpenCloudDay 2014: Deploying trusted developer sandboxes in Amazon's cloud
OpenCloudDay 2014: Deploying trusted developer sandboxes in Amazon's cloudOpenCloudDay 2014: Deploying trusted developer sandboxes in Amazon's cloud
OpenCloudDay 2014: Deploying trusted developer sandboxes in Amazon's cloud
 
Sheep it
Sheep itSheep it
Sheep it
 
ContainerDayVietnam2016: Docker for JS Developer
ContainerDayVietnam2016: Docker for JS DeveloperContainerDayVietnam2016: Docker for JS Developer
ContainerDayVietnam2016: Docker for JS Developer
 
AWS 기반 Docker, Kubernetes
AWS 기반 Docker, KubernetesAWS 기반 Docker, Kubernetes
AWS 기반 Docker, Kubernetes
 
CoreOS, or How I Learned to Stop Worrying and Love Systemd
CoreOS, or How I Learned to Stop Worrying and Love SystemdCoreOS, or How I Learned to Stop Worrying and Love Systemd
CoreOS, or How I Learned to Stop Worrying and Love Systemd
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with Docker
 
How to create your own hack environment
How to create your own hack environmentHow to create your own hack environment
How to create your own hack environment
 
Ufo Ship for AWS ECS
Ufo Ship for AWS ECSUfo Ship for AWS ECS
Ufo Ship for AWS ECS
 
One-Man Ops
One-Man OpsOne-Man Ops
One-Man Ops
 
Bare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and ChefBare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and Chef
 
Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)
 
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container ServiceScaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
 

Mais de Laurent Bernaille

Mais de Laurent Bernaille (17)

How the OOM Killer Deleted My Namespace
How the OOM Killer Deleted My NamespaceHow the OOM Killer Deleted My Namespace
How the OOM Killer Deleted My Namespace
 
Kubernetes DNS Horror Stories
Kubernetes DNS Horror StoriesKubernetes DNS Horror Stories
Kubernetes DNS Horror Stories
 
Evolution of kube-proxy (Brussels, Fosdem 2020)
Evolution of kube-proxy (Brussels, Fosdem 2020)Evolution of kube-proxy (Brussels, Fosdem 2020)
Evolution of kube-proxy (Brussels, Fosdem 2020)
 
Making the most out of kubernetes audit logs
Making the most out of kubernetes audit logsMaking the most out of kubernetes audit logs
Making the most out of kubernetes audit logs
 
Kubernetes the Very Hard Way. Velocity Berlin 2019
Kubernetes the Very Hard Way. Velocity Berlin 2019Kubernetes the Very Hard Way. Velocity Berlin 2019
Kubernetes the Very Hard Way. Velocity Berlin 2019
 
Kubernetes the Very Hard Way. Lisa Portland 2019
Kubernetes the Very Hard Way. Lisa Portland 2019Kubernetes the Very Hard Way. Lisa Portland 2019
Kubernetes the Very Hard Way. Lisa Portland 2019
 
10 ways to shoot yourself in the foot with kubernetes, #9 will surprise you! ...
10 ways to shoot yourself in the foot with kubernetes, #9 will surprise you! ...10 ways to shoot yourself in the foot with kubernetes, #9 will surprise you! ...
10 ways to shoot yourself in the foot with kubernetes, #9 will surprise you! ...
 
10 ways to shoot yourself in the foot with kubernetes, #9 will surprise you!
10 ways to shoot yourself in the foot with kubernetes, #9 will surprise you!10 ways to shoot yourself in the foot with kubernetes, #9 will surprise you!
10 ways to shoot yourself in the foot with kubernetes, #9 will surprise you!
 
Optimizing kubernetes networking
Optimizing kubernetes networkingOptimizing kubernetes networking
Optimizing kubernetes networking
 
Kubernetes at Datadog the very hard way
Kubernetes at Datadog the very hard wayKubernetes at Datadog the very hard way
Kubernetes at Datadog the very hard way
 
Deep Dive in Docker Overlay Networks
Deep Dive in Docker Overlay NetworksDeep Dive in Docker Overlay Networks
Deep Dive in Docker Overlay Networks
 
Deeper dive in Docker Overlay Networks
Deeper dive in Docker Overlay NetworksDeeper dive in Docker Overlay Networks
Deeper dive in Docker Overlay Networks
 
Operational challenges behind Serverless architectures
Operational challenges behind Serverless architecturesOperational challenges behind Serverless architectures
Operational challenges behind Serverless architectures
 
Deep dive in Docker Overlay Networks
Deep dive in Docker Overlay NetworksDeep dive in Docker Overlay Networks
Deep dive in Docker Overlay Networks
 
Feedback on AWS re:invent 2016
Feedback on AWS re:invent 2016Feedback on AWS re:invent 2016
Feedback on AWS re:invent 2016
 
Early recognition of encryted applications
Early recognition of encryted applicationsEarly recognition of encryted applications
Early recognition of encryted applications
 
Early application identification. CONEXT 2006
Early application identification. CONEXT 2006Early application identification. CONEXT 2006
Early application identification. CONEXT 2006
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Discovering OpenBSD on AWS

  • 1. OpenBSD and AWS September 23rd 2017EuroBSDcon
  • 2. @eurobsdcon Who am I? 2 Laurent Bernaille @d2si • Linux background, getting to know OpenBSD • Cloud enthusiast • Love discovering, building (and breaking…) new things @lbernail
  • 3. @eurobsdcon What is this presentation/demo about? OpenBSD and AWS • The first OpenBSD image and the ongoing work • The integration in the AWS ecosystem OpenBSD and microservices • How we can leverage OpenBSD for cloud applications • Examples and demo OpenBSD and me • A recent but interesting journey
  • 4. @eurobsdcon OpenBSD on AWS First image by @ajacoutot (December 2015, in 5.9) • Not straightforward due to Xen support (network, disk in particular) • Intro: http://blog.d2-si.fr/2016/02/15/openbsd-on-aws/ • Details: https://github.com/ajacoutot/aws-openbsd • More details: http://www.openbsd.org/papers/bsdcan2016-xen.pdf => The image worked, but without EBS (disk) support at first => Xen support was not perfect An AWS hypervisor update broke the AMI (late 2016) Fixed in 6.1, thanks to Mike Belopuhov and @esdenera Many improvements in 6.2 (performances)
  • 6. @eurobsdcon Where does my public key come from? AWS exposes a metadata web server at http://169.254.169.254
  • 7. @eurobsdcon OK but how did it get into authorized_keys? Linux distributions rely on cloud-init • http://cloudinit.readthedocs.io/ • Origin in ubuntu cloud • Cloud-init does a lot of things and is very Linux specific Enters ec2-init by @ajacoutot • Minimal cloud-init implementation • https://github.com/ajacoutot/aws-openbsd When is it run? • By netstart (very early in the boot process)
  • 8. @eurobsdcon A quick look at ec2-init mock_pf open if [[ $(mock meta-data/instance-id) != $(cat /var/db/ec2-init 2>/dev/null) ]]; then ec2_instanceid ec2_pubkey ec2_hostname ec2_userdata ec2_fingerprints sysclean fi mock_pf close open pf to allow access to metadata server check if already configured write instance id to db file to set instance as "configured" write public key in authorized_keys file set hostname from AWS metadata execute userdata (more on that later) write rc.firsttime script to display ssh fingerprints after boot clean up instance (remove old ssh keys, logs, dhcp data)
  • 9. @eurobsdcon What about this ec2-user? Standard behavior on AWS • No connection as root • ec2-user is used for Amazon Linux, Redhat, Fedora, Centos, FreeBSD • Debian uses "admin" and ubuntu, "ubuntu" ec2-user has unlimited doas with "nopass" $ cat /etc/doas.conf permit nopass ec2-user
  • 10. @eurobsdcon Let's use this instance Install terraform $ pkg_info -Q terraform terraform-0.9.2 $ doas pkg_add terraform Terraform? • Describe infrastructure components and build them • « puppet » for infrastructure • Alternatives: cloudformation / heat OK let's set up something with it $ doas pkg_add git $ git clone git@github.com:lbernail/eurobsdcon2017.git $ terraform init $ terraform plan $ terraform apply
  • 11. @eurobsdcon Under the hood Bastion eu-west-1a Public subnets Private subnets eu-west-1b Public subnets Private subnets resource "aws_vpc" "main" { cidr_block = "10.100.0.0/16" } resource "aws_subnet" "public" { vpc_id = "${aws_vpc.main.id}" cidr_block = "10.100.1.0/24" tags { Name = "Main" } } resource "aws_instance" "bastion" { ami = "${var.bastion_ami}" instance_type = "t2.micro” subnet_id = "${aws_subnet.public.id}" vpc_security_group_ids = [ "${aws_security_group.bastion.id}" ] tags { Name = "bastion" } }
  • 12. @eurobsdcon 12 Bastion Public subnets NAT GW Public subnets Public subnets What did we just build? Private subnets Private subnetsPrivate subnets
  • 13. @eurobsdcon 13 Bastion Public subnets NAT GW Public subnets Public subnets CAg (UI) CS Let’s create a consul cluster 10.0.128.100 consul0 CS 10.0.129.100 consul1 CS 10.0.130.100 consul2 10.0.128.200 consul-agent
  • 14. @eurobsdcon A quick intro to consul From Hashicorp (authors of vagrant, packer, terraform, vault) Used for microservices • Service discovery • Key-value store for configuration Resilient • Distributed system • Built on RAFT
  • 15. @eurobsdcon Let's look at it $ ssh 10.0.128.100 $ consul members
  • 16. @eurobsdcon OK but how did it all get configured? Userdata: script to bootstrap AWS instances (executed by ec2-init) $ ftp -MVo - http://169.254.169.254/latest/user-data #!/bin/sh pkg_add consul cat > /etc/consul.d/config.json <<EOF { "bootstrap_expect": 3, "server": true, "node_name": "consul0", "retry_join_ec2" : { "tag_key": "ConsulCluster", "tag_value": "Consul" } } EOF rcctl enable consul cat >> /etc/rc.firsttime <<EOF rcctl start consul EOF install consul this node is a server called consul0 it will wait for 2 other servers to bootstrap cluster rely on AWS API to discover members - instances have a "tag" - instances have a role granting them access to AWS APIs "enable" writes to /etc/rc.conf.local but rc parses rc.conf.local very early so consul won't start => we use rc.firsttime
  • 17. @eurobsdcon What can we do with this? Dynamic VPN configuration with consul-template • A companion tool to Consul • Watches for key changes in Consul • Generates a file from a template • Optionally executes a command when the file changes Let's build a VPN gateway $ cd ../vpn $ terraform init $ terraform apply
  • 18. @eurobsdcon 18 Bastion Public subnets NAT GW Public subnets Public subnets CAg (UI) CS New architecture 10.0.128.100 consul0 CS 10.0.129.100 consul1 CS 10.0.130.100 consul2 10.0.128.200 consul-agent VPN 10.0.0.10
  • 19. @eurobsdcon What is this VPN server? 1/2 $ ftp -MVo - http://169.254.169.254/latest/user-data #!/bin/sh rcctl enable ipsec rcctl enable isakmpd rcctl set isakmpd flags -K install -m 0600 /dev/null /etc/ipsec.conf pkg_add consul cat > /etc/consul.d/config.json <<EOF { "server": false, "node_name": "vpn", "retry_join_ec2" : { "tag_key": "ConsulCluster", "tag_value": "Consul" } } EOF enable ipsec install consul configure it as a client
  • 20. @eurobsdcon What is this VPN server? 2/2 pkg_add consul-template cat > /etc/consul-template.d/default.conf << EOF consul { address = "127.0.0.1:8500" } template { source = "/etc/consul-template.d/ipsec.ctmpl" destination = "/etc/ipsec.conf" perms = 0600 command = "ipsecctl -f /etc/ipsec.conf || echo Invalid ipsec configuration" } EOF # Template cat > /etc/consul-template.d/ipsec.ctmpl << 'EOF' {{ range tree "vpn" | explode -}} {{ if and .cidrblock .endpoint .psk -}} ike esp from 10.0.0.0/16 to {{ .cidrblock }} peer {{ .endpoint }} srcid 34.252.210.92 psk "{{ .psk }}" {{ end -}} {{ end }} EOF install consul-template use local consul Template configuration - template file - target - command to execute on change template file to generate ipsec.conf
  • 21. @eurobsdcon The template file {{ range tree "vpn" | explode -}} {{ if and .cidrblock .endpoint .psk -}} ike esp from 10.0.0.0/16 to {{ .cidrblock }} peer {{ .endpoint }} psk "{{ .psk }}" srcid 34.252.210.92 {{ end -}} {{ end }} get all keys under "vpn" iterate over them transform items in maps if we have values for all necessary keys generate ipsec configuration configuration keys local public IP (injected by terraform) vpn/ /us/ /cidrblock = 172.30.0.0/16 /endpoint = 32.32.32.32 /psk = demo ike esp from 10.0.0.0/16 to 172.30.0.0/16 peer 32.32.32.32 psk "demo" srcid 34.252.210.92
  • 22. @eurobsdcon Let's look at this $ consul members $ rcctl check consul consul_template $ cat /etc/consul-template.d/ipsec.ctmpl $ doas cat /etc/ipsec.conf $ doas ipsecctl -s all
  • 23. @eurobsdcon Building our VPN Bastion Public subnets NAT GW Public subnets Public subnets CAg (UI) CS 10.0.128.100 consul0 CS 10.0.129.100 consul1 CS 10.0.130.100 consul2 10.0.128.200 consul-agent VPN 10.0.0.10 Ireland, 10.0.0.0/16 Virginia, 172.30.0.0/16 EIP: 34.252.210.92 Demo 172.30.x.y allow ICMP from 10.0.0.0/16
  • 24. @eurobsdcon Conclusion and perspectives What could be improved in this example • Security of consul: SSL / ACL My (limited) usage of OpenBSD on AWS • VPN Gateways • DNS proxies • And now consul • Many potential other use-cases Look at / Fork the code of this demo on github https://github.com/lbernail/eurobsdcon2017 Questions ? @lbernail