‫Now we're going to talk about a firewall and packet filtering.
‫OK, so a firewall is basically a filtering gateway, and it only acts on packets that need to pass
‫through so it can only be effective when going through the firewall is the only path for those packets
‫you follow.
‫So the absence of a standard configuration explains a lack of a turnkey solution.
‫However, there are tools to make configuring the net filter firewall way easier.
‫So the net filter firewall is built into the Linux kernel due to different network and user requirements,
‫there's no turnkey solution with any firewall, with any firewall ever, anywhere, even though they
‫might market one anyway.
‫You can control net filter from the user's base using the IP tables and the IP six tables commands.
‫Now, the difference between these two commands is that the first works for IPv4 networks is second
‫works on Guess what, IPv6.
‫So you can also use UFW as a net filter firewall.
‫That's, of course, what the cool kids call uncomplicated firewall.
‫So UFW is a program for managing a net filter firewall designed to be easy to use.
‫It uses a command line interface consisting of a small number of simple commands and uses IP tables
‫for configuration.
‫We're also going to see a very simple example.
‫So in other words, however, you decide to configure it, and that filter is Linux firewall implementation.
‫So why don't we just have a closer look?
‫See how it works.
‫So that filter uses four distinct tables, right?
‫And these store rules regulating three kinds of operations on packets.
‫That filter mango and raw.
‫Now, each table contains a list of rules called chains.
‫Firewall uses standard strings to process packets according to predefined conditions.
‫All right, so the schema that you see on a screen is a schema of the net filter chain.
‫Each chain is a list of rules, so each rule is a set of conditions and then actions that are going
‫to be performed when the conditions are met.
‫So let's use the IP table command.
‫Open, Callie.
‫Let's start with the IP tables, and we'll create some rules, right, pseudo sue dash for permission.
‫Right.
‫IP tables.
‫Dash H to see the commands.
‫So you can see the parameters and the definitions of them.
‫Now, to see if it's working, let's create a simple rule.
‫So first rate iptables Dash L to list all the rules, as you can see.
‫Well, we don't have a rule right now.
‫So in this example, what we'll do is we'll accept all traffic from the age connection, so we'll write
‫iptables dash a input dash p TCP Dash Deport 22 Dash J Accept.
‫So the dash here means append.
‫And it adds the rule to the end of the current chain or the chain that you specify.
‫So in this case, input is a chain that we are adding the rule.
‫Dash P specifies a protocol that we want to allow.
‫We want to allow TCP connections because, as I say, age uses TCP connections.
‫Double Dash Deport is the destination port of the connection.
‫So Associates uses Port 22.
‫And J is what you want to have happen.
‫So it's a target of the rule and we want to accept sage traffic, so hit enter and with rules again.
‫Right.
‫IP tables, Dash L list rules.
‫And as you can see, we have successfully added the rule and the rule table.
‫Now it's going to accept all traffic coming from 422.
‫Now, let's say that you want to delete a rule.
‫Well, first, right, I.P. tables, Dash L double dash line, dash numbers, and that way we can see
‫which line that you wanted to lead.
‫Here is our rule.
‫And this is the one that we want to delete.
‫So right?
‫Tables Dash D and the chain name, which is input and the number of the line, which is one hit enter.
‫List the rules again.
‫And as you can see, the rule was deleted.
‫Cool.
‫All right, so now the next tool is UFW.
‫Open the terminal and right, have UFW Dash help?
‫And you can see the options here, so enable the firewall to allow or deny the connections or whatever.
‫So what we're going to do is allow the S.H. connection.
‫Right.
‫Sudo UFW allow access H.
‫And you can see here that the sage rule was added.
‫And then to activate the firewall, right, sudo UFW enable.
‫And the firewall is activated.
‫Let's have a look at the active rules.
‫So we'll write sudo UFW status numbered.
‫And there you can see the SSA rule is activated.
‫Awesome.