Category Archives: Sysadmin

Systems Administration

Google SMTP available over IPv6

chateau.d.if!abbe:~ % dig aaaa smtp.gmail.com

; <<>> DiG 9.6.-ESV-R3 <<>> aaaa smtp.gmail.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23570
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 13, ADDITIONAL: 0

;; QUESTION SECTION:
;smtp.gmail.com.                        IN      AAAA

;; ANSWER SECTION:
smtp.gmail.com.         114     IN      CNAME   gmail-smtp-msa.l.google.com.
gmail-smtp-msa.l.google.com. 115 IN     AAAA    2001:4860:8005::6d

;; AUTHORITY SECTION:
com.                    104845  IN      NS      l.gtld-servers.net.
com.                    104845  IN      NS      a.gtld-servers.net.
com.                    104845  IN      NS      j.gtld-servers.net.
com.                    104845  IN      NS      d.gtld-servers.net.
com.                    104845  IN      NS      g.gtld-servers.net.
com.                    104845  IN      NS      b.gtld-servers.net.
com.                    104845  IN      NS      c.gtld-servers.net.
com.                    104845  IN      NS      f.gtld-servers.net.
com.                    104845  IN      NS      m.gtld-servers.net.
com.                    104845  IN      NS      k.gtld-servers.net.
com.                    104845  IN      NS      h.gtld-servers.net.
com.                    104845  IN      NS      e.gtld-servers.net.
com.                    104845  IN      NS      i.gtld-servers.net.

;; Query time: 0 msec
;; SERVER: ::1#53(::1)
;; WHEN: Sun Jul 10 08:32:14 2011
;; MSG SIZE  rcvd: 322

chateau.d.if!abbe:~ % telnet smtp.gmail.com smtp
Trying 2001:4860:8005::6d...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP e13sm7839160wfd.1
EHLO lostca.se
250-mx.google.com at your service, [2001:470:f803:8000::1]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250 PIPELINING
QUIT
221 2.0.0 closing connection e13sm7839160wfd.1
Connection closed by foreign host.

Super cool 😀

Default sound device in FreeBSD

I’ve an nVidia Graphics card in my FreeBSD box, and snd_hda.ko detects audio device on it as well. But the problem is, the audio interface is masked on the card, so there are no physical audio sockets on the card.

chateau.d.if!abbe:~ % cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 64bit 2009061500/amd64)
Installed devices:
pcm0: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play) default
pcm1: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play)
pcm2: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play)
pcm3: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play)
pcm4: <HDA Realtek ALC889 PCM #0 Analog> (play/rec)
pcm5: <HDA Realtek ALC889 PCM #1 Analog> (play/rec)
pcm6: <HDA Realtek ALC889 PCM #2 Digital> (play)
pcm7: <HDA Realtek ALC889 PCM #3 Digital> (play)

The only problem with this setup is that all of my sound applications which try to use /dev/dsp end up using pcm0, which doesn’t exist physically. The tricky thing is that, there is no /dev/dsp on filesystem, so kernel internally manages accesses to that device node. To switch to on-board audio (i.e. pcm4) as default sound device, I did sysctl hw.snd.default_unit=4, which worked:

chateau.d.if!abbe:~ % cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 64bit 2009061500/amd64)
Installed devices:
pcm0: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play)
pcm1: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play)
pcm2: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play)
pcm3: <HDA NVidia (Unknown) PCM #0 DisplayPort> (play)
pcm4: <HDA Realtek ALC889 PCM #0 Analog> (play/rec) default
pcm5: <HDA Realtek ALC889 PCM #1 Analog> (play/rec)
pcm6: <HDA Realtek ALC889 PCM #2 Digital> (play)
pcm7: <HDA Realtek ALC889 PCM #3 Digital> (play)

To persist the changes, I added it to sysctl.conf(5). I’ve not rebooted it yet, but I’m sure it’ll work 😉

Setting up MTNL 3G internet connection in FreeBSD

Recently I bought an MTNL 3G internet connection to add some redundancy to my internet connectivity stack. As I use, Following is how I got it running in FreeBSD (8.2-RELEASE) with the help from a similar HOWTO for GNU/Linux.

1. Plugin the device. Following is the dmesg output after plugging in the device (Teracom LW272):

umass0: <6227--Storage> on usbus4
umass0:  SCSI over Bulk-Only; quirks = 0x0000
umass0:0:0:-1: Attached to scbus0
ugen4.2: <D-88n> at usbus4 (disconnected)
umass0: at uhub4, port 1, addr 2 (disconnected)
usb_alloc_device: Found possible auto-install disk (trying next config)
ugen7.2: <HSPADataCard> at usbus7
umass0: <HSPADataCard  > on usbus7
umass0:  SCSI over Bulk-Only; quirks = 0x0000
umass0:0:0:-1: Attached to scbus0
(probe0:umass-sim0:0:0:0): TEST UNIT READY. CDB: 0 0 0 0 0 0
(probe0:umass-sim0:0:0:0): CAM status: SCSI Status Error
(probe0:umass-sim0:0:0:0): SCSI status: Check Condition
(probe0:umass-sim0:0:0:0): SCSI sense: UNIT ATTENTION asc:28,0 (Not ready to ready change, medium may have changed)
cd0 at umass-sim0 bus 0 scbus0 target 0 lun 0
cd0: <HSPAData CD-ROM 0000> Removable CD-ROM SCSI-0 device
cd0: 40.000MB/s transfers
cd0: cd present [8982 x 2048 byte records]
(probe0:umass-sim0:0:0:1): TEST UNIT READY. CDB: 0 20 0 0 0 0
(probe0:umass-sim0:0:0:1): CAM status: SCSI Status Error
(probe0:umass-sim0:0:0:1): SCSI status: Check Condition
(probe0:umass-sim0:0:0:1): SCSI sense: NOT READY asc:3a,0 (Medium not present)
da0 at umass-sim0 bus 0 scbus0 target 0 lun 1
da0: <HSPAData SD Card 0000> Removable Direct Access SCSI-0 device
da0: 40.000MB/s transfers
da0: Attempt to query device size failed: NOT READY, Medium not present

2. Load umodem kernel module to recognize the modem in the device, no usb_modeswitch (or its equivalent) required:

chateau.d.if!abbe:~ % sudo kldload umodem
Password:
chateau.d.if!abbe:~ % dmesg|tail -4
umodem0: <HSPADataCard USB Modem1> on usbus7
umodem0: data interface 2, has CM over data, has break
umodem1: <HSPADataCard USB Modem2> on usbus7
umodem1: data interface 4, has CM over data, has break

3. Add following lines ppp.conf for dialing, in my case for prepaid connection (APN: gprsppsdel):

mtnl:
        set device /dev/cuaU0  # USB modem device node created after loading umodem
        set speed 460800
        set phone "*99#"
        set authname mtnl
        set authkey mtnl123
        accept PAP
        accept CHAP
        set dial "ABORT BUSY ABORT NO\\sCARRIER \
         \"\" AT OK-AT-OK \
         ATEQV1 OK \
         AT+CFUN=6 OK \
         AT+CGDCONT=1,\\\"ip\\\",\\\"gprsppsdel\\\" OK \\dATDT\\T CONNECT"
        set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.255 0.0.0.0
        add default HISADDR
        disable dns
        disable ipv6cp
        disable mppe
        enable lqr

4. Start dialer:

chateau.d.if!abbe:~ % sudo ppp -ddial mtnl
Working in ddial mode
Using interface: tun0

(wait for 5-10 seconds)

chateau.d.if!abbe:~ % ifconfig tun0
tun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1500
        options=80000<LINKSTATE>
        inet 59.179.150.204 --> 10.0.0.2 netmask 0xffffffff
        Opened by PID 12379
chateau.d.if!abbe:~ % curl http://checkip.dyndns.org/
<html><head><title>Current IP Check</title></head><body>Current IP Address: 59.179.150.204</body></html>

I’m planning to use it with mpd5, will post the instructions when I’m done setting it up.