AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-167331

fiedl's questions

Martin Hope
fiedl
Asked: 2021-10-08 05:46:51 +0800 CST

使用网关主机通过 IPSec 隧道路由流量

  • 1

考虑到strongswan wiki,这似乎是一个标准问题,但我无法让它正常工作。

网络布局

网络布局

本地站点 ( clientand gateway) 在我的控制之下,远程站点 ( remote gatewayand remote server) 不在。IPSec 隧道是一个拆分隧道,因此只有对10.10.0.0/16子网的请求通过 IPSec 隧道发送。

目标

我希望与client进行通信remote server,例如创建一个ssh或一个smb连接。

我已经做过的

  • gateway我已经在和之间建立了 IPSec 隧道remote gateway。

  • 我已在以下位置启用 ip 转发gateway:

    sysctl net.ipv4.ip_forward=1
    
  • 我在以下位置创建了一个 NAT gateway:

    iptables -t nat -I POSTROUTING -m policy --pol ipsec --dir out -j ACCEPT
    iptables -t nat -A POSTROUTING -j MASQUERADE
    
  • 在client我已经通过以下方式路由流量gateway:

    ip route del default
    ip route add default via 192.168.144.4
                           # 192.168.144.4 is the gateway
    

有什么作用

  • IPSec隧道已建立且稳定。
  • 登录后,我gateway可以成功。我也可以。我可以。pingremote gatewayremote serverpingclientping google.com
  • 登录后client,我可以,ping google.com我可以。随着on the我看到from the正在通过.pinggatewaytcpdump icmpgatewayping google.comclientgateway

什么不起作用,但

我不能ping从它remote server的clientIP 中获取。

client$ ping -c 1 10.10.12.7
PING 10.10.12.7 (10.10.12.7): 56 data bytes

--- 10.10.12.7 ping statistics ---
1 packets transmitted, 0 packets received, 100% packet loss

从tcpdump开始gateway,看起来ping是发送的,但不是通过隧道转发的:

gateway$ tcpdump icmp
13:19:18.122999 IP 192.168.144.7 > 10.10.12.7: ICMP echo request, id 15, seq 0, length 64
13:19:18.123038 IP gateway > 10.10.12.7: ICMP echo request, id 15, seq 0, length 64
13:19:18.127534 IP ac5.nue3.m-online.net > gateway: ICMP net 10.10.12.7 unreachable, length 36
13:19:18.127556 IP ac5.nue3.m-online.net > 192.168.144.7: ICMP net 10.10.12.7 unreachable, length 36

与ac5.nue3.m-online.net本地站点的互联网服务提供商一样,我认为数据包不是通过 IPSec 隧道路由的,而是gateway通过remote server. (如果我将 IPSec 隧道设为完整隧道而不是拆分隧道,我会得到相同的结果。)

任何帮助或见解将不胜感激!

编辑:ipsec statusall在gateway

gateway > ipsec statusall
Status of IKE charon daemon (strongSwan 5.8.2, Linux 5.4.0-88-generic, x86_64):
  uptime: 7 minutes, since Oct 08 08:18:24 2021
  malloc: sbrk 3112960, mmap 0, used 1081456, free 2031504
  worker threads: 11 of 16 idle, 5/0/0/0 working, job queue: 0/0/0/0, scheduled: 4
  loaded plugins: charon test-vectors ldap pkcs11 tpm aesni aes rc2 sha2 sha1 md5 mgf1 rdrand random nonce x509 revocation constraints pubkey pkcs1 pkcs7 pkcs8 pkcs12 pgp dnskey sshkey pem openssl gcrypt af-alg fips-prf gmp curve25519 agent chapoly xcbc cmac hmac ctr ccm gcm ntru drbg curl attr kernel-netlink resolve socket-default connmark farp stroke updown eap-identity eap-aka eap-md5 eap-gtc eap-mschapv2 eap-dynamic eap-radius eap-tls eap-ttls eap-peap eap-tnc xauth-generic xauth-eap xauth-pam tnc-tnccs dhcp lookip error-notify certexpire led addrblock unity counters
Listening IP addresses:
  192.168.144.4
Connections:
example-ipsec:  %any...vpn1.example.com  IKEv2, dpddelay=300s
example-ipsec:   local:  [[email protected]] uses pre-shared key authentication
example-ipsec:   remote: [[email protected]] uses pre-shared key authentication
example-ipsec:   child:  dynamic === 0.0.0.0/0 TUNNEL, dpdaction=clear
Security Associations (1 up, 0 connecting):
example-ipsec[1]: ESTABLISHED 7 minutes ago, 192.168.144.4[[email protected]]...<public-ip-of-the-remote-gateway>[[email protected]]
example-ipsec[1]: I: 9d7c74f670bbda86_i* c12b3b4a236b7018_r, pre-shared key reauthentication in 2 hours
example-ipsec[1]: IKE proposal: AES_CBC_256/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_2048
example-ipsec{1}:  INSTALLED, TUNNEL, reqid 1, ESP in UDP SPIs: cf66ad72_i af3c9348_o
example-ipsec{1}:  AES_CBC_256/HMAC_SHA2_256_128, 442 bytes_i (4 pkts, 434s ago), 485 bytes_o (6 pkts, 433s ago), rekeying in 38 minutes
example-ipsec{1}:   10.10.102.235/32 === 0.0.0.0/0

这是在ipsec statusall将fromgateway发送到. from不会更改输出中的“字节” 。输出中的“字节”对应于我从 发送到.pingclientremote serverpinggatewaypinggatewayremote server

编辑:/etc/ipsec.conf在gateway:

# /etc/ipsec.conf

conn example-ipsec
  left = %defaultroute
  leftsourceip = %config
  leftid = "[email protected]"
  right = vpn1.example.com
  rightid = "[email protected]"
  rightsubnet = 0.0.0.0/0
  leftfirewall = yes
  installpolicy = yes
  keyexchange = ikev2
  type = tunnel
  auto = start
  leftauth = psk
  rightauth = psk
  dpdaction = clear
  dpddelay = 300s
iptables ipsec ip-forwarding
  • 1 个回答
  • 316 Views
Martin Hope
fiedl
Asked: 2021-02-10 06:24:30 +0800 CST

nginx如何验证证书(proxy_ssl_verify)?

  • 0

考虑 nginx 的参数proxy_ssl_verify,proxy_ssl_trusted_certificate这些参数用于保护与上游服务器的通信。

# downstream server: nginx.conf

stream {
  server {
    # ...

    proxy_ssl on;
    proxy_ssl_verify on;

    proxy_ssl_trusted_certificate /etc/nginx/ssl/upstream.example.com/chain.pem;
    proxy_ssl_verify_depth 2;

  }
}

我的印象是,对于proxy_ssl on,nginx 会upstream.example.com根据proxy_ssl_trusted_certificate.

但是,我遇到了一个问题,即 nginx 无法与上游服务器建立安全连接并报告上游 SSL 证书验证错误: (2:unable to get issuer certificate) while SSL handshashing to upstream,同时验证证书openssl确实有效。

# fullchain.pem: certificate sent by the upstream server
# chain.pem: CA certificate for `proxy_ssl_trusted_certificate`

# openssl verify -CAfile chain.pem fullchain.pem
fullchain.pem: OK

这让我想知道nginx实际上是如何进行验证的。有没有办法单独重现这个以调试为什么会发生错误?

文档

https://nginx.org/en/docs/http/ngx_http_proxy_module.html

proxy_ssl_verify on | 离开;

启用或禁用代理 HTTPS 服务器证书的验证。

proxy_ssl_verify_depth 编号;

在代理的 HTTPS 服务器证书链中设置验证深度。

proxy_ssl_trusted_certificate 文件;

指定具有 PE​​M 格式的受信任 CA 证书的文件,用于验证代理 HTTPS 服务器的证书。

ssl nginx
  • 1 个回答
  • 3925 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve