.17hmr is great, but I like .223 the best. I have a Marlin 30-30 336 lever action, probably the best gun ever, big enough to knock down anything in the country, but easy to handle and cheap gun/ammo setup.
On the home defense issue, a 12 gauge would be great if you can handle or have shot a 12 gauge. They are huge loads and have a lot of recoil. You would be better off with a 20 or 28 gauge. Living in the country, a rifle would be fine for HD, buckshot has a much higher chance of hitting an intruder.
HD strategy should be based on staying alive, not on killing the intruder: Get your gun, go to secured room, sit in corner and if a threat presents itself, then you fire. Anyone can go on and on about this and probably will, especially on here. It comes down to you getting a gun, be it rifle/shotgun/handgun, that fits you the best and that you are comfortable shooting and handling.
For fun I would suggest getting a Ruger 10/22 or any used .22LR. You can get 1000 rounds of ammo for less than $30 and they are fun to shoot all day.
For hunting any small on the cheap, pick up a bolt action .223. You can find them all day for less than $300.
Zombie scenario: .223 AR15, 10 30 round mags, tons of ammo, sidearm, 12 gauge semi (google saiga 12)
Just have fun, be safe, and get what fits you and your needs the best.