Troels Kofoed Jacobsen’s blog


Printer / scanner
July 21, 2009, 11:32 pm
Filed under: FreeBSD | Tags: , , , ,

This post is part of the series FreeBSD on my laptop

I have a HP LaserJet 1020 which is shared from my linux workstation (CUPS). To use the printer from my FreeBSD laptop I have to add the driver, which is found in print/foo2zjs. CUPS has to be enabled in /etc/rc.conf with the line
cupsd_enable="YES"

After a reboot (or just a start of CUPS) the printer can be configured using the cups web interface at localhost:631

I have not tried this yet but by following the pkg-message you can supposedly set up the printer directly on the FreeBSD machine by downloading the firmware with the ‘getweb’ utility.

I also have a HP PSC 1300 printer/scanner. One should be able to install this using the guide in [1]

Resources:
[1] HP Linux Imaging & Printing on FreeBSD HowTo

[2] CUPS (freebsdwiki)



Encrypted container in mountable file on FreeBSD
July 17, 2009, 10:11 pm
Filed under: FreeBSD | Tags: , , ,

This post is part of the series FreeBSD on my laptop

The disk encruption chapter in the handbook [1] is not fully applicable as it only talks about encrypting real partitions. However a file can be attached as a device using mdconfig(8).

First a file of a proper size has to be made. Here the file is 1024 MB. dd(1) is used for the job:
dd if=/dev/zero of=/path/to/safe.img bs=1m count=1024

where /path/to/safe.img is the full path to the encrypted container.

Now the file is attached as a memory device using mdconfig:
mdconfig -f /path/to/safe.img

mdconfig will then output the devicename e.g. “md0″.

From here on the instructions in [1] can be followed with /dev/md0 as the device. (In the following the geli method is used)

Initialize the encryption
geli init /dev/md0

Attach it and create a filesystem and detach again
geli attach /dev/md0
newfs /dev/md0.eli
geli detach /dev/md0

Note that the decrypted device is at /dev/md0.eli!

Now the encrypted container is created.

When needing it mount it with:
mdconfig -f /path/to/file
geli attach /dev/md0
mount /dev/md0.eli /mnt/safe

Unmount it after use with
umount /mnt/safe
geli detach /dev/md0
mdconfig -d -u 0

Note that you are not necessarily given the device md0 but the first free one. Please take that into consideration.

Resources:
[1] Encrypting Disk Partitions



FreeBSD: Networking. LAN and Wireless.
July 5, 2009, 12:54 am
Filed under: FreeBSD | Tags: , , ,

This post is part of the series “FreeBSD on my laptop”

LAN pretty much just works. In rc.conf I have the lines:

hostname="fynkyhostnamegoeshere.domainname"
ifconfig_bge0="DHCP NOAUTO"
ifconfig_wpi0="WPA DHCP NOAUTO"

The first one just sets my hostname (obviously).

The second says that my ethernet connection should use DHCP and not connect automatically. This is done because otherwise it tries to connect at boot until timeout — adding 30 s to boot when no cable is plugged. (In 8.0 NOAUTO is deprecated, maybe a better solution is found. Maybe startup in background)

The last line is for wireless. Same story with DHCP NOAUTO. WPA tells it to use WPA, or actually just wpa-supplicant… This is configured in /etc/wpa_supplicant.conf as follows:

network={
ssid="MyEssid"
psk="LongPasswordGoesHere"
priority=1000
}

This is for my home network using wpa with a pre shared key (psk). The priority is set to 1000 as my home network has the highest priority. (all other networks are added with priority < 1000).

For the wireless to work, I also had to load the wpi driver in /etc/loader.conf, as well as accept the licence:

if_wpi_load="YES"
wpifw_load="YES"
legal.intel_wpi.license_ack=1

An interface (wpi0 in the example) is brought up with the command

/etc/rc.d/netif start wpi0

(as root)

I have also configured a pptp vpn to my work. A description of this can be found here.



pptp vpn from FreeBSD
July 5, 2009, 12:36 am
Filed under: FreeBSD | Tags: , , , , , , ,

I need to connect to work using pptp vpn from my FreeBSD laptop. This can be done using mpd (version 5, in net/mpd5). I just created the sections startup: and default: and copied pptp_client from /usr/local/etc/mpd5/mpd.conf, all into /usr/local/etc/mpd5/mpd.conf. As the server at work is MS i also merged the MPPE lines from pptp_vpn. The final result is the following:


startup:

default:
load pptp_client

pptp_client:
#
# PPTP client: only outgoing calls, auto reconnect,
# ipcp-negotiated address, one-sided authentication,
# default route points on ISP's end
#

create bundle static B1
set iface route 1.2.3.146/28
set ipcp ranges 0.0.0.0/0 0.0.0.0/0
set bundle enable compression
set ccp yes mppc
set mppc yes e40
set mppc yes e128
set bundle enable crypt-reqd
set mppc yes stateless

create link static L1 pptp
set link action bundle B1
set auth authname ********
set auth password *****'**
set link max-redial 0
set link mtu 1460
set link keep-alive 20 75
set pptp peer 1.2.3.4
set pptp disable windowing
open

One thing to note is that I do not use “set iface route default” as in the sample conf file. This is because the work lan and wan has the same ip-range even tough some addresses are only on the lan and others are only on the internet. If the lan part of the network had a more traditional layout (as 192.168.1.*) the default should work…