Wednesday, 25 January 2012

CUPS + HL-2140 (USB printer) + WZR-HP-G300NH + OpenWRT

Why running CUPS on the router?

I've had a small home server running Ubuntu to server the whole house, but it seems I'm the only one using it fully. I had my Brother HL-2140 connected to the server but since I've some spare room left in the router, why not run the print server on the router?

But why CUPS?

The other option I've is running non-spooling server, p910nd, but I believe I should make full use of the free space/memory on the router. If the router overloaded, I'll consider using p910nd later on.

What needs to be done to get CUPS running?

You need a capable router, WZR-HP-G300NH is one. It has 32MB flash ROM and 64MB RAM. I'm currently running OpenWrt Backfire 10.03.1-RC6 on it.

To install CUPS, just use LUCI to install the cups package.

How about getting the HL-2140 USB printer to work along?

There is nothing special, cups seems to have supported USB printer, so we shouldn't need to install the kmod-usb-printer package. It seems that the CUP's backend needs libusb, so, please install the libusb package.

just install the kmod-usb-printer package from LUCI, this will also install all the required packages such as kmod-usb-core, kmod-usb-ohci and kmod-usb2. If everything working, you'll see the following messages from dmesg or system log:

usblp0: USB Bidirectional printer dev 9 if 0 alt 0 proto 2 vid 0x04F9 pid 0x0033
usbcore: registered new interface driver usblp


There should be new device available: /dev/lp0


If everything works, you'll see your printer when you issue the following command:
root@OpenWrt:/mnt/share# /usr/lib/cups/backend/usb
DEBUG: list_devices
DEBUG: usb_find_busses=1
DEBUG: usb_find_devices=5
direct usb://Brother/HL-2140%20series?serial=F9J555425 "Brother HL-2140 series" "Brother HL-2140 series" "MFG:Brother;CMD:PJL,HBP;MDL:HL-2140 series;CLS:PRINTER;" ""



That is it?

Not so fast young man, there are few more things need to be done especially spooling. Since we've pretty much limited space, adding external USB storage is recommended. I've few USB sticks that I don't really use. So, I got myself a 4-port hub. Stick the 4GB USB stick, format it with ext4 and mount it. To get the USB storage working, I've installed kmod-usb-storage (I believe this will install few other packages too), kmod-fs-ext4 and e2fsprogs (to prepare the USB stick). Format the stick and mount it to /mnt/share and using LUCI, configure to make this mounted during bootup time.

The standard configuration file for CUPS has the USB pointing to /dev/usb/lp0 but OpenWRT has instead created /dev/lp0. So, edit /etc/cups/printers.conf and change that. Otherwise CUPS won't find the USB printer.

Here is my /etc/cups/cupsd.conf configuration file:
AccessLog syslog
ErrorLog syslog
LogLevel info
PageLog syslog
PreserveJobHistory No
PreserveJobFiles No
AutoPurgeJobs Yes
MaxJobs 25
MaxPrinterHistory 10
User root
Group root
RIPCache 512k
TempDir /mnt/share/cups
RequestRoot /mnt/share/cups
# Allow remote access
Port 631
Listen /var/run/cups/cups.sock
HostNameLookups Off
KeepAlive On
# Share local printers on the local network.
Browsing On
BrowseOrder allow,deny
BrowseRemoteProtocols
BrowseAddress @LOCAL
BrowseLocalProtocols CUPS
BrowseProtocols cups
< Location />
# Allow shared printing and remote administration...
Order allow,deny
Allow all
< /Location>
< Location /admin>
AuthType Basic
AuthClass System
# Allow remote administration...
Order allow,deny
Allow all
< /Location>
< Location /admin/conf>
AuthType Default
Require user @SYSTEM
# Allow remote access to the configuration files...
Order allow,deny
Allow all
< /Location>


NOTE: The code above won't allow me to have '< >' so, I put a space after the '<' .. So, edit and remove the space if you want to cut and paste my configuration. Yes, I'm allowing everyone to get access to CUPS configuration interface. You're free to edit it for sure. To add the printer, just go to http://your-router-ip-address:631 Go to administration, add printer, select the AppSocket/HP JetDirect option. Remember the output from /usr/lib/cups/backend/usb? Use the URI there and paste it into the "Connection" field. Example, for my printer, the URI returned by the backend command is: usb://Brother/HL-2140%20series?serial=F9J555425

Cut and paste the above into "Connection" field.

Somehow, we're not allowed by cups to have both User and Group to be the same, so to force the the backend to run as root, change the permission for /usr/lib/cups/backend/usb to 700.

Make sure cupsd running, so, fire it up in LUCI under System -> Startup, enable it and click start.

What else need to be done?

I had a problem when trying to print from my Mac, I'm getting an authentication error. Checking the syslog, there is this error: "Returning IPP client-error-not-authorized for Print-Job" and from my Mac, I'm getting "Authentication Required to Print" error. I didn't realised that I did not click on the "Share" option for the printer. So, if you're getting this error.. check if the printer has "Share This Printer" option ticked.

That is all .. have fun to get your printer + CUPS running on your router.

Thanks for the Openwrt wiki, somehow, my previous setup was working great until suddenly it won't print anything after I upgraded my router to the latest 10.03.01 backfire. So, please check for updated guide here:

http://wiki.openwrt.org/doc/howto/cups.server.

Sunday, 10 July 2011

Getting astrill vpn to work with OpenWRT (the hard way)!

I've just subscribed to Astrill vpn service with a thought that they've openwrt scripting works as per the old twitter post that saying they're working on it. But to my dismay, they still doesn't have one that work. I created a support ticket as suggested by a twitter reply from Astrill support but it came back saying that they only support DD-WRT, so, no openwrt, fonera or tomato support at the moment.

The reason why I'm sticking with OpenWRT on my WZR-HP-G300NH router is, I've got the VLAN port & tagging to work on this router with the latest OpenWRT trunk. And reading many DD-WRT related notes, they still couldn't get the VLAN port/tagging to work on the router, hence, I'm stuck.

So, what did I do today? Searching for more information on the net on how to get the openvpn client to work on OpenWRT. If you know the way, surely, it is not hard.. but it took me few hours to figure out what I need to get this thing working.

So, what you need to get astrillvpn working on your openwrt router (in my case the WZR-HP-G300NH)?

  1. Get the latest trunk release of OpenWRT (or probably this will work with the official release firmware too). 
  2. Install OpenVPN support, there is LUCI interface for OpenVPN configuration (at least on trunk release it has it).
  3. Download the Astrill's openvpn certificates from the member page. It should be under Servers -> OpenVPN Certificate generator.
  4. Unzip the certificates file, there will be load of them. If you're interested to use the Los Angeles server, there are five of them, choose one. There are 4 sections that will be of our interest from this configuration file. The OpenVPN and the 3 certificates.
  5. Copy and paste the certificates and copied them into /etc/openvpn directory of your router. I created three standard files as per the example I found in the /etc/config/openvpn, they are:
    • /etc/openvpn/ca.crt (copy the content from Astrill openvpn file, anything between the ca and /ca.
    • /etc/openvpn/client.crt (anything between the cert and /cert)
    • /etc/openvpn/client.key (anything between the key and /key)
  6. Done with the certificate, now, we need to configure the openvpn. Easiest is to edit it manually, here is the example I've:

    config 'openvpn' 'astrill_west_cost'
    option 'client' '1'
    option 'dev' 'tun'
    option 'proto' 'udp'
    option 'resolv_retry' 'infinite'
    option 'nobind' '1'
    option 'persist_key' '1'
    option 'persist_tun' '1'
    option 'comp_lzo' '1'
    option 'verb' '3'
    option 'enable' '1'
    option 'ca' '/etc/openvpn/ca.crt'
    option 'cert' '/etc/openvpn/client.crt'
    option 'key' '/etc/openvpn/client.key'
    option 'remote' 'XX.XX.XX.XX 8292'

    Replace the remote with the correct vpn server IP address and save the file.

  7. I've no idea if this is required, but during my first hour of testing, I could use ping to ping out outside IP/sitename but I couldn't use my browser to browse anything. So, I've added the following into my /etc/firewall.user. To tell you the truth, I've copied this from somewhere. I know nut about firewall & iptable etc. I'm not good at all these, at all.
    iptables -I FORWARD -o tun+ -j ACCEPT
    iptables -t nat -I POSTROUTING -o tun+ -j MASQUERADE

  8. Go to your LUCI interface. You'll find your configuration shown as the following:


  9. Click on the Start to start your vpn connection, and Stop to stop it. 
I believe that should be all about it on how to get Astrill's openvpn to work with OpenWRT. Good luck!

Thursday, 19 May 2011

TM/Unifi - Replacing DIR-615 for good

Finally, managed to remove MicroTik Routeboard RB250G from my setup. The old WZR-HP-G300NH router finally get the much needed firmware upgrade to the latest OpenWRT Attitude Adjustment (r26915) bleeding edge release few days ago.  Someone has managed to get his DIR-825 working here and found that DIR-825 uses the same switch as WZR-HP-G300NH. I managed to add the VLAN tagging and VLAN port assignment manually using the same configuration, this was with the older RC release of OpenWRT that I've flashed many moons back.

I've no idea if this will work for other non-Atheros chip, but if you've a wireless router with the Atheros chip, feel free to get into the bleeding edge. Installation was surely not a straight forward, the trunk/bleeding edge releases are usually without Luci (GUI) preinstalled. You've two choices, one is to download the system upgradable release (sysupgrade) and flash your router from the web interface. All you configuration files will be intact if you go by this route, this includes the WAN and LAN interfaces. What you need to do is just to install Luci from opkg. But for those who're 'stupid' enough to go the hard way (as I've chosen to do), you need to download the packages upfront into your local server and point the opkg configuration to retrive the packages from your local server instead.

How to get Unifi working? Well, in the new Luci interface (yes, the Luci interface is much nicer too compared to the stable release), there is a Switch tab under the Network configuration page. This is where you configure the VLAN tagging and VLAN to port assignment.

Here is the sample of the page (yup, this is not mine.. someone has done this before, why reinvent the wheel :)..


From the above screenshot, your IPTV should be connected to the first port while the rest of the ports are free to be used as normal. Have fun flashing and configuring your router and good luck.

Note: I'm not taking any credit on this .. all thanks to the guy who posted this in lowyat forum as per the link above.

Monday, 14 February 2011

SAP/ABAP - external debugging/breakpoint gone haywire

Have you come across an external debugging gone haywire? You tried so many times trying to put in a external breakpoints but your BSP code never stop at your breakpoints? Somehow, I've experienced this too many times while debugging my BSP codes and found that the external debugging table gone haywire .. searching OSS note found a note with a way to remove these haywire breakpoints .. run RSBREAKPOINTS and remove whatever you've there. This should solve your problem..

Friday, 11 February 2011

Micro Four Thirds Camera - Lumix DMC-GF1

Nothing much happening in my ham world, so a bit bored and trying to find something interesting to play with. That is why I ventured out looking for something new. I've been looking for a replacement P&S camera since my Sony DSC-P200 was 'nicked' by my daughter :) I was interested on m43 camera but I didn't decide on what to get until last week. For some reason, I didn't consider OLY-PL1 at all but I was eyeing for Sony NEX-5 instead. Not until last few days when I narrowed down my selection to either Lumix DMC-GF1 or GF2. This time, I wasn't interested on the dual lenses package but narrowed it down to only the 20mm pancake lens.  I will get a zoom lens if needed but not for now, there are quite number of options if I want to go for zoom lens, more and more lens manufacturers are coming out with m43 lenses.. so .. until then, I believe the 20mm pancake lens is good enough for me. Well, only GF1 comes with a 20mm lens, so, I went ahead and got myself a GF1. I've read quite a lot of reviews on both GF1 and GF2, both have pros and cons and GF2 is just available for few hundreds MYR more than the GF1, actually MYR200 more for a new GF2 with 14mm pancake lens package.



The first thing when I got it, I couldn't believe that it is huge.. compared to my previous DSC-P200 and Nikon CoolPix 885 that I had before the Sony. And it is quite heavy too but it is well built. I don't think I regret of going for GF1 at all.

This is my first time using a fixed focal length lens on P&S and I need to get used to it first.. did my first photo shoot this morning and my son became the model .. :) Not satisfy with the outcome but I guess need to learn more stuff and get to know all the features that the GF1 could give. Some nice features there .. and some photo techniques I need to learn this time. No more P&S this time .. hope I can really make use of it and my daughter won't nick it this time.. she was drooling on it when she saw it last year .. :)

Monday, 17 January 2011

Working in APRS packet mode with ISS

I'm just into this, working in APRS packet mode with ISS. Many of my friends who actively involved with APRS have worked with ISS before but for some reason, I've left behind. Not until few days ago when finally, my beacon is heard, repeated and s-gated from ISS to satellite APRS gateway and finally showed up in ariss.net. My setup won't allow me to communicate with ISS BBS system nor messaging since I'm 'misusing' aprx (meant to be as internet gateway for APRS) to send the beacons. I'm still looking for a terminal based software which can run on Linux to experiment further with the BBS and what nots.

Anyway, thanks to many of my friends, now I know that I could track the ISS using SatScape (Java) that could be run from any operating system (I'm running Mac OSX Leopard). And now I learnt that using WIDE1-1, WIDE2-1 while working with ISS is not advisable. Bob has suggested that we should use ARISS, APRSAT or WIDE as per his FAQ found here.

Here is the first time my callsign appeared in ariss.net:

Sunday, 9 January 2011

Happy new year..

Probably a belated one, 2011 is already on the 9th day today. Nothing much interesting happening I guess since last October since I didn't post anything. Anyway, listed are the latest things (happening or in my hands :).


  • I've bought a Kenwood TM-D710A, replacing my TM-V71A/OT2/Nuvi350 setup in my pickup. 
  • TM-V71A is now my main 2m/70cm radio in my shack, I wasn't able to monitor or transmit on 2m/70cm bands for quite a while. I had the FT60R connected to the only base antenna that I've installed and it was connected to a TT4/APRS and acted as fill-in digipeater and TNC interface to my igate. The shack setup is now has TM-V71A, band B as data and band A is free for me to monitor any local conversation on the repeaters or simplex channels while not missing any data coming into the other band.
  • FT-60R is now temporarily retired until I can find a new task for it. Few of us were talking about satellites communication, probably now the right time to go forward with it. Found lot of hams are using FT-60R for it. Now, the raw materials are readily available.. need to find the 'urge' to start working on it :)
  • In the CarPC world, I've 'upgraded' my CarPC setup, it is running on solid state drive (SSD) now, after I had a harddrive failure, I believe upgrading to SSD is necessary. I'm trying to migrate the frontend from Centrafuse to RideRunner since RR has nicer support for my HDR (HD Radio).
  • Work-wise, I'm still stuck doing SAP development. But then again, I'm not going to venture out doing something else. I will eat, sleep, walk & program .. ABAP :) Office is busy doing an upgrade exercise, they're going to upgrade both the CRM & R/3 to the latest packages and I believe I'll be the last in the chain as usual :) Nothing unusual though .. 
Related Posts with Thumbnails