|
Function |
DNSCMD option |
Example |
Comments |
|
Do any dnscmd command on a remote system |
dnscmd servername command |
dnscmd main.bigfirm.com /zoneprint bigfirm.com |
|
|
Create a primary zone |
dnscmd /zoneadd zonename /primary |
dnscmd /zoneadd bigfirm.com /primary |
|
|
Create a secondary zone |
dnscmd /zoneadd zonename /secondary master IP address |
dnscmd /zoneadd bigfirm.com /secondary 192.168.1.1 |
|
|
Host a zone on a server based on an existing (perhaps restored) zone file |
dnscmd /zoneadd zonename /primary /file filename /load |
dnscmd /zoneadd bigfirm.com /primary /file bigfirm.com.dns /load |
|
|
Delete a zone from a server |
dnscmd /zonedelete zonename [/f] |
dnscmd /zonedelete bigfirm.com /f |
(without the /f, dnscmd asks you if you really want to delete the zone) |
|
Show all of the zones on a DNS server |
dnscmd /enumzones |
dnscmd /enumzones |
|
|
Dump (almost) all of the records in a zone |
dnscmd /zoneprint zonename |
dnscmd /zoneprint bigfirm.com |
Doesn't show glue records. |
|
Add an A record to a zone |
dnscmd /recordadd zonename hostname A ipaddress |
dnscmd /recordadd bigfirm.com mypc A 192.168.1.33 |
|
|
Add an NS record to a zone |
dnscmd /recordadd zonename @ NS servername |
dnscmd /recordadd bigfirm.com @ dns3.bigfirm.com |
|
|
Delegate a new child domain, naming its first DNS server |
dnscmd /recordadd zonename childname NS dnsservername |
dnscmd /recordadd bigfirm.com test NS main.bigfirm.com |
This would create the "test.bigfirm.com" DNS child domain unter the bigfirm.com DNS domain |
|
Add an MX record to a zone |
dnscmd /recordadd zonename @ MX priority servername |
dnscmd /recordadd bigfirm.com @ MX 10 mail.bigfirm.com |
|
|
Add a PTR record to a reverse lookup zone |
dnscmd /recordadd zonename lowIP PTR FQDN |
dnscmd /recordadd 1.168.192.in-addr.arpa 3 PTR pc1.bigfirm.com |
This is the PTR record for a system with IP address 192.168.1.3 |
|
Modify a zone's SOA record |
dnscmd /recordadd zonename @ SOA primaryDNSservername responsibleemailipaddress serialnumber refreshinterval retryinterval expireinterval defaultTTL |
dnscmd /recordadd bigfirm.com @ SOA winserver.bigfirm.com mark.bigfirm.com 41 1800 60 2592000 7200 |
Ignores the serial number if it's not greater than the current serial number |
|
Delete a resource record |
dnscmd /recorddelete zonename recordinfo [/f] |
dnscmd /recorddelete bigfirm.com @ NS main.bigfirm.com /f |
Again, "/f" means "don't annoy me with a confirmation request, just do it." |
|
Create a resource record and incorporate a nonstandard TTL |
dnscmd /recordadd zonename leftmostpartofrecord TTL restofrecord |
dnscmd /recordadd bigfirm.com pc34 3200 A 192.168.1.4 |
|
|
Reload a zone from its zone file in \windows\system32\dns |
dnscmd /zonereload zonename |
dnscmd /zonereload bigfirm.com |
Really only useful on primary DNS servers |
|
Force DNS server to flush DNS data to zone file |
dnscmd /zonewriteback zonename |
dnscmd /zonewriteback bigfirm.com |
|
|
Tell a primary whom to allow zone transfers to |
dnscmd /zoneresetsecondaries zonename /nonsecure|securens |
dnscmd /zoneresetsecondaries bigfirm.com /nonsecure |
That example says to allow anyone who asks to get a zone transfer |
|
Enable/disable DNS NOTIFY |
dnscmd /zoneresetsecondaries zonename /notify|/nonotify |
dnscmd /zoneresetsecondaries bigfirm.com /nonotify |
Example disables DNS notification, which is contrary to the default settings. |
|
Tell a secondary DNS server to request any updates from the primary |
dnscmd /zonerefresh zonename |
dnscmd /zonerefresh bigfirm.com |
|
|
Enable or disable dynamic DNS on a zone |
dnscmd /config zonename /allowupdate 1|0 |
1 enables, 0 disables, 0 is default |
|
|
Stop the DNS service |
Either net stop dns or sc stop dns |
|
(No dnscmd command for this) |
|
Start the DNS service |
Either net start dns or sc start dns |
|
(No dnscmd command for this) |
|
Install the DNS service on a 2008 full install system |
servermanagercmd -install dns |
|
|
|
Install the DNS service on a 2008 Server Core system |
ocsetup DNS-Server-Core-Role |
|
Case matters -- ocsetup dns-server-core-role would fail |
|
Uninstall the DNS service on a 2008 Server full install system |
servermanagercmd -remove dns |
|
|
|
Uninstall the DNS service on a 2008 Server Core system |
ocsetup /uninstall DNS-Server-Core-Role |
|
|
На тестовата (developer ската) машина си имам инсталиран apache,php,mysql от пакета на Zend - Zend Server. По новият проект по който работя използвам и Python, идеята тук е да "пускам" python скриптовете през apache а не примерно през
shell_exec('command') . Идеята е да се подкара без външни модули.
За целта намираме httpd.conf файла (обикновено в "C:\Program Files\Zend\Apache2\conf" директорията), правим му резервно копие за всеки случай, отваряме го с някой текстови редактор пр. notepad. В последния ред на файла добавяме ScriptInterpreterSource Registry. А в
< Directory "C:\Program Files\Zend\Apache2/htdocs" >
намираме Options Indexes и му добавяме +ExecCGI като трябва да стане
Options Indexes +ExecCGI
и на нов ред добавяме AddHandler cgi-script .cgi .py
при мен директивата изглежда по следния начин
< Directory "C:\Program Files (x86)\Zend\Apache2/htdocs" >
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks +ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
AddHandler cgi-script .cgi .py
< / Directory >
Важно е да спомена че това е един от начините за подкарване на python в уеб под Windows. Тествано е на Windows Server 2003 и Windows 7.
Записваме промените по файла и рестартираме Apache сървъра. Ако има проблеми при стартирането четем лога за грешки и действаме :)
За тестване дали всичко е ок след рестартирането на Apache може да използвате следния код
#!c:/Python27 python # -*- coding: UTF-8 -*- # enable debugging import cgitb cgitb.enable() print "Content-Type: text/plain;charset=utf-8" print print "Hello World!"като реда
#!c:/Python27 python указва къде е инсталиран python :)
Един набързо написан php class за генериране на xml от php масив.
class xmlGen {
var $array = array();
var $xml = '';
private function strct($array) {
foreach ($array as $k=>$v) {
$tag = $k;
if(is_int($tag)) $tag = 'a_'.$tag;
$this->xml .= "<$tag>";
if (is_array($v)) {
self::strct($v);
} else {
$this->xml .= $v;
}
$this->xml .= "</$tag>";
}
}
public function gen($array, $root = 'root') {
self::strct($array);
$header = "<?xml version=\"1.0\" encoding=\"utf-8\"?><$root>";
$footer = "</$root>";
echo $header;
echo $this->xml;
echo $footer;
}
}
може да се използва по следния начин
$sample = array(
'zadacha' => array(
'1' => 'probna',
'2' => 'product_compile',
),
'test' => date('d.m.Y'),
);
include ('array2xml.php');
$xml = new xmlGen();
header ("content-type: text/xml");
echo $xml->gen($sample);
генерираният файл от примера е
<?xml version="1.0" encoding="utf-8"?>
<root>
<zadacha>
<a_1>
probna
</a_1>
<a_2>
product_compile
</a_2>
</zadacha>
<test>
31.10.2010
</test>
</root>
Благодарение на Интернет можем да гледаме лекциите от десетки университета които са си направили труда да ги заснемат и качат в някой сайт за обмен на видео съдържание. В случая това са лекциите от курса "Introduction to Computer Science and Programming" (нещото което ни преподаваха в ФМИ - 1ви курс) на MIT Като цяло програмирането в курса е на Python (новичък и мноого готин език, за разлика от C++ който ни преподават в ФМИ :) ) но не е специализиран само за него. Лекциите са за ниво начинаещи но има доста неща които могат да се научат и за самия език. Лекциите могат да се изгледат от тук. Лектори са Prof. Eric Grimson и Prof. John Guttag и са правени през 2008. Достъпни са благодарение на специалната програма на MIT - MIT OpenCourseWare
Днес започвам да работя над едно от идеите си, а именно уеб базирана администрация на MS DNS сървър. Въпреки че BIND дефакто е стандарта за DNS сървър :) Идеята е управлението на сървъра да става чрез python скриптове. Подробности по развитието следващата седмица...най-вероятно.
Освен ако не е посочено друго, всички текстове и снимки в този блог са защитени от лицензното споразумение на Creative Commons Attribution-Share Alike 2.5 Bulgaria