• Quotes
  • Index
  • About
AOssama.NET Technical Notes

Category Archives: Freebsd

Quick Note: Find partition size in GB from fdisk

January 8, 2011 12:45 pm / Ahmed

I am a big fan of fdisk, and since the output of fdisk is the block size of each partition I had to find a way to know how much each partition’s size in GB…

Do the regular fdisk command, and note the block size:

# fdisk -l /dev/sda

output omitted…
Device Boot Start End Blocks Id System
/dev/xvdc1 * 1 2871 23061276 83 Linux
…output omitted

Then using bc (An arbitrary precision calculator language) do:

# echo “23061276/(2^20)” | bc

21

Which will output the partition size in GB

Posted in: FreeBSD, Linux / Tagged: fdisk, FreeBSD, Linux

Quick Note: Searching FreeBSD ports

June 11, 2010 10:03 am / Ahmed

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

Posted in: FreeBSD

BIND9 on FreeBSD

June 4, 2010 12:20 am / Leave a Comment / Ahmed

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 PTR 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.

Posted in: FreeBSD, Networking / Tagged: bind, bind freebsd, FreeBSD

Upgrading FreeBSD ports using portsnap and portupgrade

June 3, 2010 9:09 pm / Leave a Comment / Ahmed

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

Posted in: FreeBSD

Openbox on FreeBSD

October 26, 2009 3:58 am / Leave a Comment / Ahmed

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.

Posted in: FreeBSD / Tagged: FreeBSD, freebsd gui, freebsd x11, openbox

Post Navigation

1 2 Next »

Categories

  • Apache (1)
  • Asterisk (2)
  • bind9 (1)
  • FreeBSD (9)
  • iSCSI (2)
  • Linux (12)
  • Netcat (1)
  • Networking (3)
  • Penetration Testing (1)
  • PHP (2)
  • Squid (2)

Archives

  • January 2013 (1)
  • April 2012 (3)
  • May 2011 (1)
  • January 2011 (1)
  • September 2010 (1)
  • August 2010 (1)
  • June 2010 (3)
  • May 2010 (1)
  • November 2009 (2)
  • October 2009 (9)
  • September 2009 (2)

Meta

  • Register
  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
© Copyright 2013 - AOssama.NET
Infinity Theme by DesignCoral / WordPress