Tuesday, January 25, 2011

Framebuffer

I really like to work with the commandline but framebuffer is something i don't wanna miss anymore. The default installation of CentOS-5 comes with framebuffer support but it is not activated. To activate it edit your grub.conf and append to the kernel line with the vga parameter:

# vi /boot/grub.conf
...
kernel /boot/vmlinuz-2.6.18-194.32.1.el5 ro root=LABEL=/ vga=0x305
...

After that reboot your machine and you will have a commandline resolution of 1024x768. Or you use one of these values:

0x307   1280x1024
0x305   1024x768
0x303    800x600
0x301    640x480
 
If you use lilo as your bootloader, then expand the configuration file with this option for a resolution of 1024x768:

# vi /etc/lilo.conf
...
vga=791
...

Or use another value:

vga=791 1024x768
vga=788  800x600
vga=785  640x480

Then reinstall lilo and reboot:

# lilo
Added Linux
...
# shutdown -r now
Print Friendly and PDF

Sunday, January 23, 2011

DNS & DHCP

This weekend I setup my DNS and DHCP again (updated to new version and changed the software). I am currently using the DNS and DHCP from ISC. There is nothing special about it, just the usual stuff. This configuration example will allow you to setup a normal DNS for caching and with a forward and reverse lookup zone, incl. access for rndc and updates from DHCP. The DHCP server will be configured with a small range of IP's and with access to update the DNS. The domain will be example.com but you can use whatever you want. The DNS and DHCP server will be the same machine. It's name in this example configuration is dc01. The network size is from 192.168.1.64 - 192.168.1.127, obviously the netmask is 255.255.255.192. The IP's from 192.168.1.65 - 192.168.1.120 I want to use as static IP's for my servers to play around. The IP's from 192.168.1.121 - 192.168.1.126 I want to use as DHCP range. Also the DNS acts caching, that means that all addresses that are not locally available will be externally resolved.

DNS

First configure the named (all leading "spaces" must be "tabs"):

# vi /etc/named.conf
options {
        directory "/var/named";
        forward first;
        forwarders {
                58.6.115.43;
        };
};

// KEYS
key "rndc_key" {
        algorithm hmac-md5;
        secret "secret_rndc_key";
};

key "dhcp_key" {
        algorithm hmac-md5;
        secret "secret_dhcp_key";
};

// RNDC
controls {
        inet 127.0.0.1 allow { localhost; } keys { rndc_key; };
};

// ZONES
zone "." {
        type hint;
        file "root.hints";
};

zone "0.0.127.in-addr.arpa" {
        type master;
        file "zones/0.0.127";
};

zone "example.com" {
        type master;
        notify no;
        file "zones/example.com";
        allow-update { key "dhcp_key"; };
};

zone "1.168.192.in-addr.arpa" {
        type master;
        notify no;
        file "zones/1.168.196";
        allow-update { key "dhcp_key"; };
};

The configuration file above has some basic option in the beginning followed by two keys. The first key will allow the dhcpd to update the hosts in the domain. The second key will allow to control named by the rndc command.
Then configure the rndc:

# vi /etc/rndc.conf
key rndc_key {
        algorithm "hmac-md5";
        secret "secret_rndc_key";
};

options {
        default-server localhost;
        default-key    rndc_key;
};

There is nothing special about it, just the key and the server to control.
After that the 3 zone files must be created. At first for localhost (all leading "spaces" must be "tabs"):

# vi /var/named/zones/0.0.127
@       IN      SOA     dc01.example.com. root.example.com. (
                        1       ; Serial
                        8H      ; Refresh
                        2H      ; Retry
                        4W      ; Expire
                        1D)     ; Minimum TTL
                NS      dc01.example.com.
1               PTR     localhost.

Then the forward zone files (all leading "spaces" must be "tabs"):

# vi /var/named/zones/example.com
example.com             IN SOA  dc01.example.com. root.example.com. (
                                199804069  ; serial
                                28800      ; refresh (8 hours)
                                7200       ; retry (2 hours)
                                2419200    ; expire (4 weeks)
                                86400      ; minimum (1 day)
                                )
                        NS      dc01.example.com.
                        A       192.168.1.73
                        MX      10 dc01.example.com.
bck01                   A       192.168.1.76

The file above has some basic options about refresh etc. It also holds the NS record and the MX record. This is for the name server and the mail exchanger which are both dc01. The last entry is any server with a A record and an IP.
The last file is the reverse zone file (all leading "spaces" must be "tabs"):

# vi var/named/zones/1.168.196
1.168.192.in-addr.arpa  IN SOA  dc01.example.com. root.example.com. (
                                199803388  ; serial
                                28800      ; refresh (8 hours)
                                7200       ; retry (2 hours)
                                2419200    ; expire (4 weeks)
                                86400      ; minimum (1 day)
                                )
                        NS      dc01.example.com.
76                      PTR     bck01.example.com.

The reverse file just holds the NS again and the server from above.
Start named with the following command:

# /usr/sbin/named

Check if it is running:

# pgrep -fl named
8212 /usr/sbin/named

When it's not up and running, then check the logs. These can be /var/log/syslog, /var/log/messages or maybe /var/named/named.run. But this depends on your system.

DHCP

The next configuration file is for the DHCP which is much smaller then the DNS configuration above. First configure the dhcpd configuration file:

# vi /etc/dhcpd.conf
# GENERIC
default-lease-time 86400;  # ONE DAY
max-lease-time 604800;     # ONE WEEK

# DDNS
ddns-update-style interim;
ddns-domainname "example.com";
update-static-leases true;
key dhcp_key {
  algorithm hmac-md5;
  secret secret_dhcp_key;
};

# ZONES
zone example.com. {
  primary 127.0.0.1;
  key dhcp_key;
}
zone 1.168.192.in-addr.arpa. {
  primary 127.0.0.1;
  key dhcp_key;
}

# LEASES
subnet 192.168.1.64 netmask 255.255.255.192 {
  option domain-name-servers 192.168.1.73;
  option domain-name "example.com";
  range 192.168.1.120 192.168.1.126;
  option routers 192.168.1.73;
}

The configuration above is very simple. It begins with the lease times and continues with section how to update the DNS. The last section defines the DHCP leases for the clients itself like the netmask, the DNS etc.
Start the dhcp server and check it:

# /usr/sbin/dhcpd
# pgrep -fl dhcpd
15295 /usr/sbin/dhcpd

If it is not up and running, check the logs again. If you now request an IP over DHCP than the DHCP server updates the DNS with the leased IP and the hostname of the client:

# dhcpcd eth0
...
# nslookup nb001
Server:         192.168.1.73
Address:        192.168.1.73#53

Name:   nb001.example.com
Address: 192.168.1.120

And check your /etc/resolv.conf:

# cat /etc/resolv.conf
# Generated by dhcpcd from eth0
# /etc/resolv.conf.head can replace this line
domain example.com
nameserver 192.168.1.73
# /etc/resolv.conf.tail can replace this line

Or just use dig:

# dig bck01
...
# dig -x bck01
...
Print Friendly and PDF