Giter Club home page Giter Club logo

ipsec-docker's Introduction

ipsec-docker

Repo contains example of configuring host-to-host ipsec tunnel between two Docker containers.
My work is based on hwdsl2/docker-ipsec-vpn-server repo.
Go check it out!

Prequisities

Install docker-compose
Install libre-swan
Read libre-swan docs :)

Usage scenario

Generate RSA keys and create tunnel configuration

$ ./generate-config.sh

Script creates directory with tunnel configurations for each container.

Build image

$ ./build/create-image.sh

Load necessary kernel modules

$ ./build/load-modules.sh

Start containers in detached mode

$ sudo docker-compose up -d

Log into containers and run ipsec commands

# West container terminal, log into container
$ sudo docker-compose exec west bash
# Run pluto - IKE daemon
$ bash-5.1# ipsec pluto
/usr/local/libexec/ipsec/pluto: pluto: warning: chdir("/run/pluto") to dumpdir failed (2: No such file or directory)
# Now run the same in the east container, then proceed with the rest
$ bash-5.1# ipsec auto --add mytunnel
002 "mytunnel": terminating SAs using this connection
002 "mytunnel" #1: deleting state (STATE_V2_PARENT_I1) aged 26.967386s and NOT sending notification
002 "mytunnel": added IKEv2 connection
$ bash-5.1# ipsec auto --up mytunnel
002 "mytunnel" #6: initiating Child SA using IKE SA #4
189 "mytunnel" #6: sent CREATE_CHILD_SA request for new IPsec SA
004 "mytunnel" #6: initiator established Child SA using #4; IPsec tunnel [10.10.0.100-10.10.0.100:0-65535 0] -> [10.10.0.200-10.10.0.200:0-65535 0] {ESP/ESN=>0xec3051ca <0x9d514a31 xfrm=AES_GCM_16_256-NONE-MODP2048 DPD=passive}
# Tunnel configured successfully
$ bash-5.1# ipsec trafficstatus
006 #5: "mytunnel", type=ESP, add_time=1667933454, inBytes=0, outBytes=0, maxBytes=2^63B, id='@east.kti.pg.pl'
006 #6: "mytunnel", type=ESP, add_time=0, inBytes=0, outBytes=0, maxBytes=2^63B, id='@east.kti.pg.pl'
# East container terminal, log into container
$ sudo docker-compose exec east bash
# Run pluto - IKE daemon
$ bash-5.1# ipsec pluto
/usr/local/libexec/ipsec/pluto: pluto: warning: chdir("/run/pluto") to dumpdir failed (2: No such file or directory)

Results

Once you run all of the commands you can see what IPSec tunnel looks like from the outside with wireshark.
IKE negotiations
Screenshot ICMP packet modified into ESP packet - ping the container once tunnel is configured.
Data is encrypted. Security Parameters Index and Sequence Number are present.
Screenshot

ipsec-docker's People

Contributors

tymonszczepanowski avatar

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.