Skip to content

Instantly share code, notes, and snippets.

@icy
Created July 6, 2011 14:51
Show Gist options
  • Save icy/1067412 to your computer and use it in GitHub Desktop.
Save icy/1067412 to your computer and use it in GitHub Desktop.
rubydns 0.2.3 debug
1/ Switch to root account and make sure that I am using sytem Ruby
$ rvm info
1.8:
system:
uname: "Linux icy 2.6.39-ARCH #1 SMP PREEMPT Mon Jun 27 22:01:13 CEST 2011 i686 Genuine Intel(R) CPU U2700 @ 1.30GHz GenuineIntel GNU/Linux"
bash: "/bin/bash => GNU bash, version 4.2.10(2)-release (i686-pc-linux-gnu)"
zsh: "/bin/zsh => zsh 4.3.12 (i686-pc-linux-gnu)"
rvm:
version: "rvm 1.5.2 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]"
ruby:
interpreter: "ruby"
version: "1.8.7"
date: "2011-02-18"
platform: "i686-linux"
patchlevel: "2011-02-18 patchlevel 334"
full_version: "ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-linux]"
homes:
gem: "/home/ruby/gems/1.8/"
ruby: "not set"
binaries:
ruby: "/usr/bin/ruby"
irb: ""
gem: "/usr/bin/gem"
rake: ""
environment:
PATH: "/opt/NX/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/pi/bin:/home/pi/.rvm/bin:/home/pi/.rvm/bin"
GEM_HOME: "/home/ruby/gems/1.8/"
GEM_PATH: ""
MY_RUBY_HOME: ""
IRBRC: ""
RUBYOPT: ""
gemset: ""
2/ Install RubyDNS version 0.2.3
$ gem list
*** LOCAL GEMS ***
eventmachine (0.12.10)
rexec (1.1.12)
rubydns (0.2.3)
3/ Download the test script
$ wget https://github.com/icyfork/rubydns/blob/master/test/daemon2.rb
# Update the script "daemon2.rb"
$ diff daemon2.rb.origin daemon2.rb
38c38
< RUN_AS = "daemon"
---
> RUN_AS = "nobody"
60c60
< $R = Resolv::DNS.new(:nameserver => ["60.234.1.1", "60.234.2.2"])
---
> $R = Resolv::DNS.new(:nameserver => ["208.67.220.220", "208.67.222.222"])
3/ Launch the daemon
$ ruby daemon2.rb start
$ netstat -nap |grep :53
tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 20360/ruby
udp 0 0 0.0.0.0:53 0.0.0.0:* 20360/ruby
5/ Test with dig
$ dig google.com @localhost -p 53 yahoo.com
; <<>> DiG 9.8.0-P2 <<>> google.com @localhost -p 53 yahoo.com
;; global options: +cmd
;; connection timed out; no servers could be reached
6/ Stop the daemon
$ ruby daemon2.rb stop
Stopping daemon...
Sending TERM to pid 20360...
/home/ruby/gems/1.8/gems/rexec-1.1.12/lib/rexec/daemon/controller.rb:177:in `stop': undefined local variable or method `first' for RExec::Daemon::Controller:Module (NameError)
from /home/ruby/gems/1.8/gems/rexec-1.1.12/lib/rexec/daemon/controller.rb:35:in `daemonize'
from /home/ruby/gems/1.8/gems/rexec-1.1.12/lib/rexec/daemon/base.rb:114:in `daemonize'
from daemon2.rb:82
$ netstat -nap |grep :53
# empty
7/ Logs
(Empty stdout.log)
=== Error Log Opened @ Wed Jul 06 21:45:35 +0700 2011 ===
I, [2011-07-06T21:45:35.408072 #20360] INFO -- : Starting server...
D, [2011-07-06T21:46:03.257314 #20360] DEBUG -- : Receiving incoming query...
D, [2011-07-06T21:46:03.257942 #20360] DEBUG -- : Searching for google.com A
D, [2011-07-06T21:46:03.258079 #20360] DEBUG -- : Checking rule ["test.mydomain.org", "A"]...
D, [2011-07-06T21:46:03.258180 #20360] DEBUG -- : Resource type A matched
D, [2011-07-06T21:46:03.258287 #20360] DEBUG -- : Query google.com failed to match against test.mydomain.org
I, [2011-07-06T21:46:03.258430 #20360] INFO -- : Passthrough: google.com A
D, [2011-07-06T21:46:13.441690 #20360] DEBUG -- : Receiving incoming query...
D, [2011-07-06T21:46:13.442603 #20360] DEBUG -- : Searching for 220.220.67.208.in-addr.arpa PTR
D, [2011-07-06T21:46:13.442725 #20360] DEBUG -- : Checking rule ["test.mydomain.org", "A"]...
I, [2011-07-06T21:46:13.442885 #20360] INFO -- : Passthrough: 220.220.67.208.in-addr.arpa PTR
D, [2011-07-06T21:46:23.568449 #20360] DEBUG -- : Receiving incoming query...
D, [2011-07-06T21:46:23.590056 #20360] DEBUG -- : Searching for google.com A
D, [2011-07-06T21:46:23.590258 #20360] DEBUG -- : Checking rule ["test.mydomain.org", "A"]...
D, [2011-07-06T21:46:23.590358 #20360] DEBUG -- : Resource type A matched
D, [2011-07-06T21:46:23.590459 #20360] DEBUG -- : Query google.com failed to match against test.mydomain.org
I, [2011-07-06T21:46:23.590590 #20360] INFO -- : Passthrough: google.com A
D, [2011-07-06T21:46:33.709171 #20360] DEBUG -- : Receiving incoming query...
D, [2011-07-06T21:46:33.709641 #20360] DEBUG -- : Searching for 220.220.67.208.in-addr.arpa PTR
D, [2011-07-06T21:46:33.709755 #20360] DEBUG -- : Checking rule ["test.mydomain.org", "A"]...
I, [2011-07-06T21:46:33.709902 #20360] INFO -- : Passthrough: 220.220.67.208.in-addr.arpa PTR
@ioquatix
Copy link

Hi, I've tried to reproduce this problem on both Mac OS X and Linux, and haven't had much luck so far. I followed the instruction you've given above and my result is different:

# dig google.com @localhost -p 53 yahoo.com

; <<>> DiG 9.7.3 <<>> google.com @localhost -p 53 yahoo.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20982
;; flags: qr rd; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;google.com.            IN  A

;; ANSWER SECTION:
google.com.     300 IN  A   74.125.237.83
google.com.     300 IN  A   74.125.237.80
google.com.     300 IN  A   74.125.237.84
google.com.     300 IN  A   74.125.237.81
google.com.     300 IN  A   74.125.237.82

;; Query time: 295 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Jul 11 03:38:08 2011
;; MSG SIZE  rcvd: 108

;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18109
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 7, ADDITIONAL: 7

;; QUESTION SECTION:
;yahoo.com.         IN  A

;; ANSWER SECTION:
yahoo.com.      12762   IN  A   72.30.2.43
yahoo.com.      12762   IN  A   98.137.149.56
yahoo.com.      12762   IN  A   209.191.122.70
yahoo.com.      12762   IN  A   67.195.160.76
yahoo.com.      12762   IN  A   69.147.125.65

;; AUTHORITY SECTION:
yahoo.com.      40336   IN  NS  ns6.yahoo.com.
yahoo.com.      40336   IN  NS  ns8.yahoo.com.
yahoo.com.      40336   IN  NS  ns1.yahoo.com.
yahoo.com.      40336   IN  NS  ns2.yahoo.com.
yahoo.com.      40336   IN  NS  ns3.yahoo.com.
yahoo.com.      40336   IN  NS  ns4.yahoo.com.
yahoo.com.      40336   IN  NS  ns5.yahoo.com.

;; ADDITIONAL SECTION:
ns1.yahoo.com.      37589   IN  A   68.180.131.16
ns2.yahoo.com.      37589   IN  A   68.142.255.16
ns3.yahoo.com.      37591   IN  A   121.101.152.99
ns4.yahoo.com.      40336   IN  A   68.142.196.63
ns5.yahoo.com.      37591   IN  A   119.160.247.124
ns6.yahoo.com.      37589   IN  A   202.43.223.170
ns8.yahoo.com.      37589   IN  A   202.165.104.22

;; Query time: 1 msec
;; SERVER: 210.48.62.4#53(210.48.62.4)
;; WHEN: Mon Jul 11 03:38:08 2011
;; MSG SIZE  rcvd: 345

ayako:/home/samuel/rubydns# cat log/Server/stderr.log 
=== Error Log Opened @ Mon Jul 11 03:36:58 +1200 2011 ===
I, [2011-07-11T03:36:58.051321 #7442]  INFO -- : Starting server...
D, [2011-07-11T03:38:08.222565 #7442] DEBUG -- : Receiving incoming query...
D, [2011-07-11T03:38:08.222821 #7442] DEBUG -- : Searching for google.com A
D, [2011-07-11T03:38:08.222870 #7442] DEBUG -- : Checking rule ["test.mydomain.org", "A"]...
D, [2011-07-11T03:38:08.222906 #7442] DEBUG -- : Resource type A matched
D, [2011-07-11T03:38:08.222947 #7442] DEBUG -- : Query google.com failed to match against test.mydomain.org
I, [2011-07-11T03:38:08.222999 #7442]  INFO -- : Passthrough: google.com A
ayako:/home/samuel/rubydns# dig -v
DiG 9.7.3

However, I did fix some bug in RExec based on the error you were having when stopping the daemon. I don't think this would be responsible for the other error message you are getting though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment