这个错误可能是由两个原因引起的。
xcode
重装 xcode
$ sudo rm -rf /Library/Developer/CommandLineTools $ xcode-select --install
参见 https://github.com/nodejs/node-gyp/issues/569
node-gyp
重装 node-gyp。例如直接用 nvm 装一个新版的 node 即可。
这个错误可能是由两个原因引起的。
重装 xcode
$ sudo rm -rf /Library/Developer/CommandLineTools $ xcode-select --install
参见 https://github.com/nodejs/node-gyp/issues/569
重装 node-gyp。例如直接用 nvm 装一个新版的 node 即可。
平常测试的时候,经常要开多个终端感觉有点不方便,特别是一些不支持自定义的远程 webssh。最近用 EMACS 的时候,接触到了 ctrl+z 这个东西,随手记录一下。
通常的应用程序可以通过 ctrl+z 切换到后台,例如很常见的一个场景,启动一个 http server,然后用 curl 命令(或者 ab 之类的命令)去请求它测试一下。这个时候就可以使用 ctrl+z 切换后台来节省开多个终端的时间:
$ node index # ctrl+z ^Z [1] + 26762 suspended node index
启动之后直接 ctrl+z 就可以切换到后台。然后可以通过 jobs 来查看后台程序
$ jobs [1] + suspended node index
切换到后台之后,之后就可以做一些别的操作。等操作结束后,可以重新将其从后台转到前台来:
$ fg [1] + 26762 continued node index # ... 应用日志
这样就可以勉强不用开多个终端了。直接结束前台的程序可以使用 ctrl+c。
这里有一个简单的前台程序和后台程序的概念。通常的后台程序启动方式是:
node index &
多个后台任务可以通过 %n 来选择恢复某个到前台。例如:
$ fg %1
就可以恢复 jobs 显示的编号为 1 的任务。恢复到前台之后可以通过 ctrl+c 结束任务。也可以通过 kill 来直接杀死后台任务:
$ kill %1
*nix 上的 dig 命令是专门用来挖取域名信息的。本文详细列举了 10 个例子来解析 dig 命令。
当你给 dig 命令传一个域名时,默认情况下它会返回该域名的 A 记录 (查询到的站点的 ip 地址),如下例所示。
在本例中,结果段( ANSWER SECTION )中 显示了 redhat.com 的 A 记录。
$ dig redhat.com ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> redhat.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62863 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 3 ;; QUESTION SECTION: ;redhat.com. IN A ;; ANSWER SECTION: redhat.com. 37 IN A 209.132.183.81 ;; AUTHORITY SECTION: redhat.com. 73 IN NS ns4.redhat.com. redhat.com. 73 IN NS ns3.redhat.com. redhat.com. 73 IN NS ns2.redhat.com. redhat.com. 73 IN NS ns1.redhat.com. ;; ADDITIONAL SECTION: ns1.redhat.com. 73 IN A 209.132.186.218 ns2.redhat.com. 73 IN A 209.132.183.2 ns3.redhat.com. 73 IN A 209.132.176.100 ;; Query time: 13 msec ;; SERVER: 209.144.50.138#53(209.144.50.138) ;; WHEN: Thu Jan 12 10:09:49 2012 ;; MSG SIZE rcvd: 164
dig 命令的输出由以下几个部分组成:
大多数情况下,你只需要查看结果段(ANSWER SECTION)的内容。所以,我们可以关掉其他部分的显示内容。
所以,下例的命令仅仅只显示了结果段的信息:
$ dig redhat.com +nocomments +noquestion +noauthority +noadditional +nostats ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> redhat.com +nocomments +noquestion +noauthority +noadditional +nostats ;; global options: +cmd redhat.com. 9 IN A 209.132.183.81
不想带那么多关闭项?你可以使用 +noall 来关闭所有的内容(包括结果段),然后再加上 +answer 来开启结果段的输出。
$ dig redhat.com +noall +answer ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> redhat.com +noall +answer ;; global options: +cmd redhat.com. 60 IN A 209.132.183.81
$ dig redhat.com MX +noall +answer ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> redhat.com MX +noall +answer ;; global options: +cmd redhat.com. 513 IN MX 5 mx1.redhat.com. redhat.com. 513 IN MX 10 mx2.redhat.com.
你也可以使用 -t 参数指定一个类型来查询 MX 记录。例如
$ dig -t MX redhat.com +noall +answer ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> -t MX redhat.com +noall +answer ;; global options: +cmd redhat.com. 489 IN MX 10 mx2.redhat.com. redhat.com. 489 IN MX 5 mx1.redhat.com.
$ dig redhat.com NS +noall +answer ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> redhat.com NS +noall +answer ;; global options: +cmd redhat.com. 558 IN NS ns2.redhat.com. redhat.com. 558 IN NS ns1.redhat.com. redhat.com. 558 IN NS ns3.redhat.com. redhat.com. 558 IN NS ns4.redhat.com.
也可以用 -t 指定 NS 类型。
$ dig -t NS redhat.com +noall +answer ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> -t NS redhat.com +noall +answer ;; global options: +cmd redhat.com. 543 IN NS ns4.redhat.com. redhat.com. 543 IN NS ns1.redhat.com. redhat.com. 543 IN NS ns3.redhat.com. redhat.com. 543 IN NS ns2.redhat.com.
也可以用 -t 指定 NS 类型。
$ dig redhat.com ANY +noall +answer ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> redhat.com ANY +noall +answer ;; global options: +cmd redhat.com. 430 IN MX 5 mx1.redhat.com. redhat.com. 430 IN MX 10 mx2.redhat.com. redhat.com. 521 IN NS ns3.redhat.com. redhat.com. 521 IN NS ns1.redhat.com. redhat.com. 521 IN NS ns4.redhat.com. redhat.com. 521 IN NS ns2.redhat.com.
或使用 -t
$ dig -t ANY redhat.com +noall +answer ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> -t ANY redhat.com +noall +answer ;; global options: +cmd redhat.com. 367 IN MX 10 mx2.redhat.com. redhat.com. 367 IN MX 5 mx1.redhat.com. redhat.com. 458 IN NS ns4.redhat.com. redhat.com. 458 IN NS ns1.redhat.com. redhat.com. 458 IN NS ns2.redhat.com. redhat.com. 458 IN NS ns3.redhat.com.
$ dig redhat.com +short 209.132.183.81
你也可以指定记录类型:
$ dig redhat.com ns +short ns2.redhat.com. ns3.redhat.com. ns1.redhat.com. ns4.redhat.com.
$ dig -x 209.132.183.81 ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> -x 209.132.183.81 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62435 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 3 ;; QUESTION SECTION: ;81.183.132.209.in-addr.arpa. IN PTR ;; ANSWER SECTION: 81.183.132.209.in-addr.arpa. 600 IN PTR www.redhat.com. ;; AUTHORITY SECTION: 183.132.209.in-addr.arpa. 248 IN NS ns2.redhat.com. 183.132.209.in-addr.arpa. 248 IN NS ns1.redhat.com. 183.132.209.in-addr.arpa. 248 IN NS ns3.redhat.com. 183.132.209.in-addr.arpa. 248 IN NS ns4.redhat.com. ;; ADDITIONAL SECTION: ns1.redhat.com. 363 IN A 209.132.186.218 ns2.redhat.com. 363 IN A 209.132.183.2 ns3.redhat.com. 363 IN A 209.132.176.100 ;; Query time: 35 msec ;; SERVER: 209.144.50.138#53(209.144.50.138) ;; WHEN: Thu Jan 12 10:15:00 2012 ;; MSG SIZE rcvd: 193
简要版:
$ dig -x 209.132.183.81 +short www.redhat.com.
默认情况下 dig 会使用你本机上 /etc/resolv.conf 文件中定义的 DNS 服务器。
如果你想使用不同的 DNS 服务器来执行查询,可以通过 @dnsserver 来在命令行指定。
$ dig @ns1.redhat.com redhat.com ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> @ns1.redhat.com redhat.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20963 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 4 ;; WARNING: recursion requested but not available ;; QUESTION SECTION: ;redhat.com. IN A ;; ANSWER SECTION: redhat.com. 60 IN A 209.132.183.81 ;; AUTHORITY SECTION: redhat.com. 600 IN NS ns1.redhat.com. redhat.com. 600 IN NS ns4.redhat.com. redhat.com. 600 IN NS ns3.redhat.com. redhat.com. 600 IN NS ns2.redhat.com. ;; ADDITIONAL SECTION: ns1.redhat.com. 600 IN A 209.132.186.218 ns2.redhat.com. 600 IN A 209.132.183.2 ns3.redhat.com. 600 IN A 209.132.176.100 ns4.redhat.com. 600 IN A 209.132.188.218 ;; Query time: 160 msec ;; SERVER: 209.132.186.218#53(209.132.186.218) ;; WHEN: Thu Jan 12 10:22:11 2012 ;; MSG SIZE rcvd: 180
你可以通过创建一个文件存储多行域名来告诉 dig 批量查询多个域名。
首先我们可以创建一个简单的 names.txt 文件,里面包含两个准备批量查询的域名。
$ vi names.txt redhat.com centos.org
接下来,我们可以通过 -f 标志来告诉 dig 读取该文件进行批量查询:
$ dig -f names.txt MX +noall +answer redhat.com. 600 IN MX 10 mx2.redhat.com. redhat.com. 600 IN MX 5 mx1.redhat.com. centos.org. 3600 IN MX 10 mail.centos.org.
当然你也可以通过命令行来进行该操作:
$ dig redhat.com mx +noall +answer centos.org ns +noall +answer ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> redhat.com mx +noall +answer centos.org ns +noall +answer ;; global options: +cmd redhat.com. 332 IN MX 10 mx2.redhat.com. redhat.com. 332 IN MX 5 mx1.redhat.com. centos.org. 3778 IN NS ns3.centos.org. centos.org. 3778 IN NS ns4.centos.org. centos.org. 3778 IN NS ns1.centos.org.
上例中同时查询了 redhat.com 的 MX 记录以及 centos.org 的 NS 记录。
你可能不想每次执行 dig 命令都带上一串选线,甚至 +short 也会觉得麻烦。这个时候你可以将这些选项配置到 .digrc 文件中,之后每次 dig 调用时,默认就会带上这些选项。配置如下选项:
$ cat $HOME/.digrc +noall +answer
那么在进行 dig 操作时你可以省略这些不写了:
$ dig redhat.com redhat.com. 60 IN A 209.132.183.81 $ dig redhat.com MX redhat.com. 52 IN MX 5 mx1.redhat.com. redhat.com. 52 IN MX 10 mx2.redhat.com.
原文地址:https://www.thegeekstuff.com/2012/02/dig-command-examples
通过 apt-get 安装模块或者 update 的时候出现的日志。解决方案
sudo vim /etc/gai.conf
找到
# precedence # Add another rule to the RFC 3484 precedence table. See section 2.1 # and 10.3 in RFC 3484. The default is: # #precedence ::1/128 50 #precedence ::/0 40 #precedence 2002::/16 30 #precedence ::/96 20 #precedence ::ffff:0:0/96 10 # # For sites which prefer IPv4 connections change the last line to # # 此处解开下行注释 #precedence ::ffff:0:0/96 100
删除 #precedence ::ffff:0:0/96 100
之前的 # 号即可。