Latest / CyberCode Academy / Course 44 - RH Security Specialist | Episode 12: Securing Linux with Nessus and IPTables
Transcript
- 0:00Speaker 1: Imagine for a second, right, that you've just spun up
- 0:02Speaker 1: a brand new Linux server.
- 0:04Speaker 2: Oh, yeah. Always a good feeling.
- 0:06Speaker 1: Right. And it's out there on the internet. Or maybe it's,
- 0:08Speaker 1: you know, just sitting quietly on your local network. But
- 0:11Speaker 1: the real question is, how do you actually know it's safe?
- 0:15Speaker 2: Exactly. That's the tricky part.
- 0:17Speaker 1: Because, I mean, you wouldn't leave the front door of
- 0:20Speaker 1: your physical house wide open for just anyone to wander in.
- 0:24Speaker 1: But in the digital world, it is incredibly hard to
- 0:27Speaker 1: even see where your open doors are. You can't just
- 0:30Speaker 1: you know, walk around the perimeter of a server and
- 0:32Speaker 1: check the locks.
- 0:33Speaker 2: Yeah, you really can't. And that invisible nature of a
- 0:36Speaker 2: digital perimeter, it creates this massive false sense of security.
- 0:40Speaker 1: Oh, totally.
- 0:40Speaker 2: Whether you are setting up a personal home lab or
- 0:44Speaker 2: managing infrastructure for a living, there's this dangerous tendency to
- 0:48Speaker 2: just assume that a default configuration is a secure configuration.
- 0:52Speaker 1: Right. Which brings us to the mission for today's deep dive.
- 0:55Speaker 1: We're going through a step-by-step masterclass on securing a server,
- 0:59Speaker 1: and we're using two foundational tools to do it.
- 1:01Speaker 2: Two very different but very important tools.
- 1:04Speaker 1: Exactly. First, we are going to actively hunt for vulnerabilities
- 1:09Speaker 1: and map out those invisible doors using Nessus. And then
- 1:13Speaker 1: once we know where we stand, we are going to
- 1:15Speaker 1: build a digital fortress around that server using IP tables.
- 1:20Speaker 2: Which is great because we're approaching this from the ground up.
- 1:22Speaker 2: I mean, security isn't just this luxury reserved for massive
- 1:25Speaker 2: corporations with endless budgets. Anyone can do this.
- 1:29Speaker 1: Yeah, absolutely.
- 1:30Speaker 2: What's fascinating here is that we are going to look
- 1:32Speaker 2: at both the offensive side of the coin with auditing
- 1:35Speaker 2: and the defensive side with firewalls. Because, you know, you
- 1:38Speaker 2: really need to understand how an attacker probes your system
- 1:41Speaker 2: to understand how to build a proper defense against them.
- 1:44Speaker 1: Okay, let's unpack this. Before we can defend a server,
- 1:46Speaker 1: we have to play detective, right? We need to find
- 1:49Speaker 1: its weaknesses.
- 1:50Speaker 2: That is where Nessus enters the chat.
- 1:52Speaker 1: It is such a wildly popular vulnerability scanner. But if
- 1:56Speaker 1: you look at their enterprise pricing, the sticker shock is
- 1:59Speaker 1: very real.
- 2:00Speaker 2: Oh, yeah. It can be intense.
- 2:02Speaker 1: Thankfully, there's a Nessus home free license. It lets you
- 2:05Speaker 1: scan up to 16 IPs, which is honestly perfect for
- 2:09Speaker 1: auditing your own home lab or personal projects.
- 2:11Speaker 2: Definitely. It's plenty for a small setup.
- 2:14Speaker 1: So let's visualize getting this running. You download the RPM package,
- 2:18Speaker 1: you run your installation command, and you start the service.
- 2:20Speaker 2: Right. You've got to remember to actually start the service.
- 2:22Speaker 1: Yeah. It's so easy to forget. You type, you know,
- 2:24Speaker 1: systems kennel start nessest.
- 2:26Speaker 2: Yeah.
- 2:26Speaker 1: The cursor blinks, drops you back to the command prompt,
- 2:29Speaker 1: and now this scanning engine is just quietly humming in
- 2:32Speaker 1: the background.
- 2:32Speaker 2: Ready to go.
- 2:33Speaker 1: But then you open your browser, you punch in the
- 2:35Speaker 1: server's local URL, and immediately your browser throws this massive,
- 2:40Speaker 1: scary red warning screen at you. Ah, yes.
- 2:43Speaker 2: Yes. The classic self-signed certificate warning.
- 2:46Speaker 1: It just screams at you that your connection is not secure.
- 2:50Speaker 1: And mechanically, I always wonder, why does the browser panic
- 2:53Speaker 1: so aggressively over a service that I just installed on
- 2:56Speaker 1: my own machine?
- 2:57Speaker 2: Well, think of it like this. Your browser is functioning
- 3:00Speaker 2: like a hyper-vigilant security guard at a highly restricted building.
- 3:03Speaker 1: Okay, I like that.
- 3:04Speaker 2: When a web server presents a certificate... The browser expects
- 3:08Speaker 2: that certificate to be mathematically vouched for by a trusted
- 3:12Speaker 2: third party, like a global certificate authority.
- 3:15Speaker 1: Right, like the big ones that are already baked into
- 3:17Speaker 1: the browser.
- 3:17Speaker 2: Exactly. The root certificates for those authorities are already in
- 3:21Speaker 2: your browser's trusted store. But because you just generated this
- 3:26Speaker 2: Nessa certificate locally-like, literally during the installation process, that cryptographic
- 3:31Speaker 2: chain of trust simply doesn't exist.
- 3:33Speaker 1: So it's like the browser is a security guard looking
- 3:36Speaker 1: at an ID badge that I printed myself in the basement. Yes.
- 3:39Speaker 2: Precisely.
- 3:40Speaker 1: The browser is just saying, I have no idea who
- 3:42Speaker 1: authorized this signature. But in this specific context, I mean,
- 3:47Speaker 1: I am my own certificate authority, right?
- 3:48Speaker 2: Basically, yeah.
- 3:49Speaker 1: I know the server is local and I know I
- 3:52Speaker 1: just installed the service. So bypassing that warning and just
- 3:55Speaker 1: adding the exception is perfectly safe here. Whereas... doing that
- 4:00Speaker 1: on an external banking site would be absolutely terrifying.
- 4:02Speaker 2: Right. Context dictates your response here. Once you bypass that warning,
- 4:06Speaker 2: you just create your credentials, input the activation code they
- 4:09Speaker 2: emailed you, and you hid a waiting period.
- 4:11Speaker 1: Because Nessus has to download all those plugins. Right.
- 4:13Speaker 2: Yeah. It has to initialize thousands of plugins before you
- 4:17Speaker 2: can actually launch a scan against your infrastructure. It takes
- 4:20Speaker 2: a minute.
- 4:21Speaker 1: I want to focus on those plugins, actually, and the
- 4:23Speaker 1: mechanics of the scan, because this aspect Always makes me
- 4:26Speaker 1: a little nervous.
- 4:27Speaker 2: How so?
- 4:28Speaker 1: Well, if I point Nessus at a live production server
- 4:31Speaker 1: and tell it to run an advanced scan, is it
- 4:33Speaker 1: throwing live weaponized exploits at my machine? Like, how does
- 4:37Speaker 1: it interrogate these services without just tipping the server over
- 4:40Speaker 1: or causing a denial of service?
- 4:42Speaker 2: Oh, that is a really vital distinction to make. Nessus
- 4:45Speaker 2: plugins are designed for safe interrogation, not exploitation.
- 4:49Speaker 1: Okay, phew.
- 4:50Speaker 2: When you initiate a scan, Nessus uses those plugins to
- 4:54Speaker 2: systematically query your open ports. It relies really heavily on
- 4:58Speaker 2: something called banner grabbing.
- 4:59Speaker 1: Banner grabbing.
- 5:00Speaker 2: Yeah, which is essentially just asking a service to identify itself.
- 5:04Speaker 2: And it also checks how a service responds to specific,
- 5:07Speaker 2: often malformed packets.
- 5:08Speaker 1: So it's more like rattling the doorknob and checking the
- 5:11Speaker 1: manufacturer of the lock rather than taking a battering ram
- 5:14Speaker 1: to the front door.
- 5:15Speaker 2: That's a great way to put it. It is probing
- 5:17Speaker 2: for information. If Nessa sees that you are running a
- 5:20Speaker 2: specific version of a web server, say one with a
- 5:23Speaker 2: known flaw, it doesn't actually try to crash the server
- 5:26Speaker 2: to prove the vulnerability exists.
- 5:28Speaker 1: Right, that'd be bad.
- 5:29Speaker 2: Very bad. Instead, it cross-references the server's broadcasted version information
- 5:34Speaker 2: against its massive internal database, the Common Vulnerabilities and Exposures database.
- 5:40Speaker 1: Ah, the CVE list.
- 5:42Speaker 2: Exactly. And then it generates a comprehensive report detailing exactly
- 5:46Speaker 2: where your architecture is exposed based on that version match.
- 5:49Speaker 1: And when you are setting up that scan, you have
- 5:53Speaker 1: the option to provide Nessus with credentials.
- 5:55Speaker 2: Yeah.
- 5:56Speaker 1: What is the mechanical difference there, like between an uncredentialed
- 5:59Speaker 1: scan and a credentialed scan?
- 6:01Speaker 2: So an uncredentialed scan only sees what an outside attacker
- 6:04Speaker 2: would see. It can only interrogate the services listening publicly
- 6:08Speaker 2: on those network ports.
- 6:09Speaker 1: The stuff exposed to the network.
- 6:10Speaker 2: Right. But a credentialed scan is where you provide Nessus
- 6:14Speaker 2: with administrative login details. So Nessus uses those credentials to
- 6:18Speaker 2: actively log into the server yourself.
- 6:20Speaker 1: Wow.
- 6:21Speaker 2: Yeah, it checks the local file system, it reads the
- 6:23Speaker 2: registry or configuration files, and it verifies patch levels directly
- 6:27Speaker 2: from the inside. It gives you a vastly more accurate
- 6:30Speaker 2: picture of your internal security posture.
- 6:32Speaker 1: That makes total sense.
- 6:33Speaker 2: Yeah.
- 6:34Speaker 1: But regardless of how you scan, we really have to
- 6:37Speaker 1: address the false positive trap.
- 6:38Speaker 2: Oh, yes. The bane of every security admin's existence.
- 6:43Speaker 1: Seriously. I run these scans. The report comes back with
- 6:46Speaker 1: a bunch of critical red alerts. And your immediate reaction
- 6:49Speaker 1: is just panic. You feel like the server is bleeding out.
- 6:52Speaker 2: It's definitely stressful the first time you see it.
- 6:54Speaker 1: But when you dig into the mechanics, how exactly does
- 6:57Speaker 1: a highly advanced scanner get it wrong? Like, why the
- 7:01Speaker 1: false alarms?
- 7:02Speaker 2: Because a scanner is essentially a giant state machine matching patterns.
- 7:06Speaker 2: It completely lacks human context. Right. A false positive occurs
- 7:10Speaker 2: when Nessus finds a pattern it recognizes as a vulnerability,
- 7:14Speaker 2: but it misinterprets a custom configuration. Or, you know, it
- 7:18Speaker 2: fails to see a mitigating control that you've put in
- 7:20Speaker 2: place on the back end.
- 7:22Speaker 1: So it's shouting, the window is open, without realizing there's
- 7:26Speaker 1: literally bulletproof glass installed behind the screen.
- 7:29Speaker 2: Yes. Tools do not replace human logic. When you read
- 7:33Speaker 2: that report, it requires critical thinking. You have to review
- 7:37Speaker 2: those findings, verify them manually in the terminal, and determine
- 7:41Speaker 2: if they are legitimate threats or just the scanner misunderstanding
- 7:44Speaker 2: your custom architecture.
- 7:46Speaker 1: Let's play out a scenario based on that report, actually. So,
- 7:49Speaker 1: Nessus finishes its scan and finds a legitimate glaring vulnerability.
- 7:54Speaker 2: Okay, a real one this time.
- 7:55Speaker 1: Yeah, a real one. It flags a legacy internal application
- 7:59Speaker 1: running on our server, and when we call the developers,
- 8:01Speaker 1: they tell us they can't patch the vulnerability for another month.
- 8:05Speaker 2: Typical.
- 8:05Speaker 1: Right. But we can't just leave that vulnerable port open
- 8:08Speaker 1: to the network for a month. How do we secure
- 8:10Speaker 1: a service we can't immediately patch? This feels like where
- 8:14Speaker 1: we shift from offense to defense.
- 8:15Speaker 2: It absolutely is. That is where you draw the line
- 8:18Speaker 2: in the sand. If you cannot patch the application, you
- 8:21Speaker 2: must restrict network access so tightly that an unauthorized packet
- 8:25Speaker 2: can never reach the vulnerable service in the first place.
- 8:28Speaker 2: And in the Linux ecosystem, the foundational tool for building
- 8:31Speaker 2: that barrier is a net filter, which we administer using
- 8:35Speaker 2: IP tables.
- 8:36Speaker 1: I really want to clarify the architecture here because those
- 8:39Speaker 1: two terms get thrown around interchangeably in a lot of
- 8:42Speaker 1: documentation and it causes a ton of confusion.
- 8:45Speaker 2: It really does. People use them like they're the exact
- 8:47Speaker 2: same thing.
- 8:48Speaker 1: Right. So what is the actual mechanical difference between NetFilter
- 8:51Speaker 1: and IP tables?
- 8:52Speaker 2: Think of it this way. NetFilter is the actual network
- 8:56Speaker 2: subsystem built directly into the Linux kernel itself.
- 8:59Speaker 1: It's in the kernel.
- 9:00Speaker 2: Yes. It operates at the absolute lowest level, utilizing a
- 9:04Speaker 2: series of hooks to intercept packets the millisecond they arrive
- 9:08Speaker 2: at the network interface. This happens long before they ever
- 9:11Speaker 2: reach your user space applications.
- 9:13Speaker 1: And IP tables?
- 9:14Speaker 2: IP tables is simply the user space utility. It's the
- 9:17Speaker 2: command line tool you use to talk to NetFilter and
- 9:20Speaker 2: dictate the rules for those kernel hooks.
- 9:22Speaker 1: So IP tables is the steering wheel, and NetFilter is
- 9:25Speaker 1: the engine actually processing the traffic.
- 9:27Speaker 2: The perfect way to look at it.
- 9:29Speaker 1: Now, let me play devil's advocate for a moment. Let's
- 9:31Speaker 1: say I'm managing a server sitting deep inside a corporate network.
- 9:35Speaker 1: The perimeter of the building is guarded by a massive,
- 9:38Speaker 1: expensive enterprise hardware firewall.
- 9:41Speaker 2: Sure.
- 9:42Speaker 1: Why should I spend time configuring IP tables on my
- 9:45Speaker 1: individual internal server when the perimeter is already locked down?
- 9:49Speaker 1: Isn't that redundant?
- 9:50Speaker 2: Well, relying solely on a perimeter firewall assumes the inside
- 9:54Speaker 2: of your network is a sterile, perfectly trusted environment.
- 9:58Speaker 1: Which it never is.
- 9:59Speaker 2: Exactly. The reality of modern security architecture requires a defense-in-depth strategy,
- 10:05Speaker 2: and that means anticipating bad actors who are already inside
- 10:09Speaker 2: the house.
- 10:09Speaker 1: You're talking about lateral movement. Like, an attacker breaches a
- 10:13Speaker 1: random workstation because an employee clicked a bad phishing link,
- 10:16Speaker 1: and suddenly that attacker is sitting right behind the expensive
- 10:18Speaker 1: perimeter firewall. Yep.
- 10:20Speaker 2: Once they are inside, if your internal servers lack their
- 10:23Speaker 2: own local firewalls, that attacker basically has free reign. They
- 10:27Speaker 2: can move laterally, probe your services, extract data, all without resistance.
- 10:33Speaker 1: That's terrifying.
- 10:34Speaker 2: But if every individual server is running its own IP
- 10:37Speaker 2: tables firewall, that attacker hits a solid brick wall at
- 10:41Speaker 2: every single turn. You severely limit their access and massively
- 10:46Speaker 2: increase the noise they have to make.
- 10:48Speaker 1: And that noise gives your intrusion detection systems the time
- 10:51Speaker 1: they need to catch them.
- 10:51Speaker 2: Exactly. You don't just lock the front door of the building.
- 10:54Speaker 2: You lock the safe inside the office, too.
- 10:57Speaker 1: Here's where it gets really interesting, though. When we look
- 10:59Speaker 1: at how IP tables handles traffic, it is capable of
- 11:03Speaker 1: both stateless and stateful packet filtering.
- 11:06Speaker 2: Yes, it can do both.
- 11:07Speaker 1: What is the fundamental difference in how the kernel processes
- 11:10Speaker 1: those two types of traffic?
- 11:11Speaker 2: It really comes down to memory and context. Stateless inspection
- 11:15Speaker 2: is incredibly rigid. It looks at every single packet of
- 11:18Speaker 2: data in total isolation.
- 11:20Speaker 1: Okay, isolation.
- 11:21Speaker 2: It examines the source IP, destination IP, port, and protocol
- 11:25Speaker 2: against your rule set. But it has absolutely zero memory
- 11:29Speaker 2: of what happened one millisecond ago.
- 11:31Speaker 1: So using a physical analogy, a stateless firewall is like
- 11:34Speaker 1: a bouncer with severe short-term memory loss.
- 11:36Speaker 2: Oh, I like this.
- 11:37Speaker 1: You walk up to the club. He demands your ID,
- 11:40Speaker 1: checks his rule book, and lets you in. Right. Then
- 11:42Speaker 1: you step out onto the sidewalk for three seconds and
- 11:45Speaker 1: take a phone call. You turn back around and he
- 11:47Speaker 1: stops you and demands your ID all over again.
- 11:50Speaker 2: Yes, exactly.
- 11:51Speaker 1: He reads the rulebook from page one every single time,
- 11:55Speaker 1: totally blind to the context that you were literally just
- 11:58Speaker 1: inside the club.
- 11:59Speaker 2: It forces the system to evaluate every single packet from scratch,
- 12:04Speaker 2: which honestly is computationally expensive if you have complex rules.
- 12:07Speaker 1: Yeah, that sounds exhausting for the CPU.
- 12:09Speaker 2: It is. A stateful firewall, however, utilizes a feature in
- 12:13Speaker 2: the kernel called connection tracking or contract.
- 12:16Speaker 1: Contract, okay.
- 12:17Speaker 2: Stateful packet inspection dynamically tracks the operating state of active
- 12:21Speaker 2: network connections. It allocates a small amount of memory to
- 12:24Speaker 2: literally remember the conversation.
- 12:26Speaker 1: Okay, so going back to our bouncer, the stateful bouncer
- 12:29Speaker 1: has a VIP list in his head. You show your
- 12:32Speaker 1: ID once and you go in. If you step outside
- 12:35Speaker 1: and try to come back, He checks his VIP list.
- 12:38Speaker 1: The connection tracking table sees you have an active established
- 12:41Speaker 1: session and just waves you right back in without the
- 12:43Speaker 1: full interrogation.
- 12:44Speaker 2: Precisely. The kernel recognizes that the packets flowing back into
- 12:48Speaker 2: your server are part of a legitimate conversation that originated
- 12:51Speaker 2: from a trusted source.
- 12:52Speaker 1: And allows them through seamlessly.
- 12:54Speaker 2: Right. It is a vastly more intelligent, fluid way to
- 12:58Speaker 2: manage security. And IP tables gives you the granular control
- 13:02Speaker 2: to build rules utilizing both methods depending on your needs.
- 13:05Speaker 1: That is so cool. Let's get into the actual mechanics
- 13:08Speaker 1: of configuring these gates, though. Because these IP tables rules
- 13:11Speaker 1: aren't just abstract concepts floating in the void. They live
- 13:14Speaker 1: in a very specific configuration file, right?
- 13:17Speaker 2: They do, specifically at X's configables.
- 13:20Speaker 1: And to visualize how the system processes this file, we
- 13:24Speaker 1: really have to talk about the serial top-to-bottom reading logic.
- 13:27Speaker 2: The top-to-bottom logic is arguably the single most critical mechanical
- 13:31Speaker 2: feature to grasp.
- 13:32Speaker 1: Why is that?
- 13:33Speaker 2: Because when a packet arrives, the kernel looks at rule
- 13:36Speaker 2: number one. If the packet matches the criteria, it applies
- 13:39Speaker 2: the action, typically accept or drop, and it stops reading instantly.
- 13:44Speaker 1: Instantly.
- 13:44Speaker 2: Instantly. It does not care what rule number 50 says
- 13:47Speaker 2: if rule number one already allowed the packet through.
- 13:50Speaker 1: Wow. Okay. This has to have massive performance implications then.
- 13:54Speaker 1: Because if the kernel evaluates rules serially, and I have,
- 13:59Speaker 1: let's say, 10,000 rules configured.
- 14:01Speaker 2: That's a lot of rules, but go on.
- 14:03Speaker 1: A packet that matches rule number 10,000 has to be
- 14:05Speaker 1: checked against 9,999 rules first. That sounds like a great
- 14:10Speaker 1: way to spike your CPU load on a high-traffic web server.
- 14:13Speaker 2: Which is exactly why rule ordering is not just about functionality.
- 14:17Speaker 2: It is a critical optimization technique. You always want your
- 14:21Speaker 2: highest volume traffic rules or your stateful established connection rules
- 14:25Speaker 2: at the very top of the list.
- 14:26Speaker 1: So they hit the accept rule immediately.
- 14:28Speaker 2: Right. That way, the kernel can accept the bulk of
- 14:31Speaker 2: the traffic right away and move on without burning precious
- 14:34Speaker 2: CPU cycles evaluating the rest of the chain.
- 14:36Speaker 1: Let's look at the bottom of the chain then. On
- 14:39Speaker 1: a typical default setup for a lab server, you might
- 14:42Speaker 1: open that text file and see that SSH port 22
- 14:46Speaker 1: is explicitly set to accept at the top. So you
- 14:49Speaker 1: can remotely manage the machine.
- 14:50Speaker 2: Essential, yeah.
- 14:51Speaker 1: But at the very bottom of the list, there is
- 14:53Speaker 1: usually this blanket reject rule.
- 14:56Speaker 2: The catch-all.
- 14:56Speaker 1: The catch-all, right.
- 14:57Speaker 2: It essentially dictates that if a packet makes it all
- 15:00Speaker 2: the way down to the bottom of the list without
- 15:02Speaker 2: hitting an accept rule, the kernel will just reject it.
- 15:05Speaker 2: It's your ultimate safety net, ensuring nothing undocumented slips through.
- 15:10Speaker 1: This raises an important question, though, and it brings me
- 15:12Speaker 1: to an incredibly frustrating pitfall I ran into when I
- 15:16Speaker 1: first started learning this architecture.
- 15:17Speaker 2: Oh, I think I know where this is going.
- 15:19Speaker 1: Let's say I install a web server and I need
- 15:21Speaker 1: to open port 80 for incoming HTTP traffic. I'm in
- 15:24Speaker 1: the terminal looking at the command prompt. I type out
- 15:27Speaker 1: the command. Iptables hyphen N N P U T hyphen
- 15:32Speaker 1: P hyphen D port 80 hyphen J A C C
- 15:34Speaker 1: C P D. I hit enter.
- 15:35Speaker 2: OK, looks good so far.
- 15:37Speaker 1: The cursor drops to the next line. No errors. Everything
- 15:40Speaker 1: looks perfect. But when I go to my browser, the
- 15:43Speaker 1: web page completely fails to load. Mechanically, what went wrong there?
- 15:47Speaker 2: The issue lies entirely with that hyphen A flag in
- 15:50Speaker 2: your command. Hyphen A stands for append.
- 15:54Speaker 1: Ah, it appends the rule.
- 15:55Speaker 2: Yes, it appends the rule to the very end of
- 15:58Speaker 2: the list.
- 15:58Speaker 1: Meaning my brand new rule to accept port 80 was
- 16:01Speaker 1: placed below the blanket reject rule.
- 16:03Speaker 2: Exactly. Because of the top-to-bottom serial processing we just discussed,
- 16:08Speaker 2: the kernel saw the incoming web traffic, hit the catch-all
- 16:11Speaker 2: reject rule, dropped the packets, and stopped reading long before
- 16:15Speaker 2: it ever reached your new accept rule.
- 16:17Speaker 1: It drives people crazy, because you turn off the firewall
- 16:20Speaker 1: service entirely, and the web page loads perfectly. You turn
- 16:23Speaker 1: it back on, and it breaks. The traffic is still
- 16:26Speaker 1: being blocked, despite the rule technically existing.
- 16:28Speaker 2: Yep, the logic flow is king.
- 16:30Speaker 1: So how do we avoid the append trap? when we
- 16:33Speaker 1: are configuring via the command line.
- 16:35Speaker 2: Well, instead of hyphen A for append, you should use
- 16:37Speaker 2: hyphen I for insert. That allows you to specify exactly
- 16:41Speaker 2: which line number you want the rule to occupy.
- 16:43Speaker 1: That's handy. It is.
- 16:44Speaker 2: However, this is a really strong argument for why manually
- 16:48Speaker 2: opening the Eptables configuration file in a text editor can
- 16:51Speaker 2: sometimes be much clearer, especially for beginners.
- 16:54Speaker 1: Because you can actually see it. Right.
- 16:56Speaker 2: When you view the file directly, you have visual confirmation
- 16:59Speaker 2: of the logic flow. You can literally paste your new
- 17:02Speaker 2: port 80 rule right above the final reject line, save
- 17:06Speaker 2: the file, and know for an absolute fact the execution
- 17:10Speaker 2: order is correct.
- 17:11Speaker 1: Visual confirmation definitely helps. But let's say I do use
- 17:14Speaker 1: the command line. I use the insert flag correctly. I
- 17:16Speaker 1: verify the rules with the list command, and the web
- 17:19Speaker 1: server is working flawlessly.
- 17:20Speaker 2: Great.
- 17:21Speaker 1: Then a week later, the server reboots for a routine
- 17:23Speaker 1: kernel update, and suddenly my web server is blocked again.
- 17:27Speaker 1: All the rules I typed are completely gone. What happened?
- 17:30Speaker 2: Ah, the volatile memory trap. When you use the Iptable's
- 17:34Speaker 2: command line tool, you are exclusively modifying the live running
- 17:37Speaker 2: rules in the system's volatile memory.
- 17:39Speaker 1: The RAM.
- 17:40Speaker 2: Yes, the RAM. The moment the server loses power or reboots,
- 17:43Speaker 2: that RAM is wiped. And upon startup, NetFilter reverts to
- 17:46Speaker 2: whatever is saved on the physical disk in that configuration file.
- 17:49Speaker 1: So all that careful configuration work in the terminal just
- 17:53Speaker 1: vanishes into the ether.
- 17:54Speaker 2: Exactly. To make your dynamic terminal changes permanent, you must
- 17:58Speaker 2: explicitly lock them in by running service iptables save.
- 18:01Speaker 1: Service iptables save. Okay.
- 18:04Speaker 2: That command takes the current configuration running in memory and
- 18:07Speaker 2: overwrites the file on the disk so your rules survive
- 18:10Speaker 2: a reboot.
- 18:10Speaker 1: Makes sense.
- 18:12Speaker 2: And conversely, if you chose to manually edit the text
- 18:14Speaker 2: file instead, the live firewall in memory doesn't magically know
- 18:18Speaker 2: you changed the file on the disk. You have to
- 18:20Speaker 2: run service iptables reload or restart to to force the
- 18:23Speaker 2: system to read the disk and apply your new logic
- 18:26Speaker 2: to the RAM.
- 18:27Speaker 1: So what does this all mean? If we step back
- 18:29Speaker 1: and look at the whole picture, true server security is
- 18:32Speaker 1: this dynamic two-step pants.
- 18:34Speaker 2: It really is.
- 18:35Speaker 1: You use a tool like Nessus to play offense actively,
- 18:38Speaker 1: hunting for vulnerable legacy applications and mapping out your invisible
- 18:42Speaker 1: open doors. And then you use the kernel-level power of
- 18:46Speaker 1: IP tables to tightly and methodically control exactly who is
- 18:50Speaker 1: allowed through your gates.
- 18:52Speaker 2: The overarching theme here is that security is never a
- 18:55Speaker 2: static configuration. It's not a set it and forget it thing.
- 18:58Speaker 1: Right.
- 18:58Speaker 2: Vulnerability spanners and firewalls are incredibly powerful pieces of technology,
- 19:03Speaker 2: but they are ultimately just tools. Their effectiveness relies entirely
- 19:08Speaker 2: on the architectural logic and critical thinking of the person
- 19:11Speaker 2: sitting at the keyboard.
- 19:13Speaker 1: You have to interpret the lack of context in false positives.
- 19:16Speaker 2: Yeah.
- 19:16Speaker 1: You have to optimize the serial processing logic of your
- 19:19Speaker 1: rule sets.
- 19:20Speaker 2: Exactly. And you have to constantly consider how traffic could
- 19:23Speaker 2: move laterally across your network if the perimeter falls.
- 19:26Speaker 1: Which brings us to a quick mental exercise to reinforce
- 19:29Speaker 1: everything we've just unpacked today.
- 19:31Speaker 2: Oh, a pup quiz.
- 19:31Speaker 1: Just a little one. Imagine you're staring down a terminal
- 19:35Speaker 1: window and you need to set up a web cache
- 19:38Speaker 1: on your server. This requires you to open port 8080. Okay.
- 19:43Speaker 1: Based on our deep dive, exactly where in the IP
- 19:45Speaker 1: tables configuration list must that new port 8080 rule be
- 19:49Speaker 1: placed to ensure the kernel doesn't drop the packets? And
- 19:53Speaker 1: once you get it working in the command line, what
- 19:55Speaker 1: is the exact command you need to run so your
- 19:57Speaker 1: server doesn't suffer from amnesia the next time it restarts?
- 20:00Speaker 2: Think carefully about the serial order of operations and the
- 20:05Speaker 2: mechanical difference between system memory and the physical disk.
- 20:08Speaker 1: That's something to mull over before your next server deployment.
- 20:12Speaker 1: Thank you so much for joining us on this deep dive.
- 20:14Speaker 1: We hope you feel empowered to go out there, audit
- 20:16Speaker 1: your own systems, and secure your digital perimeter. Until next time.