Logging DNS queries

If you ever need to look at the DNS queries sent to your server, there are two ways: Logging or looking at DNS traffic on port 53.

Logging queries in Bind

Logging is definitely more reliable and can be turned on (if you’re using bind) using rndc

To check if logging is enabled:

# rndc status |grep query
query logging is OFF

To turn logging on:

# rndc querylog on
# rndc status |grep query
query logging is ON

Once logging is enabled, the requests are by default logged to /var/log/messages:

# cat /var/log/messages |grep named |grep query
Jul 15 13:44:36 nas named[1858]: client 10.1.1.3#64896: query: steamr.com IN A + (10.1.1.9)
Jul 15 13:44:36 nas named[1858]: client 10.1.1.3#64897: query: steamr.com IN AAAA + (10.1.1.9)

DNS Traffic

To look at the actual DNS traffic (either directly to your server or sniffing on a network), use tcpdump. Here is an example of me looking up ‘steamr.com’ while tcpdump was running.

# tcpdump -n -s 1500 -i eth1 port 53
13:44:43.398635 IP 10.1.1.3.64903 > 10.1.1.9.domain: 6+ A? steamr.com. (28)
13:44:43.399434 IP 10.1.1.9.domain > 10.1.1.3.64903: 6 1/13/13 A 209.217.226.237 (463)
13:44:43.400415 IP 10.1.1.3.64904 > 10.1.1.9.domain: 7+ AAAA? steamr.com. (28)
13:44:43.401365 IP 10.1.1.9.20821 > 64.59.135.135.domain: 4278+ [1au] AAAA? steamr.com. (39)
13:44:43.412659 IP 64.59.135.135.domain > 10.1.1.9.20821: 4278 0/1/0 (74)
13:44:43.413243 IP 10.1.1.9.domain > 10.1.1.3.64904: 7 0/1/0 (74)

You can see the queries which are denoted with a question mark (?), and the responses to the queries.

Odd MySQL Problem using 100% CPU with Nothing Running

For some reason, MySQL (5.5.15) on my home server (running kernel 2.6.32-220.17.1.el6.x86_64) was using all my CPU:

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
10949 mysql 20 0 804m 53m 5868 S 125.8 1.6 415:09.88 mysqld

There was nothing running on MySQL.

mysql> show processlist;
+----+------+-----------+------+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+------+---------+------+-------+------------------+
| 36 | root | localhost | NULL | Query | 0 | NULL | show processlist |
+----+------+-----------+------+---------+------+-------+------------------+
1 row in set (0.00 sec)

My disk wasn’t full.

[root@nas leo]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 51606140 22222600 26762100 46% /

I tried restarting MySQL a few times, but it continued to use up all the CPU immediately after starting. After scratching my head and not wanting to waste any more time, I simply rebooted the machine and everything was back to normal again.

Documenting this in case someone else has ran into the same problem and possibly has a fix/

Booting Z/OS Emulation Files with Hercules

I recently stumbled across some (illegal) Z/OS emulation files for Hercules on The Pirate Bay a while back, but one thing which I couldn’t figure out was to actually get them working. With a little bit of searching, I’ve finally figured it out. This guide should help anyone who has absolutely no background with IBM mainframes or Hercules – but for some reason wishes to play with a mainframe – to get started.

Step 1: Required Programs and Files

You will need to download and install:

Secondly, you will need to obtain the Z/OS emulation files for Hercules (hint: search TPB or google ‘IBM Z OS Emulation files’)

Step 2: Configure your 3270 Terminal Emulator

Open the wc3270 Session Wizard and create a new session with the host set to localhost and the TCP port number set to 3270. Be sure to save your session by hitting ‘[Enter]’ at the menu. You may want to create a desktop shortcut to be used later.

Step 3: Configure hercules.cnf

Ensure that your hercules.cnf file references your DASD devices correctly. The paths from the configuration file may be relative. However, in my case, I’ve provided absolute paths.

Note that my DSAD files are on my D:\ibm\cckd\ directory. If you are using relative paths, ensure that your hercules.cnf file is in the correct location, relative to your cckd files.

Ensure your display terminals are set to 3270.

My hercules.cnf is as follows:


#
# Hercules Emulator Control file...
# Description:
# MaxShutdownSecs: 15
#
#
# System parameters
#

ARCHMODE z/Arch
ALRF ENABLE
CCKD RA=2,RAQ=4,RAT=2,WR=2,GCINT=5,GCPARM=0,NOSTRESS=0,TRACE=0,FREEPEND=-1
CNSLPORT 3270
CONKPALV (3,1,10)
CPUMODEL 3090
CPUSERIAL 012345
DIAG8CMD ENABLE
ECPSVM YES
LOADPARM 0A95DB..
LPARNAME HERCULES
MAINSIZE 1024
MOUNTED_TAPE_REINIT DISALLOW
NUMCPU 4
OSTAILOR Z/OS
PANRATE 80
PGMPRDOS LICENSED
SHCMDOPT NODIAG8
SYSEPOCH 1900
TIMERINT 50
TZOFFSET +1400
YROFFSET 0

HERCPRIO 0
TODPRIO -20
DEVPRIO 8
CPUPRIO 0
PANTITLE z/OS 1.9 IPL A80?

# Display Terminals

0700 3270
0701 3270
0702 3270
0703 3270
0704 3270

# DASD Devices

0A81 3390 D:/ibm/cckd/zares1.cckd sf=shadow/zares1_*
0A82 3390 D:/ibm/cckd/zares2.cckd sf=shadow/zares2_*
0A83 3390 D:/ibm/cckd/zadb81.cckd sf=shadow/zadb81_*
0A84 3390 D:/ibm/cckd/zadb82.cckd sf=shadow/zadb82_*
0A85 3390 D:/ibm/cckd/zadb83.cckd sf=shadow/zadb83_*
0A86 3390 D:/ibm/cckd/zadb84.cckd sf=shadow/zadb84_*
0A87 3390 D:/ibm/cckd/zadb91.cckd sf=shadow/zadb91_*
0A88 3390 D:/ibm/cckd/zadb92.cckd sf=shadow/zadb92_*
0A89 3390 D:/ibm/cckd/zacic1.cckd sf=shadow/zacic1_*
0A8A 3390 D:/ibm/cckd/zadis1.cckd sf=shadow/zadis1_*
0A8B 3390 D:/ibm/cckd/zadis2.cckd sf=shadow/zadis2_*
0A8C 3390 D:/ibm/cckd/zadis3.cckd sf=shadow/zadis3_*
0A8D 3390 D:/ibm/cckd/zadis4.cckd sf=shadow/zadis4_*
0A8E 3390 D:/ibm/cckd/zadis5.cckd sf=shadow/zadis5_*
0A8F 3390 D:/ibm/cckd/zadis6.cckd sf=shadow/zadis6_*
0A90 3390 D:/ibm/cckd/zaims1.cckd sf=shadow/zaims1_*
0A91 3390 D:/ibm/cckd/zaprd1.cckd sf=shadow/zaprd1_*
0A92 3390 D:/ibm/cckd/zaprd2.cckd sf=shadow/zaprd2_*
0A93 3390 D:/ibm/cckd/zaprd3.cckd sf=shadow/zaprd3_*
0A94 3390 D:/ibm/cckd/zaprd4.cckd sf=shadow/zaprd4_*
0A95 3390 D:/ibm/cckd/zasys1.cckd sf=shadow/zasys1_*
0A96 3390 D:/ibm/cckd/zauss1.cckd sf=shadow/zauss1_*
0A97 3390 D:/ibm/cckd/zawas1.cckd sf=shadow/zawas1_*
0A98 3390 D:/ibm/cckd/zawas2.cckd sf=shadow/zawas2_*
0A99 3390 D:/ibm/cckd/zawas3.cckd sf=shadow/zawas3_*
0A9A 3390 D:/ibm/cckd/sares1.cckd sf=shadow/sares1_*

 

Step 4: Starting Hercules

Start hercules on the same directory as your hercules.cnf file. In my case:

D:\ibm>"C:\Program Files\Hercules\Hercules 3.07 (64 Bit)\hercules.exe"

Hercules should start and you should see something similar to:

Press ‘ESC’ to switch to the graphic mode. Start two instances of the 3270 terminals that was made and configured in Step 2. The first will be the console terminal, the second will be the TSO terminal. If everything works, you should see two terminals binded to Hercules:

To start Z/OS, press ‘L’ for IPL, then F for the first Z/OS disk device (as highlighted above). Z/OS should begin loading.

The terminal console should halt and prompt whether to initialize sysplex ADCDPL or to reinitalize XCF. Enter ‘r 00,r’

It will then prompt asking for the couple system parameter. Enter ‘r 00,couple=**’

Step 5: Have Fun

The login screen should appear on the second terminal. You may login as ‘IBMUSER’ with the password ‘SYS1’.