Saturday, July 16, 2011

IP Addr and Internet Name - Part 1 Commands

cat /etc/resolv.conf

BIND
====
BIND is an acronym for the Berkeley Internet Name Domain project,
which is a group that maintains the DNS-related software suite that runs under Linux.
The most well known program in BIND is named, the daemon that responds to DNS queries from remote machines.

ref: http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch18_:_Configuring_DNS


The Host Command
=================
The host command accepts arguments that are either the fully qualified domain name
or the IP address of the server when providing results. To perform a forward lookup,
use the syntax:

[root@bigboy tmp]# host www.linuxhomenetworking.com
www.linuxhomenetworking.com has address 65.115.71.34


The nslookup Command
=====================
The nslookup command provides the same results on Windows PCs. To perform forward lookup, use.

sudo apt-get install dnsutils

s@penguin:~$ nslookup portal.trueinternet.co.th
Server: 192.168.1.1
Address: 192.168.1.1#53

Non-authoritative answer:
Name: portal.trueinternet.co.th
Address: 61.91.230.178

authoritative = ซึ่งเชื่อถือได้


dig
====
dig {domain.to.lookup}

>> look in /etc/resolv.conf file and querying the DNS servers listed there.

s@penguin:~$ dig portal.trueinternet.co.th +nocmd +nostats +noquestion

; <<>> DiG 9.7.3 <<>> portal.trueinternet.co.th +nocmd +nostats +noquestion
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47978 ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; WARNING: recursion requested but not available ;; ANSWER SECTION: portal.trueinternet.co.th. 531 IN A 61.91.230.178 s@penguin:~$ dig portal.trueinternet.co.th ; <<>> DiG 9.7.3 <<>> portal.trueinternet.co.th
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27376
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;portal.trueinternet.co.th. IN A

;; ANSWER SECTION:
portal.trueinternet.co.th. 243 IN A 61.91.230.178

;; Query time: 4 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Thu May 26 09:25:52 2011
;; MSG SIZE rcvd: 59


Lines beginning with ; are comments that are not part of the information received from the DNS server

the RA flag shows that recursive queries are available.

The IN means this is an Internet lookup (in the Internet class).

The A record stores the host IP address.
The CNAME is an alias record, which is used to give multiple aliases to a single computer.
The MX record is the mail exchange record, which tells mail servers how to route email for this domain.

* to query other DNS servers
dig @ns.hosteurope.com www.hungrypenguin.net


Ref: http://www.linux.com/learn/tutorials/442431-check-your-dns-records-with-dig


List open ports and listening services
$ netstat -an
# -n : to get port numbers instead of having the utility try to provide names for services
$ netstat -lnptu

$ sudo apt-get install nmap
$ nmap localhost

$ sudo apt-get install sockstat
$ sockstat

then
$ grep -w 631 /etc/services


Fix IP
=======
sudo vi /etc/network/interfaces
replace
  allow-hotplug eth0
  iface eth0 inet dhcp
with
  auto eth0
  iface eth0 inet static
  address 192.168.1.36
  netmask 255.255.255.0
  gateway 192.168.1.1
  dns-nameservers 192.168.1.1

sudo ifconfig eth1 192.168.2.3 netmask 255.255.255.0
sudo route add default gw 192.168.2.1 eth1

more info: http://www.cyberciti.biz/faq/setting-up-an-network-interfaces-file/

No comments:

Post a Comment