Master-Zone Blog Technical Notes

11Jun/10Off

Quick Note: Searching FreeBSD ports

If you already have the Ports Collection installed on your machine, you may search by changing to the /usr/ports directory and performing ``make search name=string``

# cd /usr/ports
# make search name=portname

VN:F [1.7.5_995]
Rating: 0.0/10 (0 votes cast)
Filed under: FreeBSD Comments Off
4Jun/100

BIND9 on FreeBSD

The Domain Name System, or DNS, is one of the Internet's fundamental building blocks. It is the global, hierarchical, and distributed host information database that's responsible for translating names into addresses and vice versa, routing mail to its proper destination, and many other services.

For this article I used a fresh installation from 8.0-RELEASE-i386-bootonly, enabled ssh, and installed bash. First thing I fetched the latest release for the ports, installed portupgrade and updated the system...

# portsnap fetch extract
# cd /usr/ports/ports-mgmt/portupgrade && make install clean
# portupgrade -a

Installation...

# cd /usr/ports/dns/bind97/ && make install clean

You are free to choose which options are to be compiled with bind, but make sure you choose REPLACE_BASE. It's always a good idea to run bind in a chroot-ed environment

# mkdir -p /var/chroot/named/etc/namedb /var/chroot/named/dev /var/chroot/named/var/run
# chown -R bind:bind /var/chroot/named/
# chmod 755 /var/chroot/named/
# chmod 555 /var/chroot/named/dev
# ln -s /etc/localtime /var/chroot/named/etc/localtime
# mknod /var/chroot/named/dev/zero c 2 12
# ln -s /dev/random /var/chroot/named/dev/random
# mknod /var/chroot/named/dev/null c 2 2
# chmod 666 /var/chroot/named/dev/*
# mv /etc/namedb /etc/old.namedb
# ln -s /var/chroot/named/etc/namedb /etc/namedb

Configuration...

# dig > /etc/namedb/named.root
# rndc-confgen -a -c /etc/namedb/rndc.conf -k rndc-key -b 256
# vi /etc/namedb/named.conf

controls { inet 127.0.0.1 port 953 allow { localhost; } keys { rndc-key; }; };

include "/etc/namedb/rndc.conf";

acl "trusted" { 127.0.0.1; 192.168.0.0/16; };

options {
directory "/etc/namedb";
pid-file "/var/run/named.pid";
dump-file "/var/dump/named_dump.db";
statistics-file "/var/stats/named.stats";

allow-transfer { 127.0.0.1; 192.168.56.3; };
listen-on { 127.0.0.1; 192.168.56.2; };

auth-nxdomain yes;
};

view "internal" {
match-clients { "trusted"; };
recursion yes;

zone "." { type hint; file "named.root"; };
zone "localhost" { type master; file "master/localhost-forward.db"; };
zone "127.in-addr.arpa" { type master; file "master/localhost-reverse.db"; };
};

view "external" {
match-clients { any; };
recursion no;
};

logging {
channel systemlog {
file "/var/log/named.log";
severity debug;
print-time yes;
};

channel audit_log {
file "/var/log/security.log";
severity debug;
print-time yes;
};

channel xfer_log {
file "/var/log/xfer.log";
severity debug;
print-time yes;
};

category default { systemlog; };
category security { audit_log; systemlog; };
category config { systemlog; };
category xfer-in { xfer_log; };
category xfer-out { xfer_log; };
category notify { audit_log; };
category update { audit_log; };
category queries { audit_log; };
category lame-servers { audit_log; };
};

After that, create /etc/namedb/master/localhost-forward.db and /etc/namedb/master/localhost-reverse.db

# vi /etc/namedb/master/localhost-forward.db

$TTL 3h
localhost. SOA localhost. nobody.localhost. 42 1d 12h 1w 3h

NS localhost.

A 127.0.0.1

# vi /etc/namedb/master/localhost-reverse.db

$TTL 3h
@ SOA localhost. nobody.localhost. 42 1d 12h 1w 3h

NS localhost.

1.0.0 A localhost.

And start named...


# echo named_enable="YES" >> /etc/rc.conf
# /etc/rc.d/named start

Following up is creating slave name server, creating a zone and syncing the master ns with the slave name server.

VN:F [1.7.5_995]
Rating: 0.0/10 (0 votes cast)
3Jun/100

Upgrading FreeBSD ports using portsnap and portupgrade

Portsnap is an alternative system for distributing the Ports Collection. Please refer to Using Portsnap for a detailed description of all Portsnap features.

First download a compressed snapshot of the Ports:

If it's the first time running portsnap...
# portsnap fetch extract

If you already have a populated /usr/ports and you are just updating...
# portsnap fetch update

A quick useful tip to check the outdated ports installed locally and their updates...
# portversion -vL=

To upgrade all of the outdated ports...
# portupgrade -a

To upgrade one or more ports...
# portupgrade bash bzip2 conky

VN:F [1.7.5_995]
Rating: 0.0/10 (0 votes cast)
Filed under: FreeBSD No Comments
26Oct/090

Openbox on FreeBSD

So I was always a big fan of KDE till 3.5. When 4 was released I wasn't pretty much pleased (though a lot of people like it). So I kept with 3.5 till I switched to Openbox.

Openbox is light-weight extensible window manager. It could be used in a desktop environment (GNOME and KDE) or as a standalone window manager without a desktop environment (The lightweight approach).

Openbox itself does not manage the desktop. That means installing Openbox won't give you easy menu access to wallpaper options, a taskbar or system panel, or most of those other doo-dads. It does, however, give a framework to build incorporate other programs that do those things and usually with a greater degree of freedom over the style and interface.

So breaking what's needed for a desktop...

  • A wallpaper, for fancying the background
  • A trayer, to keep track of system tray/notification area
  • A taskbar, to launch and monitor applications
  • Desktop Icons, for quick launching programs
  • Desktop Menu, provides a central launching point for application and tasks

Beautifying Openbox...

First thing I do upon configuring a new operating system, either Linux, FreeBSD or Windows, I set the wallpaper.

Install hsetroot for fancying the background
# pkg_add -r hsetroot
$ hsetroot -center /home/ahmed/.config/openbox/bg.jpg

Install trayer to keep track of system tray/notification area
# pkg_add -r trayer
$ trayer --edge bottom --align right --widthtype request --height 20 --SetDockType true --transparent true --alpha 255 --expand true

Install tint to launch and monitor applications
# pkg_add -r tint2
$ tint2 &

For the desktop icons, I use iDesk

The desktop menu is provided by right clicking anywhere on the desktop.

VN:F [1.7.5_995]
Rating: 0.0/10 (0 votes cast)
23Oct/090

Bring X to life on FreeBSD

By default, X isn't enabled on a new FreeBSD installation, even if it's installed during a regular installation. I tried to make it as simple as possible to get X running smoothly. I continued using the vm I created earlier for my FreeBSD asterisk installation.

During the installation, I chose to install X and xdm (located in x11 category in sysinstall), with no graphical desktops yet. Later, I installed openbox.

First thing, build an initial configuration file, and place it in /etc/X11/
# Xorg -configure; mv xorg.conf.new /etc/X11/xorg.conf

Then enable hal and dbus
# vi /etc/rc.conf

dbus_enable="YES"
hald_enable="YES"

At this point, X is configured, but need it needs a display manager. I was a big fan of KDM (I even wrote some kdm themes), but I choose to go with XDM. So to get xdm on...

Modify the xdm entry in /etc/ttys
# vi /etc/ttys

ttyv8 "/usr/local/bin/xdm -nodaemon" xterm on secure

XDM needs ~/.xsession file to launch a desktop environment, I use openbox.
# pkg_add -r openbox
$ echo "exec openbox-session" >> ~/.xsession

Now after rebooting, XDM will launch, and upon logging in, openbox will start.

VN:F [1.7.5_995]
Rating: 0.0/10 (0 votes cast)