大网数据广告活动
服务器运维问答

How to configure DNS of OpenVPN client?

· 52CE 我爱测

I have an OpenVPN server running with the following config file port 1194 proto tcp dev tun ca ca.crt cert server.crt key server.key dh dh2048.pem topology subnet server 10.8.0.0 255.255.255.0 ifconfig-pool-persist ipp.txt push "…

问题原文

原帖链接 · Frederick Álvarez · CC BY-SA 3.0

I have an OpenVPN server running with the following config file

port 1194
proto tcp
dev tun
ca ca.crt
cert server.crt
key server.key 
dh dh2048.pem
topology subnet
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
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
tls-crypt myvpn.tlsauth
cipher AES-256-CBC
compress lz4-v2
push "compress lz4-v2"
user nobody
group nobody
persist-key
persist-tun
status openvpn-status.log
log /var/log/openvpn.log
verb 3
remote-cert-eku "TLS Web Client Authentication"

and I have different clients connected, on Debian machines I used the following config file

client
tls-client
ca ca.crt
cert pibox.crt
key pibox.key
tls-crypt myvpn.tlsauth
proto tcp
remote X.X.X.X 1194 tcp
dev tun
topology subnet
cipher AES-256-CBC
log /var/log/openvpn.log
pull
script-security 2                     
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

all is working fine, I can access to my VPN and also I have access to the internet, I'm trying to set up a CentOS 7 client for which I used the same config file but since

script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

cannot be used, I'm not sure how can I configure the DNS, I research and some people mention openresolv, I also tried with

pull-filter ignore "dhcp-option DNS"

but nothing works, also, I read this but I don't have

/usr/share/openvpn/update-resolv-conf
/usr/share/openvpn/update-resolv-conf

What is the correct procedure to configure the DNS on a CentOS client?

已采纳解答

原帖链接 · Frederick Álvarez · CC BY-SA 3.0

I managed to fix it, what I did was

cd /etc/yum.repos.d
sudo wget https://copr.fedorainfracloud.org/coprs/macieks/openresolv/repo/epel-7/macieks-openresolv-epel-7.repo
sudo yum update
sudo yum install openresolv

it will create /etc/resolv.conf

then I modified it to set my custom DNS

# Generated by NetworkManager
search Home
nameserver 8.8.8.8
nameserver 8.8.4.4

client

client
tls-client
ca ca.crt
cert i7box.crt
key i7box.key
tls-crypt myvpn.tlsauth
proto tcp
remote x.x.x.x 1194 tcp
dev tun
topology subnet
cipher AES-256-CBC
log /var/log/openvpn.log
pull

also I desabled the automatic DNS and I put static ones, if you know a better method let me know

GUI static DNS

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-04-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。