如何在Linux中为每个PPP会话findDNS服务器?

如何获取特定于每个ppp会话的DNS服务器地址。 例如,我有两个ppp会话,每个连接不同的服务提供商,我如何找出每个服务提供商分配的DNS服务器IP地址? 通常,每当build立新的ppp会话时,/etc/ppp/resolv.conf文件将被新的DNS IP地址覆盖。 有没有办法如何维护每个服务提供商的DNS服务器的单独文件?

man pppd

  usepeerdns Ask the peer for up to 2 DNS server addresses. The addresses supplied by the peer (if any) are passed to the /etc/ppp/ip-up script in the environment variables DNS1 and DNS2, and the environment variable USEPEERDNS will be set to 1. In addition, pppd will create an /etc/ppp/ resolv.conf file containing one or two nameserver lines with the address(es) supplied by the peer. 

因此,只需在您的ip-up脚本(在PPP连接build立后运行一次)中评估DNS1和DNS2,稍后如果您需要此信息,则将其存储在某处。

但是,正如mailq写的,这种function真的只有很less的用处。