OpenVPN - 無法連線到新子網路上的用戶端

OpenVPN - 無法連線到新子網路上的用戶端

我運行一個伺服器,有很多客戶端透過 OpenVPN 連接到它,客戶端的數量慢慢增長,直到幾天前達到超過 255 個。當我最初設定VPN時,我就考慮到了這一點,並將子網路遮罩設定為「255.255.0.0」;然而,有些問題,因為我可以連接到具有 IP 位址的舊客戶端,但不能連接到任何具有IP 位址10.8.0.x的新客戶端。10.8.1.x

我的配置中是否缺少任何內容?

  • /etc/openvpn/server.conf:
    port 1194
    proto udp
    dev tun
    
    ca ca.crt
    crl-verify crl.pem
    cert server.crt
    key server.key
    dh dh.pem
    
    auth SHA512
    tls-auth ta.key 0
    cipher AES-256-CBC
    
    topology subnet
    server 10.8.0.0 255.255.0.0
    ifconfig-pool-persist ipp.txt
    
    push "bypass-dhcp"
    push "dhcp-option DNS 8.8.8.8"
    push "dhcp-option DNS 8.8.4.4"
    push "dhcp-option DNS 10.8.0.1"
    
    keepalive 10 120
    sndbuf 0
    rcvbuf 0
    persist-key
    persist-tun
    
    verb 3
    
    log /var/log/openvpn.log
    status openvpn-status.log
    
    # This automatically assigns domain names to clients, based on their names:
      # NOTE: You have to comment out user and grop lines above for this to even work
        #user nobody
        #group nogroup
    
        # default is 1 which doesn't allow user-defined scripts
        script-security 2
        learn-address /home/dvida/openvpn_scripts/learn_address.sh
    
  • /etc/openvpn/client-common.txt:
    client
    dev tun
    proto udp
    remote blah.blah.com 1194
    
    sndbuf 0
    rcvbuf 0
    mssfix 1160
    
    resolv-retry infinite
    persist-key
    persist-tun
    nobind
    
    remote-cert-tls server
    tls-version-min 1.0
    key-direction 1
    
    auth SHA512
    cipher AES-256-CBC
    
    verb 3
    
  • ifconfig報告此 VPN 介面與其他介面沒有 IP 衝突:
    tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
              inet addr:10.8.0.1  P-t-P:10.8.0.1  Mask:255.255.0.0
              UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
              RX packets:71105670 errors:0 dropped:0 overruns:0 frame:0
              TX packets:70755978 errors:0 dropped:391 overruns:0 carrier:0
              collisions:0 txqueuelen:100
              RX bytes:42092973453 (39.2 GiB)  TX bytes:42070922921 (39.1 GiB)
    

答案1

事實證明,它與 OpenVPN 無關,並且符合以下 SNAT 規則:

iptables -t nat -A POSTROUTING -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to 129.100.40.167
  • 我更新了實時iptables規則並修復了其中的一個,/etc/rc.local因此網路遮罩/16/24

相關內容