Sunday, April 06, 2014

Dnsmasq: DNS & DHCP for a small network

For a small network like a home network, dnsmasq is an appropriate local DNS and DHCP server. The DNS is dynamic in the sense, that if a computer is assigned an IP by the DHCP server, it will show up in the DNS, as well.

NAT network and the virtual machines

For a first experience, I started with VirtualBox. Created a NAT network, vb.nat (192.168.4.0/24). For the installation of the virtual machines, DHCP is enabled in this network. Installed two virtual machines, dnsmasq.vb.nat (ubuntu-12.04.3-server-amd64) and client.vb.nat (ubuntu-13.10-desktop-amd64). For dnsmasq.vb.nat, the "SSH server" packages were chosen at installation.

To install VirtualBox guest additions, some packages are needed. Ubuntu server does not automount the CD and does not autostart the installation. The following commands do the installation:
frigo@dnsmasq:~$ sudo apt-get install build-essential dkms
frigo@dnsmasq:~$ sudo mount /dev/sr0 /mnt
frigo@dnsmasq:~$ sudo /mnt/VBoxLinuxAdditions.run
frigo@dnsmasq:~$ sudo eject
The VirtualBox guest additions are easy to install to client.vb.nat, using the graphical interface of the desktop Ubuntu.

Preparation: hosts and interfaces

After installation, the /etc/hosts file contains the name of the server with the 127.0.0.1 IP address that leads to a lot of trouble, so fix it as the first step:
frigo@dnsmasq:~$ sudo vi /etc/hosts
127.0.0.1       localhost
192.168.4.15    dnsmasq.vb.nat  dnsmasq
The second step of preparation is to set a fixed IP address for the DNS and DHCP server.

frigo@dnsmasq:~$ sudo vi /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.4.15
        netmask 255.255.255.0
        network 192.168.4.0
        broadcast 192.168.4.255
        gateway 192.168.4.1
        dns-nameservers 8.8.8.8 # Google Public DNS
        dns-search vb.nat
Testing: 
frigo@dnsmasq:~$ sudo service networking restart

Install and configure dnsmasq

The dnsmasq package is easy to install. The default configuration file contains 500+ lines of documentation and examples in the form of comments. The installation and the options that worked for me:
frigo@dnsmasq:~$ sudo apt-get install dnsmasq
frigo@dnsmasq:~$ sudo vi /etc/dnsmasq.conf

# Never forward plain names (without a dot or domain part)
domain-needed
# Never forward addresses in the non-routed address spaces.
bogus-priv
# Listen on eth0 (this option may be superfluous)
interface=eth0
# Set the domain for dnsmasq.
domain=vb.nat
# Enable the integrated DHCP server
dhcp-range=192.168.4.50,192.168.4.150,12h
# Override the default route supplied by dnsmasq
dhcp-option=3,192.168.4.1

Finished. Disable DHCP in VirtualBox.

Testing - use Alt-F1 and Alt-F2 to have two text consoles or use terminal windows in the graphical interface of client.vb.nat to ssh into dnsmasq:
frigo@dnsmasq:~$ tail -f /var/log/syslog
frigo@dnsmasq:~$ sudo service dnsmasq restart
You can restart client.vb.nat and see the DHCP handshake in dnsmasq syslog. Some simple tests:
frigo@client:~$ nslookup dnsmasq.vb.nat
Server:        127.0.1.1
Address:    127.0.1.1#53

Name:    dnsmasq.vb.nat
Address: 192.168.4.15

frigo@client:~$ nslookup client.vb.nat
Address: 192.168.4.147

frigo@client:~$ nslookup ubuntu.com
Address: 91.189.94.156

Useful information

This blog entry was inspired by the three articles about configuring isc-dhcp-server and bind9 at raerek.blogspot.hu (in Hungarian):
  1. http://raerek.blogspot.hu/2012/03/dhcp-szerver-ubuntu-1204-en.html
  2. http://raerek.blogspot.hu/2012/04/ddns-ubuntu-1204-en-elso-resz.html
  3. http://raerek.blogspot.hu/2012/04/ddns-ubuntu-1204-en-masodik-resz.html
 The most important sources of information used for my dnsmasq setup:
  1. https://wiki.debian.org/HowTo/dnsmasq 
  2. https://help.ubuntu.com/community/Dnsmasq
  3. http://xmodulo.com/2012/10/how-to-set-up-dhcp-server-using-dnsmasq.html
  4. http://edoceo.com/howto/dnsmasq

Saturday, June 25, 2011

Maxtor is now Seagate

30 merevlemezem között 2 Maxtor is akadt az elmúlt húsz évben. Mindkettő szektorhibákat kezdett gyűjteni. Az egyik egy 1996-os, szingapúri gyártású 71626AP modell (1.6 GB), a másik egy 2002-es, szintén szingapúri Fireball 3 (30GB).

Most épp egy 500 GB-os MAXELL márkájú, külső, USB diszkről próbálom lementeni a hibás szektorok közül a jókat. A myrescue programot használom.

Thursday, February 11, 2010

PrinciplesOfOod

Olvastam egy remek cikket az objektum-orientált tervezés elveiről.
Nem az elvek újdonsága, hanem a lényeg nagyon jó megragadása emeli ki a hasonló cikkek közül.
Érdemes megnézni a hozzá tartozó inspirációs képeket is!

Sunday, November 08, 2009

Ubuntu 9.10 - JDK6

Ubuntu 9.10 supports openjdk by default. To install the SUN JDK, the /etc/apt/sources.list file has to be extended by the following lines:
  • deb http://ftp.debian.org/debian squeeze main contrib non-free
  • deb-src http://ftp.debian.org/debian squeeze main contrib non-free
After that, JDK install is simple:
  1. sudo apt-get update
  2. sudo apt-get install sun-java6-jdk

Sunday, February 08, 2009

trac install - win XP

Components:
How to install and configure:
  1. Had to move IIS to port 1080 to make port 80 available for Apache:
    My computer /manage / IIS / default site / properties
  2. Apache: next-next-OK
  3. SVN server: extract the ZIP file and use the README in the zip file
    The referenced tortoisesvn howto is useless, but the end of the README itself is OK
    no installer, copy modules to Apache, add svnserver\bin to SYSTEM path, edit httpd.conf and REBOOT.
  4. Run "svnadmin create d:\repository\subversion\sandbox"
  5. Subversion is available now at http://localhost/svn
  6. Python: next-next-OK
  7. svn-python: next-next-OK
  8. Genshi: next-next-OK
  9. SetupTools: next-next-OK
  10. Trac: next-next-OK
  11. Run python25\Scripts\trac-admin.exe
    trac-admin d:\repository\trac\sandbox initenv
    (SVN repository: d:\repository\subversion\sandbox)
  12. test: python25\Scripts\tracd --port 8000 d:\repository\trac\sandbox
    URL: http://localhost:8000/sandbox
  13. mod_python: next-next-OK
  14. Apache config:

    copy mod_dav_svn.so & mod_authz_svn.so to apache2\modules

    enable (uncomment in apache2\conf\httpd.conf):
    LoadModule dav_module modules/mod_dav.so
    LoadModule dav_fs_module modules/mod_dav_fs.so

    add:
    LoadModule dav_svn_module modules/mod_dav_svn.so
    LoadModule authz_svn_module modules/mod_authz_svn.so
    LoadModule python_module modules/mod_python.so

    add locations and authentication to httpd.conf, see http://trac.edgewall.org/wiki/TracModPython

    Note: I had to use apache2/bin/htpasswd.exe with the "-p" option to generate authentication that works.

  15. Enable WebAdmin for your username:
    python25\scripts\trac-admin.exe /repository/trac/sandbox permission add username TRAC_ADMIN

  16. Test: http://localhost/trac/sandbox
    (works fine for me)
How to suck:
  • I have lost a lot of time trying to integrate svn-win32-1.5.5_py.zip to python.
    The solution was installing svn-python-1.5.5.win32-py2.5.exe

Monday, February 02, 2009

NSLU2

My NSLU2 came with the ancient firmware version v2.3R24. The newest available firmware is V2.3R63, although dead links can be found at the linksys site to V2.3R76.

I have tried to upgrade using the web interface, but it did not work, just the status led started blinking green/amber for hours, until switch-off (in theory, the upgrade should have been finished in 5-10 minutes). After restart the unit came up with the old firmware.

Wednesday, January 14, 2009