web-dev-qa-db-ja.com

OpenVPNサーバーのプッシュされたDNSに関係なく、OpenVPNクライアントが自身のDNSサーバーをプッシュすることを許可しますか?

Debianで実行されているOpenVPNサーバーがあり、サーバー構成ファイルにDNSをプッシュします。

「dhcp-option DNS 8.8.8.8」をプッシュします

ユーザーがクライアント側でDNSサーバーを変更できるオプションはありますか?

ここでの問題は、openvpnサーバーがDNSをプッシュする必要があることです。そうしないと、多くのOpenVPNクライアントは、システムのネットワーク設定でDNSサーバーを手動で設定するまでWebページを開くことができません。

私の目標は、技術的なスキルのないユーザーに既定のDNSサーバーを自動的に適用すると同時に、熟練したコンピューターユーザーが独自のDNSサーバーを設定できるようにすることです。

Openvpnサーバーで「プッシュ "dhcp-option DNS 8.8.8.8"」オプションがアクティブなときにPCでDNS設定を変更するだけでは、何も実行されないことに注意してください。サーバーによってプッシュされたDNSは、ローカルDNS設定に関係なく残ります。

何か案は?

OpenVPNサーバー構成:

# cat /etc/openvpn/openvpn.conf
server 10.186.35.0 255.255.255.0
port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh1024.pem
ifconfig-pool-persist ipp.txt
#Push "route 0.0.0.0 0.0.0.0"
#Push "redirect-gateway"
Push "redirect-gateway def1 bypass-dhcp"
Push "dhcp-option DNS 8.8.8.8"
Push "dhcp-option DNS 8.8.4.4"
keepalive 10 120
comp-lzo
user nobody
group users
persist-key
persist-tun
status openvpn-status.log
verb 3
script-security 3
auth-user-pass-verify /etc/openvpn/auth-chap via-env
client-cert-not-required
duplicate-cn
management 127.0.0.1 5119
script-security 3 system
username-as-common-name
client-connect /etc/openvpn/scripts/clientconnect.sh
client-disconnect /etc/openvpn/scripts/clientdisconnect.sh
log-append /var/log/openvpn.log
log /var/log/openvpn.log

更新:クライアントのオペレーティングシステムはWindowsとMacです

9
Dimi

2017(OpenVPN 2.4)以降、これが可能になりました。次の行をクライアント構成ファイルに追加します。

pull-filter ignore "dhcp-option DNS"

そして、引用されたテキストで始まるプッシュされた設定行をすべて無視します。

オプションはトップダウンで照合されるため、最初に一致したものが使用されます。必要に応じて、これを使用して一部のルートを許可し、他のルートを拒否できます。

3つのアクションキーワードは、acceptignore、およびrejectです。 rejectの使用例を発見していません。

14
Criggie

公式 OpenVPNのドキュメント で見つけることができます:

[...]
--route-nopull
  When used with --client or --pull, accept options pushed by server EXCEPT for routes and 
  dhcp options like DNS servers.
  When used on the client, this option effectively bars the server from adding routes to the 
  client's routing table, however note that this option still allows the server to set the 
  TCP/IP properties of the client's TUN/TAP interface.
[...]

残念ながら、これに加えて、これには、構成によって提供されるredirect-gatewayを無効にするという副作用があり、これはあなたの場合のために、問題。

私が提案するのは、まったく異なるアプローチです

明示的に述べたように、「私の目標は、デフォルトのDNSサーバーを技術的に熟練していないユーザーに自動的に適用すると同時に、熟練したコンピューターユーザーが独自のDNSサーバーを設定できるようにすることです。」 DNS構成を提供するユーザーと、そのような構成を提供しないユーザーを正確に把握しているようです。

したがって、メインのOpenVpn構成ファイルに直接構成をプッシュする代わりに(...したがって、そのような構成を[〜#〜] all [〜#〜]ユーザーの場合)、ユーザーごとの設定を実装できます。これは次の方法で行うことができます。

--client-config-dir dir
  Specify a directory dir for custom client config files. After a connecting client 
  has been authenticated, OpenVPN will look in this directory for a file having the 
  same name as the client's X509 common name. If a matching file exists, it will be
  opened and parsed for client-specific configuration options. If no matching file is
  found, OpenVPN will instead try to open and parse a default file called "DEFAULT", 
  which may be provided but is not required. Note that the configuration files must 
  be readable by the OpenVPN process after it has dropped it's root privileges.
  This file can specify a fixed IP address for a given client using --ifconfig-Push, as 
  well as fixed subnets owned by the client using --iroute.
  One of the useful properties of this option is that it allows client configuration 
  files to be conveniently created, edited, or removed while the server is live, without 
  needing to restart the server.
  The following options are legal in a client-specific context: --Push, --Push-reset, 
  --iroute, --ifconfig-Push, and --config.

したがって、メインの構成については、removeを実行する必要があります。

  [**** to be removed from the main config***]
  Push "dhcp-option DNS 8.8.8.8"
  Push "dhcp-option DNS 8.8.4.4"

およびadd/ etc/openvpn/userconfディレクトリへの参照(例として。お気軽に好きなものを選択してください):

 [**** to be ADDED to the main config***]
 client-config-dir /etc/openvpn/userconf

次に、そのようなuserconfディレクトリで、そのようなDNSを提供するユーザーごとに1つのファイルを作成します。このファイルには、上記で削除した2つの行が含まれています。

明らかに、カスタマイズを上の2行に限定するのではなく、ユーザーごとにopenvpn設定を自由に微調整できます。

最後の注意として、ccd-exclusiveパラメータにも興味があるかもしれません。

4

私の問題はまったく同じではありませんでしたが、この質問が検索結果に表示されるのに十分な症状があったので、同じ理由で他の誰かがここにアクセスした場合に備えて:

Mac OS用のOpenVPN GUI Tunnelblick を使用しています。 OpenVPNサーバーがDHCPまたはDNSオプションをプッシュするように設定されていませんでしたが、クライアントは、使用したいローカルの非VPN DNSサーバーではなく、VPNを介してDNSサーバーをまだ使用していました。

解決策は、Tunnelblickの[構成]→[設定]タブに移動し、Set DNS/WINSDo not set server

1
Aldaviva

@aldavivaをありがとう、それは私のmacOS 10.11で動作しています。

スクリーンショットを添付してください。

enter image description here

0
Chu-Saing Lai