Archive for the ‘Ubuntu Linux’ Category

df: displays file system disk space usage for all partitions

free: displays the amount of free and used memory in the system

top: displays running processes

uname -a: prints system information

lsb_release -a: prints version information information of the Linux release currently running

ifconfig: reports system network interfaces

iwconfig: reports wireless network adapters

ps: view all running processes

lspci: lists all pci devices

lsusb: lists usb devices

lshw: lists hardware

RPM Package Management

Posted: 11/12/2011 in Ubuntu Linux
Tags: , ,

Most rpm package names are formed as:
name-version-release.architecture.rpm

Use rpm command to manage rpm-based packages.

Major mode options (first option given to rpm)
-install [-i]: install the package
-update [-u]: update or install a package
-freshen[-F]: update only installed package
-verify [-V]: file size, MD5, permissions, type
-query [-q]: query installed/uninstalled packages and files
-erase [-e]: uninstall package

Minor mode options (option that is not in the first position)
a: apply to all installed packages
v: verbose
h: add hashes while processing

Minor mode options together with q
c: list configuration files
d: list documentation files
f: queries which package installed a given file
h: adds hashes while processing
i: list information about a package
l: list all files and directories in a package
p: specifies that the query is performed on the package file


Credits to: http://nakedape.cc

A Web Server delivers web pages requested by clients via the internet. Apache has been the most popular and widely used web server today; in fact, it is the default web server on most Linux Distros. Web pages from the Apache Server can be accessed from a web browser, any web browser initiates communication from a web server by making a request using HTTP or HTTPS.

Installing Apache2 on an Ubuntu machine.

sudo apt-get install apache2

After installing apache2, important files are stored in /etc/apache2.
httpd.conf is the main configuration file for Apache.
apache2.conf is the main configuration file for Apache2.

Starting Apache

sudo /etc/init.d/apache2 start
or
sudo service apache2 start
or
sudo service apache2 graceful --> calls apachectl

Stoping Apache2

sudo /etc/init.d/apache2 stop
or
sudo service apache2 stop

apache2ctl
apache2ctl is a management utility, an Apache HTTP server control interface that is also used to start and stop Apache. Commands are:

start -Start the daemon
stop -Stop the daemon
restart -Restart or start the daemon
fullstatus -Report status of server (requires lynx)
graceful -Gracefully restart the server
configtest -Test config file syntax
help -Display commands

For apache2 options, type man apache2 on the terminal. If apache version 1 is installed on a machine, same commands are used, instead apache2 is replaced with httpd.

The following daemon and utilities form the heart of DNS operations:

named

This daemon must be running for DNS to be operational on all but remote servers. After you enable your server, named is invoked each time your system enters multiuser mode. It reads information found in the configuration file, named.conf(4tcp), and takes appropriate actions: priming the cache, accessing zone files, and so on. named can also be invoked from the command line; see named(1Mtcp) for more information.

named-xfer

This command enables you to transfer a DNS zone from one server to another in asynchronous mode so that named can continue processing requests. See the manual page for named-xfer(1Mtcp) for more information.

nslookup

This command allows you to request DNS information, including names, addresses, and other resource records, from any server you can reach from your computer. You can use nslookup to request a single record or start an nslookup session to request multiple records from one or more servers. See nslookup(1Mtcp) or “BIND 9 Administrator’s Guide” for more information.

dig

This command is similar to nslookup but with a slightly different syntax. See dig(1Mtcp) for more information.

host

This command is useful for finding out information about individual or multiple hosts. See host(1Mtcp) for more information.

Source: http://docsrv.sco.com/NET_tcpip/dnsC.daemons.html

This is a step by step guide on how to configure BIND9 as a Primary Master Name Server.

A Primary Master Name Server reads data for a domain zone from a file located on it’s host and is authoritative for that zone. Every zone needs to have at least one DNS name server that is responsible for it. When any device on the Internet wants to know something about a zone, it consults one of its authoritative servers.

The steps will configure your name server as a Primary Master for engrdhee.com. Replace engrdhee.com with your own FQDN (Fully Qualified Domain Name).

Name Server Configuration

Step 1: Configure your Local Network.
Set up the name server’s IP configuration in /etc/network/interfaces.

Step 2: Edit host settings on the name server. Edit /etc/hosts.

[Internet address] [official hostname] [alias1]
127.0.0.1       ns1     localhost.localdomain   localhost
192.168.1.4     ns1.engrdhee.com                 ns1

/etc/hosts file contains IP addresses associated on each host names. The file is accessed by commands that use the network in the absence of a name server.

Step 3: Create a zone file on /etc/bind directory.

sudo nano db.engrdhee.com
; BIND data file for local loopback interface
$TTL    604800
@       IN      SOA     ns1.engrdhee.com. root.engrdhee.com. (
                              4         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
                        NS      ns1.engrdhee.com.

router  IN      A       192.168.1.1
ns1     IN      A       192.168.1.4
laptop          A       192.168.1.2

A zone file is a text file containing a list of all the hosts in your domain, and their corresponding IP address.
DNS records are listed at the bottom of the zone. Here’s a list of DNS records and their meaning:
SOA – Start of Authority. The record that states that this server is authorative for the specified domain.
NS – Name server: Specifies the name server to use to look up a domain
MX – Mail Exchange: Specifies mail server(s) for the domain.
A – A Record: Used for linking a FQDN to an IP address
CNAME – Canoical name: Used to assign aliases to existing A records.
PTR – Used to reveres map IP addresses to a FQDN.

Step 4: Create a reverse zone file.

sudo nano rev.1.168.192.in-addr.arpa
; BIND reverse data file for local loopback interface
$TTL    604800
@       IN      SOA     ns1.engrdhee.com. root.engrdhee.com. (
                              3         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
        IN      NS      ns1.engrdhee.com
1       IN      PTR     router.engrdhee.com
2       IN      PTR     laptop.engrdhee.com

A Reverse zone allows DNS to conversion from an address to a name.

Increment the serial every time changes are made in the zone and reverse zone file.

Step 5: Edit /etc/bind/named.conf.local.

zone "engrdhee.com" {
        type master;
        file "/etc/bind/db.engrdhee.com";
};

zone "1.168.192.in-addr.arpa" {
        type master;
        file "/etc/bind/rev.1.168.192.in-addr.arpa";
};

The configuration will tell bind to use the files we created.

Step 6: Configure server firewall, if any.
Open port 53 to accept DNS requests. For ufw, use:

sudo ufw allow 53
sudo ufw allow bind9

sudo ufw app list will list available apps.

Step 7: Reload service.

sudo service bind9 reload

Client Configuration

Step 1: Configure each clients with their correct name server. Edit /etc/resolv.conf.

domain engrdhee.com
search engrdhee.com
nameserver 192.168.1.4
nameserver 192.168.1.1

Testing

tail -f /var/log/syslog
Output should be:

Sep 28 17:57:04 dhee-engr named[3047]: received control channel command 'reload'
Sep 28 17:57:04 dhee-engr named[3047]: loading configuration from '/etc/bind/named.conf'
Sep 28 17:57:04 dhee-engr named[3047]: reading built-in trusted keys from file '/etc/bind/bind.keys'
Sep 28 17:57:04 dhee-engr named[3047]: using default UDP/IPv4 port range: [1024, 65535]
Sep 28 17:57:04 dhee-engr named[3047]: using default UDP/IPv6 port range: [1024, 65535]
Sep 28 17:57:04 dhee-engr named[3047]: reloading configuration succeeded

Use DNS utilities, daemons and other commands to test.
e.g.:

dig engdrhee.com
nsllookup engrdhee.com
route -n 
ping engrdhee.com 
named-checkzone engrdhee.com /etc/bind/db.engrdhee.com
named-checkzone engrdhee.com /etc/bind/rev.1.168.192.in-addr.arpa
dig rev.1.168.192.in-addr.arpa. AXFR

This is a guide on how to configure BIND9 as a Caching Name Server. BIND9 is set-up as a caching name server by default.

A Caching Name Server caches a received information about a IP-address and FQDN (Fully Qualified Domain Name) mapping. It will reduce the search cost, reducing bandwidth and latency.

Name Server Configuration

Step 1: Add the IP address of your ISP’s DNS servers on /etc/bind/named.conf.options.

        forwarders {
             8.8.8.8;
             8.8.4.4;
        };

In this case, google’s public dns is used. You can replace them with your ISP’s DNS servers.

Step 2: Restart the BIND daemon.

sudo /etc/init.d/bind9 restart

Client Configuration

Step 1: Add the IP Address of your Name Server on /etc/resov.conf.

nameserver 192.168.1.2

Testing

dig -x 127.0.0.1
Output should be:

; <> DiG 9.4.1-P1 <> -x 127.0.0.1
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13427
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
[...]
;; Query time: 1 msec
;; SERVER: 172.18.100.80#53(172.18.100.80)
;; WHEN: Mon Nov 26 23:22:53 2007
;; MSG SIZE  rcvd: 93

dig google.com twice
Compare the query time. The second query time should improve. This is because your server cache the query.

DNS Server – BIND9

Posted: 09/30/2011 in Ubuntu Linux
Tags: , , ,

http://www.google.com is actually 74.125.71.104. Thanks to the power of DNS Servers! We do not have to remember the numeric address 74.125.71.104 just to visit google.com. A DNS Server, a Name Server as we may call it, contains a record of ip addresses and their equivalent domain name.

BIND (Berkley Internet Naming Daemon) is the most widely used DNS software on the Internet. It provides various services such as caching Name Server and serving DNS Zones for a domain name.

BIND9 Configuration Files

Configuration files are stored in /etc/bind.
Main configuration files are:

/etc/bind/named.conf
/etc/bind/named.conf.options
/etc/bind/named.conf.local

How to Install BIND9
sudo apt-get install BIND9

sudo apt-get install dnsutils

A useful package for testing and troubleshooting DNS issues.

Step1: Edit etc/network/interfaces
e.g.:

sudo vi /etc/network/interfaces
auto eth0
iface eth0 inet static
address 10.50.15.12
netmask 255.255.255.192.
gateway 10.50.26.1

Disable Network Manager first. Unless, your configuration will be ignored.

Step 2: Start networking

sudo /etc/init.d/networking start

Step 3: Check your network information

ifconfig

Other than editing /etc/network/interfaces, here’s another way to configure your network interface:
The following are low-level commands.

$ sudo ifconfig eth0 192.168.7.26 netmask 255.255.255.0 broadcast 192.168.7.255 ←
$ sudo ifconfig eth0 down ←
$ sudo route add -net 192.168.7.0 netmask 255.255.255.0 dev eth0 ←
$ sudo route add default gw 192.168.7.1 ←
Files

/etc/hostname – holds the hostname
/etc/hosts – file mapping of IP addresses – hostnames
/etc/networks – maps network addresses -names
/etc/host.conf – replaced by nsswitch
/etc/resolv.conf – client dns configuration
/etc/services – maps port numbers to names
/etc/nsswich.conf – name service switch configuration file, determines how system looks up name and various other things.

Commands

ifconfig – show and configure network interfaces
route – show and configure network routes
dhcpcd, dhcpclient, pmp – DHCP clients
dig – tests DNS servers
host – query and debug DNS servers
hostname – display hostname, and NIS domaind setting
netstat – shows what service is listening on what port
ping – sends ICMP echo request to hosts
traceroute – show the path (display routes) that a network connection takes.
mtr – works like traceroute in real time
tcpdump – packet sniffer command that displays the contents of packets received on a network interface.
route -n – view the routing table
whois – queries information about the owner of the domain

Netstat
netstat -a -u -t – Prints ports in use
netstat -r – Prints routing table
netstat -i – Prints interfaces
netstat -g – Prints multicast groups
netstat -M – Prints masqueraded connections
netstat -s – Prints statistics