问题原文
原帖链接 · Santobert · CC BY-SA 4.0
I use an openvpn infrastructure with a server and some clients. The clients can call each other via their hostnames, but cannot reach the server in the same way. At the moment it is possible to reach the server via its IP address.
How can I transfer the server name and the corresponding IP addresses (v4 and v6) to the clients?
If possible, i don't want to set up an extra dns server
已采纳解答
原帖链接 · Nanzikambe · CC BY-SA 4.0
Edit re-read your question:
Ok without a DNS server you would add the server's IP to the client's /etc/hosts file:
172.31.0.1 dns.local
I would recommend the dns server option though, it's straight-forward:
Install bind or dnsmasq on the openvpn server and add the following to its config:
push "dhcp-option DOMAIN yourdomain.local"
push "dhcp-option DNS X.X.X.X"
Where X.X.X.X is the IP bind/dnsmasq listens on.
The options do the following:
- DNS X.X.X.X -- Set primary domain name server IPv4 address. Repeat this option to set secondary DNS server addresses.
- DOMAIN yourdomain.local -- sets Connection-specific DNS
If the DNS server is not in the same network as the VPN clients you may need to use:
push "redirect-private bypass-dns"
Which will create a separate route to the DNS server that skips the VPN.
If you're using Bind, then your named.conf would contain:
zone "local" IN {
type master;
allow-update { none; };
notify no;
file "/etc/bind/local.zone";
};
And local.zone:
$TTL 600
@ IN SOA dns.local. root.local. (
2018061001 ; serial
12h ; refresh
1h ; retry
2w ; expire
1h ; minimum
)
;
NS ns ; Inet Address of name server
MX 10 mail.local. ; Primary Mail Exchanger
MX 20 mail.local. ; Secondary Mail Exchanger
localhost IN A 127.0.0.1
dns IN A 172.31.0.1
ns IN A 172.31.0.1
mail IN A 172.31.0.1
client100 IN A 172.31.0.100
client101 IN A 172.31.0.101
If you're new to Bind make absolutely sure it does not respond on any Internet facing IP.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
