Monday, October 21, 2013

The case of the finicky firewall

I'm using openSUSE 12.3 and have a Windows XP session running in a VirtualBox. I've returned to my home network from a trip and now I can't use the printer.

dmesg reveals a series of drops of the printer (192.168.5.5) trying to reach the virtual machine guest (192.168.5.24).

 [ 8207.414111] SFW2-FWDint-DROP-DEFLT IN=wlan0 OUT=wlan0 MAC=e0:2a:82:e1:d5:21:00:22:64:3b:99:99:08:00 SRC=192.168.5.5 DST=192.168.5.24 LEN=425 TOS=0x00 PREC=0x00 TTL=63 ID=3204 PROTO=UDP SPT=427 DPT=427 LEN=405

So fire up yast2 firewall. I then:

• Ensured the WiFi adapter is in the Internal zone

• Explicitly added 192.168.5.0/24 (both TCP and UDP) to the Internal zone

• Explicitly adding TCP/UDP port 427 as both SPT and DPT

• Explicitly allow the printer, VM guest, source port (SPT) and destination port (DPT) as custom rules.

Nope, no change despite being told explicitly to allow these things. Twilight zone...


OK, try shutting down the VM.

OK! This stops the drops from happening. So the problem is with the VB, not the firewall.

     https://forums.virtualbox.org/viewtopic.php?f=6&t=43072

suggests that bridging is the issue. It states the problem should not exist but occasionally arises. This affirms my twilight zone observation...

OK, we check VirtualBox and indeed, wlan0 is bridged. So we change it to Natural Address Translation (NAT) and restart. And, indeed, the drops have now stopped.

So it would appear that the firewall looks not only at IP addresses and ports but also at MAC addresses, and if they don't all match correctly then the packet is dropped. VirtualBox does indeed modulate the guest MAC address under bridging. Changing back to NAT resolved the issue.

The disadvantage of NAT mode is that, much like a private network behind a router, the virtual machine is invisible and unreachable from the outside internet. Similarly, neither the host nor any other machine on the local network can see into the VM guest. The VM guest (now 10.0.2.15) is on a completely separate network from the host and the LAN.

But now it's working so we'll leave it NAT until we find a reason to work harder...

So now back to trying to fix the printer...

Friday, October 18, 2013

GnuCash: Macros?

I love GnuCash. GnuCash is the best.

But it could be better.

BLUF: we need a macro facility. Something to do simple manipulations. No invoking international or GAAP. Just a way of automating simple repetitive tasks.

For example:

http://list-archives.org/2012/10/12/gnucash-user-gnucash-org/buildin-currency-exchange/f/6417193929

How can I enter a transaction in a foreign currency and have it converted
automatically to my home currency?

For example, in a USD account (e.g., {Visa-USD}) enter a GBP amount (e.g. GBP 83.22) and have it converted to USD with the current rate recorded in the Price Editor?

The price editor correctly updates exchange rates, so I believe I have the
necessary modules installed, but entering "GBP 83.22" or a host of other
variants returns an error. I am relatively certain that I remember being
able to do that in the past, but perhaps I'm disremembering Quicken... :-(


Well, I never got a reply, except that it is hard to do.

OK, said the little red hen, I'll do it myself. So I did. Easy when you know how.

All you have to do is:

1. Go to a foreign currency account, e.g., {Cash-GBP}, that is denominated in the foreign currency, e.g.,GBP.

2. Enter all your splits in GBP: {Food}, {Supplies}, {Drinks}, etc.

3. Multiply all your splits by 1.01 (insert *1.01 at the end of each split value and move to the next split) to accommodate the "Foreign Transaction Fee" that the bank will charge you.

4. If it is an ATM transaction add a split for your {Financial Misc} account with the value of the inverse of the exchange rate (e.g., £0.60) as a placeholder for the one dollar ATM fee the bank will charge.

5. After everything is set correctly, change the {Cash-GBP} split account to {Checking-NFCU} (or whatever your home currency (e.g., USD) checking or credit card account is called) and arrow down to the next split line.

     a. This will invoke a currency exchange dialog box to update the exchange rate. When you click OK and accept the transaction it will disappear from {Cash-GBP}  and move to the {Checking-NFCU} account.

6. Go to {Checking-NFCU} to check the result.

Easy when you know how...

=====

Now, when it comes to balancing the checkbook, things are only a little more complicated. The process above will give you pretty close ballpark numbers in your home-denominated account, but time delays may result in a few pennies' worth of exchange rate differences.

That is where the macros would really come into use, since you probably want to redistribute those pennies to the various splits if you are really a nut for detail. (Otherwise, just chuck them into {Financial Misc} and be done.)

But no macros. So what to do?

I then wield the faithful calculator, an HP-35s in my case.  A tutorial on Reverse Polish Notation (RPN) is beyond the scope of this article but easily available with the link and this manual:
http://h10010.www1.hp.com/wwpc/pscmisc/vac/us/product_pdfs/user_guide.pdf

I use two routines:

     • LBL I uses the Imbalance to calculate the Original transaction amount and save the current transaction Total (the transaction amount reported by the bank).

     • LBL D then calculates the ratio of the original split to the Original total and multiplies it by the current total to give the redistribution value.

Open the transaction and change the checking account value to what the bank has reported and arrow down (don't press Enter or you will get an imbalance split). This will result in an undesignated imbalance. Now with the calculator:

LBL I

<Imbalance>
ENTER
<Bank transaction amount>
XEQ I

This stores the current bank Total in register T, returns the Original total, and stores it in register O:

        I001  LBL I       
            I002  STO T    Save the current Total
            I003  x<>y      Flip the values
            I004  -            Get the Original total
            I005  STO O    Store the Original total
        I006  RTN

LBL D


<Split value>
XEQ D

This saves the split Value in register V, divides it by the Original total to get the ratio, recalls the current Total and multiplies it by the ratio to return the reproportioned Distribution amount and save it in register D:

        D001 LBL D       
            D002  STO V    Save the Value
            D003  RCL O    Recall the original total
            D004  ÷            Divide to get this item's percentage of total
            D005  RCL T    Recall the new total
            D006  x            Multiply to get the new proportional value
            D007  STO D    Save the Distribution
        D008  RTN       

Yes, it was fun figuring all this out, but how much nicer it would be to just click a button...

Monday, October 14, 2013

Days of Yore



My grandfather's brass vernier scale sextant (circa 1910, no micrometer drum).

My aunt wanted to make it into a lamp. My cousin complained loudly, demanding that she pass it on to me, a Naval officer.

Aunt Lucy surrendered and sent it to me.

It was in rather sad shape, but I cleaned, calibrated, polished, and repainted it and refurbished its lovely walnut case.

So it sits in grandeur on my side table and I do occasionally take it out and take a sight. It  works, just fine.

But sight reduction is a pain, even with software. GPS is a lot easier.

Beside it is a replacement for my Keuffel & Esser Log Log Duplex Decitrig slide rule.
 

The original was given to me in high school by Mr. (Stempel?), a next door neighbor who was an electrical engineer and had a beautiful daughter. I don't know whether he was mentoring me to be an engineer or grooming me for his daughter. The first won and off we went to Duke Engineering School.

But  a really cool guy. Thank you again, sir.

Absolute magic, except I could never keep the decimal point straight.

That problem was solved with my first calculator, the HP-35:

Truly magic.

I was convinced that little green spacemen had sprinkled magic microchips under the polka-dotted mushrooms of Monterey county that were being harvested and put into a box by Hewlett Packard.

As I said, I was having problems with decimal points. There was a Brazilian officer in my class who was kind. So one day I just asked him.

"Look: I'm as smart as you, but you're getting A's and I'm getting C's. What am I doing wrong?"

He said, "I've been watching you. Basically you are totally disorganized. Here: you need one of these:"
and he pulled a six-inch C-Thru ruler out of his shirt pocket and handed it to me.
"You need to organize your writing, draw boxes around your answers, using this ruler, and get a calculator, like this one." and held up his HP-35.
Probably the best advice I have ever been given.
So after class I jumped into the car, dashed off to HP's office in Cupertino.
I came sliding into the parking lot at about 1645, before their 1700 closing.
Dashed into the office, slapped down the VISA and said, "Please, get me one."
So she did, I got back in the car, and headed back to Monterey. I can still remember the smell. Wonderful.
Then I hit the freeway.
Bumper to bumper through San Jose and beyond.

OK, make lemonade. RTFM
By the time I cleared the San Jose traffic we were into eucalyptus trees and the red barn flea market (where I later bought my first O-scope) and I had read the manual cover to cover.

And indeed, it worked. I got a "most improved" award on graduation. Not too hard, since my Duke BA got me a 2.11 and Monterey got me a 3.72...

I now carry around a modern HP-35s.

And still carry the C-Thru, an engineer's pencil, its separate eraser, and have a pad of green grid paper on the shelf under the coffee table.
Just in case.

More as an act of faith and of following the engineer's Articles of Religion than for any practical utility. They just make me feel good, like a reel injuneer.

Maybe I should go after eBay and see if I can find another of the reel thang  HP-35.

Happy memories.