At some point, you will have to defend your territory. If you're a Major Faction, that's just a part of life. At some point, someone is going to try to wreck your stuff, and you're just going to have to deal with it.
With that in mind, you would think more factions would rely on fixed fortifications to defend their territory, but this hasn't really become a trend. There are a number of reasons why this could be, ranging from metaknowledge abuse to the sheer difficulty in planning them, but I think that's something that should change.
All too often, invasions devolve into slugging matches where numbers matter more than strategy or tactics. And while those brawls are underway, individuals or teams of Force users have a habit of miraculously finding weak points that bring the whole thing down.
It's a damn shame too, because a good defensive installation can not only give the defenders a sorely needed leg up, it can help define the story and add clarity to the engagement for both sides. If they attackers have a clear set of objectives, it makes the story flow more smoothly, as both sides know exactly what's going on without any of the ambiguity that's plagued past invasions.
With that in mind, we're going to cover three topics: general defensive design philosophy, then build off of that to explore hasty defenses, and finally we'll move on to deliberate defenses. Since it seemed to work well with the operational planning lecture, I'll use spoiler tags to keep from bombarding you all with walls of text, because this is going to be a long one.
General Defensive Design Philosophy:
In general, there are two types of defensive position: hasty and deliberate.
Hasty defenses are those built in the spur of the moment. The enemy is at your doorstep, and you don't have time to construct an elaborate fortress. Instead, you've got to make do with what you can build before they arrive to try and kill you to death.
Deliberate defenses are constructed well before the attack. You've got the time and presumably the resources to create the most formidable defense possible, so you carefully plan and build the best installation you can.
Both approaches have clear advantages and disadvantages, which we'll go over later, but they share a number of traits in common, and there are several things to keep in mind when constructing both.
Terrain: The land around you can be your greatest friend or your worst enemy, all depending on how you use it. When analyzing the terrain, remember the acronym OCOKA:
  • Observation and Fields of Fire- How well you can see what's going on around you, and how well you can shoot it. Ideally, you'll be able to observe everything clearly, and you'll have clear fields of fire all the way out to the effective range of your weapons. Take special note of locations where engagements are likely to occur and make special preparations to ensure your guests have a warm reception.
  • Cover and Concealment- Cover is anything that can protect you from incoming fire. This can include manmade structures, natural rock formations and caves, trenches and ravines, and so on. Concealment is anything that can hide you from sight. Cover can be used for concealment, but concealment isn't necessarily bulletproof. A bush might keep you from being spotted, but it won't protect you if you are. Keep that in mind.
  • Obstacles (man made and natural)- Anything, whether natural or otherwise, that might impede movement. The best sorts of obstacles are the ones that'll slow an approaching enemy down without giving them access to cover or concealment. Concertina wire is your best friend here.
  • Key or Decisive Terrain- Anything that, if controlled, will give one side or another a decisive advantage. High buildings, hills, bridges, river crossings, etc. You want to make a special effort to own anything that falls into this category.
  • Avenues of Approach- Any route, be it air or ground, that would form a natural path for attacking troops. Identifying key avenues of approach is your number one priority when siting weapons, as you'll want to make the easiest ways to attack your position the most treacherous.
Available Forces and Resources: What you have on hand, both in terms of manpower and resources. When constructing a defense, more is not necessarily better. You want enough troops to effectively defend the location, but not so many that they get in each others' way, or so many that you can't feed them all in the event of a siege. Effectively managing the troops onhand is key to a successful defense, and even more so in a siege.
This also takes into consideration things like building material. A wooded area, for instance, can provide plenty of material for constructing a hasty defense. Logs aren't necessarily bulletproof, but timber has a variety of uses when constructing just about anything. Industrial facilities, construction equipment, all of this has to be considered. Even a hasty defense can start looking deliberate if you have access to a high volume armor plating factory.
Depth: Defense in depth is one of those terms you'll hear a lot, usually in regards to elastic defenses that are meant to slow down an enemy rather than stop them altogether. There are some situations in which this isn't appropriate, but a word of advice: if your commanding general ever demands that you not give a single inch of ground to the enemy, see to it that they commit suicide by shooting themselves in the back multiple times and from multiple angles. Forming all of your forces into a single defensive line with no depth is the height of stupidity.
You should never, even in the most desperate of circumstances, rely on a single layer of defense unless you have absolutely no other option. This applies to everything from a platoon's hasty defense of a bridge, where they might use claymores and C-wire to slow the enemy down, to an interstellar defensive plan that forces the enemy to capture multiple worlds leading to their primary objective, lest they be used as bases for attacks to their flanks and rear. Every layer of defense you add is one more thing the enemy has to deal with before they can directly engage, and doing so forces them to expend time and resources that could otherwise be used to hammer away at you.
To make a long story short, by the time the enemy makes it to your primary defensive line, they should be so battered and worn out that the idea of getting shot comes as a relief.
Resupply: Given enough time, any defensive battle can become a siege. If at all possible, you want to make sure you have enough supplies at the beginning to last for the duration of the battle, but that's not always realistic. Always try to have a means of securing more supplies as the battle goes on. Your priorities, in order, should be water if you don't have access to a clean well, ammunition, food, medical supplies, and nonessential equipment.
That might seem strange, but consider this: without water, most of your men will be incapacitated, or at best severely screwed up, within a day or two. If necessary they can conserve ammunition, but there's only so far you can make a water supply stretch before they're reduced to drinking their own piss. And if they get thirsty enough, they will. Never mind the diseases that can be spread from drinking contaminated water. Next up is ammo, because you generally need that to mount an effective defense. I mean, if you do things exactly right, you can hold a fortress against a modern army with melee weapons, but not for long. Food takes priority over medical supplies. In the event of a siege, any injury that requires more than a bandage is likely to be fatal anyway. If you can keep your walking wounded fed, you can keep them fighting. Medical supplies should primarily be things like sterile bandages, tourniquets, IVs, and antibiotics. It sucks, but the guy with his guts hanging out is no longer an effective fighter. Unless you've got a means to CASEVAC, he's not really a priority. And lastly, anything that might be handy, but isn't exactly a necessity to continue fighting. This includes comfort items.
Retreat: Any defense can be overrun, given sufficient time and the resources on behalf of the attacker. Whenever it is strategically appropriate to do so, try to have a way out. Unless you're completely encircled on all sides and you've chosen to make your stand on swamp that makes tunneling impossible, there is almost always a way to escape from whatever monstrosity you build. There will be occasions in which it is appropriate to make a last stand, in which case feel free to close yourself in tighter than a dolphin's asshole, but the majority of historical last stands are the result of someone, somewhere along the line, screwing the pooch so hard the poor doggy was rubbing its butt in ice for a week.
Just remember that any exit can be an entry with enough motivation and lubrication, so take care to make yours as unobtrusive and unattractive as possible. If at all possible, you don't want it noticed, and if it is noticed, make sure it's not a viable avenue for attack. Just remember that if you make it absolutely impossible for them to get in, you've made it impossible for you to get out.
Ideally, your retreat should be planned well in advance of the attack. Figuring out your escape route is only half the problem. If everyone just runs for their lives once they leave the position, you've set yourself up for defeat in detail. A retreat should be orderly. You need to establish a rally point for when you escape, as well as a backup or three in case the primary is unsuitable for whatever reason. In a perfect world, you'll have on call fire support to cover your retreat, and as you're making your way towards the rally point, your troops need to be prepared to slow the enemy as much as possible along the way. It make be necessary to have a rear guard whose purpose is to die fighting the enemy for as long as possible in order to ensure that the bulk of your force escapes. Try not to expend your best troops in the rearguard, but make sure they've got enough spine to stand and enough skill to make it hurt.
Also, if at all possible, destroy your defenses as thoroughly as you can manage in the time allotted. No need to leave them for the enemy to make use of. If you can't destroy them, try and place some booby traps on the way out. Place claymores and tripmines in the most convenient areas possible. Destroy or render unusable any foodstuffs you can't take with you. Dump a dead body down the well. The more you destroy, the less they can use against you in the future.
If you've got one handy, don't be afraid to use a nuke.
Hasty Defense
Hasty defenses are a common enough occurrence in maneuver warfare. If your main strength is speed and maneuverability, it just doesn't make much sense to get tied down in any one spot. Nonetheless, there are times when you'll have to make a stand. That's where a hasty defense comes into play.
The very first thing you should consider when making a hasty defense is the terrain. Using the OCOKA tool listed above, analyze what's around you and see how you can make the most of it. Try to take the most advantageous spot possible. If you've got a hilltop that you can get dug in on, that's a pretty good spot. Try to avoid canyons and ravines if at all possible. It's far too easy to get trapped with no way out, or end up taking fire from above. I mean, do what you've gotta to survive, but that's never a good idea.
Once you know where you're making your stand, do everything in your power to improve your odds. The best way to do that is to get your fighting force below ground level, via trenches or foxholes.
If you have time, a trench network can be your best friend. Even a shallow trench is better than nothing.
Trenches do several things: they provide both cover and concealment, allowing your troops to move around without being seen or shot. They make it much easier to move around supplies, such as ammunition, and to get the wounded off the front line. If you've got time to construct some sort of overhead cover, they can provide protection from indirect fire as well as direct fire. Even a simple roof made of logs covered with sandbags can protect from airburst mortars or artillery shells.
There are several ways to construct a trench. The easiest and safest is to use whatever construction equipment you have on hand. The chances of a foot patrol having heavy equipment handy are slim, but if you've got, say, an armored column, it doesn't hurt to have something that can dig a ditch.
If you've got sappers handy, explosives can be used. Take a spool of detcord and lay out the approximate dimensions of the trench. Use sandbags to tamp it down, and then set it off. While that won't actually dig a trench, it will loosen the earth, and all you have to do is scrape it out.
Manually digging a trench is backbreaking work. If all you've got are handtools, bear that in mind, because it's going to take a while, and your men are going to be exhausted by the time they're finished. If that's your only option, you might want to make do with a shallow trench network and use the dirt you dug out to construct a berm on the side facing the enemy.
Even if they have to crawl to get from point to point, so long as they can crawl without getting shot, the trenches have done their jobs. Plus, it'll make it easier to fight the enemy if you can expose as little of yourself as possible.
If you want to get dug in, but you don't have time to construct a trench system, foxholes are your next best bet. A foxhole can be anything from a shallow scrape in the ground big enough for someone to lay down in to a miniature trench that can fit a whole squad. It is far faster and easier to construct a foxhole than it is a trench system. If nothing else, you can have your unit dig in with foxholes, and then connect them with trenches if there's time.
If you don't have access to heavy equipment, the easiest way to construct a foxhole is with a cratering charge. For the sake of not ending up on any more watchlists than necessary, I'm not going to go into detail on how to do that, but if you have cratering charges, you can instantly dig out several comfortable-sized foxholes in a matter of moments. Wear hearing protection.
And, much like trenches, if you don't have access to equipment or explosives, you're back to digging. A good way to motivate your troops is to point out that the better they dig the holes, the less likely they are to get shot.
But what if you can't easily dig where you're at, or you don't have time?
Take advantage of natural cover. Boulders will generally stop a bullet. If you're in a forest, you can construct a berm out of trees. Wood isn't necessarily bulletproof, but it's a damn sight better than nothing. In the desert, sandbags can be your best friend. A single sandbag might not stop a bullet, but if it's backstopped by five or six more, you're probably okay. Any reasonable measures that can be taken to make it harder for the enemy to shoot you should at least be considered, and only discarded if impractical.
So you've got a fighting position set up. Now what?
If you've done your terrain analysis, you've already identified your best avenues of approach. Find out which ways the enemy is likely to come from, and make sure they're covered by your highest casualty producing weapons. Typically, this will be things like machine guns and grenade launchers, but if you've got a redneck who grew up shooting squirrels at a thousand meters for fun, maybe consider placing him where he can do his thing.
This is also the point where, time permitting, you worry about adding some depth.
If you have mines, use them. Trust me on this one, there is no better way to make someone stain their britches than to make them realize they've entered a minefield. If you're smart and planned ahead, you'll have plenty of them on hand. Setting up a minefield isn't easy, but this is RP, so you can probably get away with saying that you set up a minefield.
You should also have several spools of concertina wire on hand. If you're not familiar, this is concertina wire:

It comes in spools like this:

Setting it up doesn't take long at all. You basically just have to stretch it out and stake it down in a few places and you've instantly got a barrier that's a right pain in the ass to get past. It's not enough to cut through it in one spot, because of the way it's set up. Cut it at the wrong point and it just makes a godawful tangle, and there's no real good way to deal with it under fire.
If you're really mean, you can stack it several rolls high or deep, making it all but impossible to get through quickly. Even Bangalore torpedoes have trouble dealing with large quantities of the stuff, and if the enemy does cut a hole, well, you know right where they're coming. Strap a few rolls to the outside of your vehicles, maybe on the roof if it won't get away, and you've got an easy, effective way of restricting enemy movement.
If you're expecting the enemy to have armor, you should probably have some means of dealing with that. Tanks are everyone's first option. Get those bad boys hull down, so they're exposed as little as possible. Anti-tank weaponry is also useful to have on hand, whether it be missiles, mines, or one of those nifty anti-tank disruptor rifles you can buy from a few different places.
If you have time, construct obstacles that the incoming armor will have to deal with. This is a little bit more difficult when hovertanks come in play, but since everyone in Star Wars is obsessed with walkers, you can screw with them in a number of creative ways.
The standard anti-tank barrier is basically a caltrop made from three thick sections of I-beam welded together. If you've got the time and the materials, don't be afraid to use them. C-wire is perfectly capable of ruining a tank's day too, if you use enough of it. They might think they can barrel through, but all they've really done is get themselves wrapped up in the stuff, and it has a habit of getting into the tracks, the turret ring, etc. If they hit it fast enough, they can rip off protruding bits, like coaxial machine guns or the heads of anyone unlucky enough to be sticking up out of the hatch.
Natural obstacles like rivers, ravines, swamps, hell, even sufficiently thick mud can make it difficult for tanks and walkers to pass through. Slow the armor down as much as possible to give your countermeasures as much time as possible to work.
Once you've done as much as you possibly can to improve your position, all you can really do is wait for the enemy. Do not keep everyone awake and alert until an attack is imminent. Work out a sleep rotation, and try to have as many guys as possible resting at any given time when they're not fighting. If you've got a way to feed them hot chow, do so. There's no way to overestimate the good a hot meal does for a force's morale before a fight. It might not be especially good food, but a hot meal and a nap does wonders for the average grunt's constitution.
Be careful not to let boredom set in, too, as it'll kill morale just as quickly as anything else. If they're not sleeping, eating, or maintaining watch, they should be doing something productive, just so long as it doesn't wear them out and it doesn't hinder them from fighting on a moment's notice. If you're going to fight from a hasty defensive position, you'll need every advantage you can get. It's imperative that you worry about your troops' mental wellbeing as much as their physical.
Deliberate Defense
For all practical intents and purposes, a deliberate defensive position is either a fort or a line of fortifications. Though you may have to build it in a hurry, you're generally not under threat of imminent attack, or if you are, you've already got your hasty position established and you're improving it drastically.
In many ways, your deliberate position is built with the same considerations as a hasty position. You've got to consider your terrain, your avenues of approach, so on and so forth. The key difference is, you've got the time and resources to construct something far sturdier than a few trenches.
Unlike the hasty position, it's usually best to work on both the static and elastic defenses at the same time. Your elastic defense in depth will go up far quicker than your proper fortifications, so once you've got that completed, you can redirect those resources to building the fortifications.
One key preparation for a deliberate defensive position is the clearing of fields of fire. For as far out as possible, you want to clear away anything that might provide the enemy with cover and concealment. Trees, heavy bush, buildings, boulders, anything that can be cleared away, should be. The same goes for anything naturally occurring, like gullies or ravines. Make the world around your position as barren and inhospitable as possible.
If you're going to construct things like anti-tank trenches designed to slow or halt armor, make them too deep to be useful as cover. Make the sides completely vertical. Line them with concrete, so the enemy can't easily make handholds. Rim it with C-wire. If possible, pump them full of raw sewage. I was going to say something flammable, but fire can be an effective means of concealment, so maybe don't do that. But hey, you do you. Whatever you decide to do, make the idea of even climbing down into the things on the off chance that they might be used as unattractive as possible.
You want a minefield? Buddy, you make the best minefield you possibly can. Antipersonnel mines, anti-tank mines, hell, put anti-mime mines down if you want. While you're at it, use as much C-wire as you possibly can. Have regular old barbed wire stretched out in tanglefoot grids.

Tanglefoot might seem a bit old fashioned, but that stuff makes life hell for infantry, especially in the dark when they can't see it. One minute, they're running towards the next possible smidgen of cover, and the next they've tripped and fallen face first onto a bunch of spiky wire.
If the planet is known for a particularly vile form of stinging insect, do what you can to encourage it to make nests out in no man's land. Anything and everything you can do to make that approach as unpleasant as possible, you do it.
When it comes to building your actual fortification, there's something to be said for a big-ass medieval fortress, but I wouldn't recommend it. The more structure you have exposed above the ground, the more vulnerable you are overall. Build down, not up. You key areas, such as command and control, medical facilities, armories, magazines, and so on, should be build as deep as practical, and they should have as much overburden on top as possible to protect them from incoming artillery, air-dropped munitions like bunker busters, and of course, orbital turbolaser bombardment.
For your actual defensive line, you'll want bunkers and pillboxes with overlapping fields of fire. The firing slits will be weaknesses, obviously, but there are ways around that. The best way is to have remotely operated weapons. Don't have someone sitting behind each machine gun, have them sitting behind a console hardwired to control the machine gun, far enough back that in the unlikely event their position is silenced, they won't so much as have a scratch on them.
Ideally, every inch of the area leading up to your primary defensive line should be targeted by no less than three high casualty producing weapons, with enough ammunition to fire from now til judgment day. Meanwhile, your regular infantry can fire out of firing slits all along the outside of your fortification. The slits should be just wide enough to stick a muzzle through, preferably one with a camera on the end so they can see where they're aiming without exposing themselves to fire. They should not be wide enough to permit grenades to enter.
The walls should be thick enough to provide protection from everything short of a direct hit from a turbolaser, and the slits should have blast shutters that can be closed and locked from the inside if it looks like the enemy is somehow going to get close enough to the wall to stick his own gun through.
If it's feasible to do so, you should have an artillery or mortar pit, preferably several, inside the defensive perimeter. They should be dug in, so as not to expose themselves to direct fire, and they should be able to range every inch of no man's land with ease. They'll be your best defense against a mass charge designed to overwhelm the defenses, or against enemy armor if you've got smart munitions on standby.
It's also essential that you incorporate a robust antiaircraft grid. It might not be feasible to include the sorts of guns that can take out a Star Destroyer from orbit, but if you've got it, flaunt it. In the meantime, your biggest threat will be fighters and bombers flying low to the ground in the hopes of dodging incoming fire. Do your best to teach them the folly of their ways by making sure your anti-aircraft guns can track low, fast moving craft, and can depress far enough to hit something flying so low, it's scraping the paint off the belly. Oh, and make sure they have overlapping fields of fire, too.
Of course, they'll be pretty vulnerable if you position them to do that, and you're still vulnerable to orbital bombardment, but that's what the shield is for.
What, you didn't think we'd get to that point? Oh, buddy, have I got news for you: if you've got a facility this size, and you've got enough power to provide for everything, you need a shield. At least one. Preferably more. You want enough juice to protect from a Base Delta Zero from the entire Imperial Fleet at the heart of Palpatine's Empire, if you can swing it.
But what about comms, you ask? What if the enemy tries to jam them?
Hardwire that stuff, yo. There's absolutely no reason why you can't have hardlines going to every important location within your base. Go analog too, and use an old fashioned switchboard. It can't be easily jammed, and it's damned difficult to slice.
Now, you're probably thinking at this point that this ideal fortification is a monster on a scale that would rival most cities.
Nope.
This is for a company-sized element.
If you've got the resources of an interplanetary government behind you, there's absolutely no reason why you couldn't construct a base like this for a single company. Sure, it would probably be a massive pain in the ass to do it for every company that you decide needs to defend a hill, but most of the actual structure can be made from prefab and installed in the span of a few days by a team of skilled engineers.
Now granted, multiple layers of shielding and cannon that can shoot down Star Destroyers are impractical, but everything else? You've got the GDP of entire star systems funding your war machine. There is absolutely no reason your troops should have to slum it in some World War 1 crap if they don't have to. There's literally nothing that stops you from doing this aside from lack of imagination.
Of course, you can easily scale this up as large as you need to, but past a certain size, you'll want to worry about a wastewater recycling plant, sewage system, maybe some hydroponics for growing food if you expect to be there for a while, and other things you would consider vital for something the size of a large city.
It could be argued that this sort of thing is inherently unfair in an RP environment. After all, there's always some give and take, right?
True, balance has to be considered. But if you'll recall what I said earlier, any defensive position can be overrun given appropriate time and resources. A facility like this can be overrun. The troops inside can be pinned down while the enemy goes off to accomplish other objectives. There are dozens of ways to overcome an obstacle like this.
A thorough defensive position is not inherently unfair, as long as both sides are willing to work together to ensure the best story possible. As an attacker, you've got to use your brain a bit more than you would if you were going up against walls of numbers, but the challenge is one to be relished, not cursed. As a defender, you've got to be willing to take damage fairly.
If both sides are willing to work together, I can almost guarantee that a setup like this will be a lot more fun for all involved than the usual slugging match.
That's it for today, folks. I know this was a long one, and I'm fairly certain I've missed some stuff, because this is the sort of topic one could write a PhD thesis on. But hopefully, you'll walk away with some useful information and a new appreciation for the utility of defensive positions. As always, the comments section is open, but don't be an ass.