업데이트로 돌아가기
New releaseSep 8, 2026

strongswan v6.1.0

strongSwan - IPsec 기반 VPN

공유

strongSwan 구성

개요

strongSwan은 오픈소스 IPsec 기반 VPN 솔루션입니다.

이 문서는 최신 vici Versatile IKE Configuration Interface를 사용하는 strongSwan swanctl 명령에 대한 간단한 소개일 뿐입니다. 레거시 stroke 구성 인터페이스를 사용하는 더 이상 사용되지 않는 ipsec 명령은 여기에 설명되어 있습니다. 더 자세한 정보는 매뉴얼 페이지, 새로운 문서 사이트 및 레거시 wiki를 참조하십시오.

빠른 시작

사용자, 호스트 및 게이트웨이용 인증서는 가상의 strongSwan CA에서 발급됩니다. 예제 시나리오에서 CA 인증서 strongswanCert.pem은 피어를 인증할 수 있도록 모든 VPN 엔드포인트에 있어야 합니다. 특정 VPN 애플리케이션의 경우 타사 CA의 인증서를 사용하거나 아래 섹션 중 하나에서 설명할 strongSwan pki 도구를 사용하여 필요한 개인 키와 인증서를 직접 생성할 수 있습니다.

사이트 간(Site-to-Site) 사례

이 시나리오에서는 두 보안 게이트웨이 _moon_과 _sun_이 두 게이트웨이 사이에 설정된 VPN 터널을 통해 두 서브넷 _moon-net_과 _sun-net_을 서로 연결합니다:

10.1.0.0/16 -- | 192.168.0.1 | === | 192.168.0.2 | -- 10.2.0.0/16
  moon-net          moon                 sun           sun-net

게이트웨이 _moon_의 구성:

/etc/swanctl/x509ca/strongswanCert.pem
/etc/swanctl/x509/moonCert.pem
/etc/swanctl/private/moonKey.pem

/etc/swanctl/swanctl.conf:

    connections {
        net-net {
            remote_addrs = 192.168.0.2

            local {
                auth = pubkey
                certs = moonCert.pem
            }
            remote {
                auth = pubkey
                id = "C=CH, O=strongSwan, CN=sun.strongswan.org"
            }
            children {
                net-net {
                    local_ts  = 10.1.0.0/16
                    remote_ts = 10.2.0.0/16
                    start_action = trap
                }
            }
        }
    }

게이트웨이 _sun_의 구성:

/etc/swanctl/x509ca/strongswanCert.pem
/etc/swanctl/x509/sunCert.pem
/etc/swanctl/private/sunKey.pem

/etc/swanctl/swanctl.conf:

    connections {
        net-net {
            remote_addrs = 192.168.0.1

            local {
                auth = pubkey
                certs = sunCert.pem
            }
            remote {
                auth = pubkey
                id = "C=CH, O=strongSwan, CN=moon.strongswan.org"
            }
            children {
                net-net {
                    local_ts  = 10.2.0.0/16
                    remote_ts = 10.1.0.0/16
                    start_action = trap
                }
            }
        }
    }

이 시나리오에서 사용되는 로컬 및 원격 ID는 최종 엔터티 인증서에 포함된 subjectDistinguishedNames입니다. 인증서와 개인 키는 다음 명령으로 charon 데몬에 로드됩니다:

swanctl --load-creds

반면에

swanctl --load-conns

swanctl.conf에 정의된 연결을 로드합니다. start_action = trap을 사용하면 IPsec 연결은 터널을 통과하려는 첫 번째 일반 텍스트 페이로드 IP 패킷과 함께 자동으로 설정됩니다.

호스트 간(Host-to-Host) 사례

이것은 뒤에 서브넷이 없는 두 단일 호스트 간의 구성입니다. 호스트 간 연결에는 IPsec 전송 모드로 충분하지만 기본 IPsec 터널 모드를 사용하겠습니다.

| 192.168.0.1 | === | 192.168.0.2 |
     moon                sun

호스트 _moon_의 구성:

/etc/swanctl/x509ca/strongswanCert.pem
/etc/swanctl/x509/moonCert.pem
/etc/swanctl/private/moonKey.pem

/etc/swanctl/swanctl.conf:

    connections {
        host-host {
            remote_addrs = 192.168.0.2

            local {
                auth=pubkey
                certs = moonCert.pem
            }
            remote {
                auth = pubkey
                id = "C=CH, O=strongSwan, CN=sun.strongswan.org"
            }
            children {
                net-net {
                    start_action = trap
                }
            }
        }
    }

호스트 _sun_의 구성:

/etc/swanctl/x509ca/strongswanCert.pem
/etc/swanctl/x509/sunCert.pem
/etc/swanctl/private/sunKey.pem

/etc/swanctl/swanctl.conf:

    connections {
        host-host {
            remote_addrs = 192.168.0.1

            local {
                auth = pubkey
                certs = sunCert.pem
            }
            remote {
                auth = pubkey
                id = "C=CH, O=strongSwan, CN=moon.strongswan.org"
            }
            children {
                host-host {
                    start_action = trap
                }
            }
        }
    }

Roadwarrior 사례

이것은 strongSwan 게이트웨이가 일반적으로 동적 IP 주소를 가진 임의의 수의 원격 VPN 클라이언트에 서비스를 제공하는 매우 일반적인 사례입니다.

10.1.0.0/16 -- | 192.168.0.1 | === | x.x.x.x |
  moon-net          moon              carol

게이트웨이 _moon_의 구성:

/etc/swanctl/x509ca/strongswanCert.pem
/etc/swanctl/x509/moonCert.pem
/etc/swanctl/private/moonKey.pem

/etc/swanctl/swanctl.conf:

    connections {
        rw {
            local {
                auth = pubkey
                certs = moonCert.pem
                id = moon.strongswan.org
            }
            remote {
                auth = pubkey
            }
            children {
                net-net {
                    local_ts  = 10.1.0.0/16
                }
            }
        }
    }

roadwarrior _carol_의 구성:

/etc/swanctl/x509ca/strongswanCert.pem
/etc/swanctl/x509/carolCert.pem
/etc/swanctl/private/carolKey.pem

/etc/swanctl/swanctl.conf:

    connections {
        home {
            remote_addrs = moon.strongswan.org

            local {
                auth = pubkey
                certs = carolCert.pem
                id = [email protected]
            }
            remote {
                auth = pubkey
                id = moon.strongswan.org
            }
            children {
                home {
                    local_ts  = 10.1.0.0/16
                    start_action = start
                }
            }
        }
    }

remote_addrs에는 호스트 이름 moon.strongswan.org이 선택되었으며, 이는 런타임에 DNS에 의해 해당 IP 대상 주소로 확인됩니다. 이 시나리오에서 roadwarrior carol의 ID는 이메일 주소 [email protected]이며, 이는 roadwarrior 인증서 carolCert.pemsubjectAlternativeName으로 포함되어야 합니다.

가상 IP를 사용하는 Roadwarrior 사례

Roadwarrior는 일반적으로 현재 연결된 ISP가 할당한 동적 IP 주소를 가지고 있습니다. _moon-net_에서 원격 액세스 클라이언트 _carol_로의 라우팅을 단순화하려면 roadwarrior가 사전 정의된 풀에서 선택된 내부 IP 주소를 가지는 것이 바람직합니다.

10.1.0.0/16 -- | 192.168.0.1 | === | x.x.x.x | -- 10.3.0.1
  moon-net          moon              carol       virtual IP

이 예제에서 가상 IP 주소는 주소 풀 10.3.0.0/16에서 선택되며, 이는 게이트웨이의 swanctl.conf에 다음 섹션을 추가하여 구성할 수 있습니다:

pools {
    rw_pool {
        addrs = 10.3.0.0/16
    }
}

이 풀은 다음 명령을 사용하여 charon 데몬에 로드됩니다:

swanctl --load-pools

이 풀에서 IP 주소를 요청하기 위해 roadwarrior는 IKEv1 모드 구성 또는 IKEv2 구성 페이로드를 사용할 수 있습니다. 둘 다 구성은 동일합니다:

vips = 0.0.0.0

게이트웨이 _moon_의 구성:

/etc/swanctl/x509ca/strongswanCert.pem
/etc/swanctl/x509/moonCert.pem
/etc/swanctl/private/moonKey.pem

/etc/swanctl/swanctl.conf:

    connections {
        rw {
            pools = rw_pool

            local {
                auth = pubkey
                certs = moonCert.pem
                id = moon.strongswan.org
            }
            remote {
                auth = pubkey
            }
            children {
                net-net {
                    local_ts  = 10.1.0.0/16
                }
            }
        }
    }

    pools {
        rw_pool {
            addrs = 10.30.0.0/16
        }
    }

roadwarrior _carol_의 구성:

/etc/swanctl/x509ca/strongswanCert.pem
/etc/swanctl/x509/carolCert.pem
/etc/swanctl/private/carolKey.pem

/etc/swanctl/swanctl.conf:

    connections {
        home {
            remote_addrs = moon.strongswan.org
            vips = 0.0.0.0

            local {
                auth = pubkey
                certs = carolCert.pem
                id = [email protected]
            }
            remote {
                auth = pubkey
                id = moon.strongswan.org
            }
            children {
                home {
                    local_ts  = 10.1.0.0/16
                    start_action = start
                }
            }
        }
    }

EAP 인증을 사용하는 Roadwarrior 사례

이것은 strongSwan 게이트웨이가 예를 들어 EAP-MD5 또는 EAP-MSCHAPv2와 같은 비밀번호 기반 Extended Authentication Protocol을 통해 인증하는 임의의 수의 원격 VPN 클라이언트에 서비스를 제공하는 매우 일반적인 사례입니다.

10.1.0.0/16 -- | 192.168.0.1 | === | x.x.x.x |
  moon-net          moon              carol

게이트웨이 _moon_의 구성:

/etc/swanctl/x509ca/strongswanCert.pem
/etc/swanctl/x509/moonCert.pem
/etc/swanctl/private/moonKey.pem

/etc/swanctl/swanctl.conf:

    connections {
        rw {
            local {
                auth = pubkey
                certs = moonCert.pem
                id = moon.strongswan.org
            }
            remote {
                auth = eap-md5
            }
            children {
                net-net {
                    local_ts  = 10.1.0.0/16
                }
            }
            send_certreq = no
        }
    }

swanctl.conf 파일에는 모든 클라이언트 자격 증명을 정의하는 secrets 섹션이 추가로 포함되어 있습니다:

    secrets {
        eap-carol {
            id = [email protected]
            secret = Ar3etTnp
        }
        eap-dave {
            id = [email protected]
            secret = W7R0g3do
        }
    }

roadwarrior _carol_의 구성:

/etc/swanctl/x509ca/strongswanCert.pem

/etc/swanctl/swanctl.conf:

    connections {
        home {
            remote_addrs = moon.strongswan.org

            local {
                auth = eap
                id = [email protected]
            }
            remote {
                auth = pubkey
                id = moon.strongswan.org
            }
            children {
                home {
                    local_ts  = 10.1.0.0/16
                    start_action = start
                }
            }
        }
    }

    secrets {
        eap-carol {
            id = [email protected]
            secret = Ar3etTnp
        }
    }

EAP ID를 사용하는 Roadwarrior 사례

종종 클라이언트 EAP ID는 외부 IKEv2 ID와 다른 EAP를 통해 교환됩니다. 이 예제에서 IKEv2 ID는 기본적으로 클라이언트의 IPv4 주소입니다.

10.1.0.0/16 -- | 192.168.0.1 | === | x.x.x.x |
  moon-net          moon              carol

게이트웨이 _moon_의 구성:

/etc/swanctl/x509ca/strongswanCert.pem
/etc/swanctl/x509/moonCert.pem
/etc/swanctl/private/moonKey.pem

/etc/swanctl/swanctl.conf:

    connections {
        rw {
            local {
                auth = pubkey
                certs = moonCert.pem
                id = moon.strongswan.org
            }
            remote {
                auth = eap-md5
                eap_id = %any
            }
            children {
                net-net {
                    local_ts  = 10.1.0.0/16
                }
            }
            send_certreq = no
        }
    }

    secrets {
        eap-carol {
            id = carol
            secret = Ar3etTnp
        }
        eap-dave {
            id = dave
            secret = W7R0g3do
        }
    }

roadwarrior _carol_의 구성:

/etc/swanctl/x509ca/strongswanCert.pem

/etc/swanctl/swanctl.conf:

    connections {
        home {
            remote_addrs = moon.strongswan.org

            local {
                auth = eap
                eap_id = carol
            }
            remote {
                auth = pubkey
                id = moon.strongswan.org
            }
            children {
                home {
                    local_ts  = 10.1.0.0/16
                    start_action = start
                }
            }
        }
    }

    secrets {
        eap-carol {
            id = carol
            secret = Ar3etTnp
        }
    }

인증서 및 CRL 생성

이 섹션은 strongSwan pki 도구 사용 방법에 대한 본격적인 튜토리얼이 아닙니다. strongSwan과 함께 사용할 자체 인증서와 CRL을 생성하려는 경우 관련된 몇 가지 사항만 나열합니다.

CA 인증서 생성

pki 문은

pki --gen --type ed25519 --outform pem > strongswanKey.pem

128비트의 암호화 강도를 가진 타원 에드워즈 곡선(Edwards-Curve) 키를 생성합니다. 해당 공개 키는 10년(3652일)의 수명을 가진 자체 서명 CA 인증서에 포함됩니다:

pki --self --ca --lifetime 3652 --in strongswanKey.pem \
           --dn "C=CH, O=strongSwan, CN=strongSwan Root CA" \
           --outform pem > strongswanCert.pem

다음 명령으로 나열할 수 있습니다:

pki --print --in strongswanCert.pem

subject:  "C=CH, O=strongSwan, CN=strongSwan Root CA"
issuer:   "C=CH, O=strongSwan, CN=strongSwan Root CA"
validity:  not before May 18 08:32:06 2017, ok
           not after  May 18 08:32:06 2027, ok (expires in 3651 days)
serial:    57:e0:6b:3a:9a:eb:c6:e0
flags:     CA CRLSign self-signed
subjkeyId: 2b:95:14:5b:c3:22:87:de:d1:42:91:88:63:b3:d5:c1:92:7a:0f:5d
pubkey:    ED25519 256 bits
keyid:     a7:e1:6a:3f:e7:6f:08:9d:89:ec:23:92:a9:a1:14:3c:78:a8:7a:f7
subjkey:   2b:95:14:5b:c3:22:87:de:d1:42:91:88:63:b3:d5:c1:92:7a:0f:5d

CA 개인 키와 X.509 인증서를 바이너리 DER 형식으로 선호하는 경우 --outform pem 옵션을 생략하면 됩니다. /etc/swanctl/x509ca 디렉토리에는 모든 필수 CA 인증서가 바이너리 DER 또는 Base64 PEM 형식으로 포함되어 있습니다. 파일 접미사와 관계없이 strongSwan이 올바른 형식을 자동으로 판단합니다.

호스트 또는 사용자 최종 엔터티 인증서 생성

다시 다음 명령을 사용하여 호스트 moon의 Ed25519 개인 키를 생성합니다:

pki --gen --type ed25519 --outform pem > moonKey.pem

또는 다음을 입력하여 전통적인 3072비트 RSA 키를 생성하고 바이너리 DER 형식으로 저장할 수 있습니다:

pki --gen --type rsa --size 3072 > moonKey.der

또한 최신 Intel 플랫폼에서 사용할 수 있는 TPM 2.0 Trusted Platform Module을 가상 스마트카드로 사용하여 RSA 또는 ECDSA 개인 키를 안전하게 저장할 수도 있습니다. 자세한 내용은 TPM 2.0 HOWTO를 참조하십시오.

다음 단계에서 다음 명령은 CA가 서명해야 하는 PKCS#10 인증서 요청을 생성합니다:

pki --req --type priv --in moonKey.pem \
          --dn "C=CH, O=strongswan, CN=moon.strongswan.org" \
          --san moon.strongswan.org --outform pem > moonReq.pem

--san 매개변수를 여러 번 사용하면 원하는 수의 subjectAlternativeNames를 요청에 추가할 수 있습니다. 형식은 다음과 같습니다:

--san sun.strongswan.org     # fully qualified host name
--san [email protected]   # RFC822 user email address
--san 192.168.0.1            # IPv4 address
--san fec0::1                # IPv6 address

인증서 요청을 기반으로 CA는 다음 명령으로 서명된 최종 엔터티 인증서를 발급합니다:

pki --issue --cacert strongswanCert.pem --cakey strongswanKey.pem \
            --type pkcs10 --in moonReq.pem --serial 01 --lifetime 1826 \
            --outform pem > moonCert.pem

16진수 인수를 사용하는 --serial 매개변수를 생략하면 임의의 일련 번호가 생성됩니다. 일부 타사 VPN 클라이언트는 VPN 게이트웨이 인증서에 TLS Server Authentication EKU(Extended Key Usage) 플래그가 포함되어 있어야 합니다. 다음 옵션으로 포함할 수 있습니다:

--flag serverAuth

다음 섹션 중 하나에서 설명하는 동적 CRL 가져오기 기능을 사용하려면 --crl 매개변수를 사용하여 최종 엔터티 인증서에 하나 이상의 crlDistributionPoints를 포함할 수 있습니다:

--crl  http://crl.strongswan.org/strongswan.crl
--crl "ldap://ldap.strongswan.org/cn=strongSwan Root CA, o=strongSwan,c=CH?certificateRevocationList"

발급된 호스트 인증서는 다음 명령으로 나열할 수 있습니다:

pki --print --in moonCert.pem

subject:  "C=CH, O=strongSwan, CN=moon.strongswan.org"
issuer:   "C=CH, O=strongSwan, CN=strongSwan Root CA"
validity:  not before May 19 10:28:19 2017, ok
           not after  May 19 10:28:19 2022, ok (expires in 1825 days)
serial:    01
altNames:  moon.strongswan.org
flags:     serverAuth
CRL URIs:  http://crl.strongswan.org/strongswan.crl
authkeyId: 2b:95:14:5b:c3:22:87:de:d1:42:91:88:63:b3:d5:c1:92:7a:0f:5d
subjkeyId: 60:9d:de:30:a6:ca:b9:8e:87:bb:33:23:61:19:18:b8:c4:7e:23:8f
pubkey:    ED25519 256 bits
keyid:     39:1b:b3:c2:34:72:1a:01:08:40:ce:97:75:b8:be:ce:24:30:26:29
subjkey:   60:9d:de:30:a6:ca:b9:8e:87:bb:33:23:61:19:18:b8:c4:7e:23:8f

일반적으로 Windows, OSX, Android 또는 iOS 기반 VPN 클라이언트는 개인 키, 호스트 또는 사용자 인증서 및 CA 인증서가 필요합니다. 이 정보를 로드하는 가장 편리한 방법은 모든 것을 PKCS#12 컨테이너에 넣는 것입니다:

openssl pkcs12 -export -inkey carolKey.pem \
               -in carolCert.pem -name "carol" \
               -certfile strongswanCert.pem -caname "strongSwan Root CA" \
               -out carolCert.p12

strongSwan pki 도구는 현재 PKCS#12 컨테이너를 생성할 수 없으므로 openssl을 사용해야 합니다.

CRL 생성

CA가 서명한 빈 CRL은 다음 명령으로 생성할 수 있습니다:

pki --signcrl --cacert strongswanCert.pem --cakey strongswanKey.pem \
              --lifetime 30 > strongswan.crl

--lifetime 옵션을 생략하면 기본값인 15일이 사용됩니다. CRL은 HTTP 또는 LDAP 서버에 업로드하거나 바이너리 DER 또는 Base64 PEM 형식으로 /etc/swanctl/x509crl 디렉토리에 넣을 수 있으며, 여기에서 다음 명령으로 charon 데몬에 로드됩니다:

swanctl --load-creds### 인증서 폐기 ###

특정 최종 엔터티 인증서는 다음 명령으로 폐기됩니다.

pki --signcrl --cacert strongswanCert.pem --cakey strongswanKey.pem \
              --lifetime 30 --lastcrl strongswan.crl \
              --reason key-compromise --cert moonCert.pem > new.crl

인증서 파일(예제에서는 moonCert.pem) 대신 --serial 매개변수를 사용하여 폐기할 인증서의 일련 번호를 지정할 수 있습니다. pki --signcrl --help 명령은 가능한 모든 폐기 사유를 설명하지만 --reason 매개변수는 생략할 수도 있습니다. 새 CRL 파일의 내용은 다음 명령으로 나열할 수 있습니다.

pki --print --type crl --in new.crl

issuer:   "C=CH, O=strongSwan, CN=strongSwan Root CA"
update:    this on May 19 11:13:01 2017, ok
           next on Jun 18 11:13:01 2017, ok (expires in 29 days)
serial:    02
authKeyId: 2b:95:14:5b:c3:22:87:de:d1:42:91:88:63:b3:d5:c1:92:7a:0f:5d
1 revoked certificate:
  01: May 19 11:13:01 2017, key compromise

CRL 로컬 캐싱

strongswan.conf 옵션

charon {
    cache_crls = yes
}

HTTP 또는 LDAP 서버에서 동적으로 가져온 CRL의 로컬 캐싱을 활성화합니다. 캐시된 사본은 발급자의 subjectKeyIdentifier.crl 접미사로 구성된 고유 파일 이름을 사용하여 /etc/swanctl/x509crl에 저장됩니다.

캐시된 사본이 있으면 시작 후 CRL을 즉시 사용할 수 있습니다. 로컬 사본이 만료되면 다음 IKEv2 인증 중에 정의된 CRL 배포 지점 중 하나에서 업데이트된 CRL이 자동으로 가져와집니다.

카테고리