Assignment-04-Solutions
pdf
keyboard_arrow_up
School
Carleton University *
*We aren’t endorsed by this school
Course
4810
Subject
Computer Science
Date
Jan 9, 2024
Type
Pages
24
Uploaded by CountFlagTrout38
SYSC 4810: Introduction to Network and Software Security
Module 4
Assignment
Fall 2021
Dr. J. Jaskolka
Carleton University
Department of Systems and Computer Engineering
Posted: October 21, 2021
Due: November 14, 2021
Due on Sunday, November 14, 2021 by 11:59PM
This assignment contains 24 pages (including this cover page) and 8 problems.
You are responsible for
ensuring that your copy of the assignment is complete.
Bring any discrepancy to the attention of your
instructor.
Special Instructions:
1.
Do as many problems as you can.
2. Start early as this assignment is much more time consuming than you might initially think!
3. The burden of communication is upon you. Solutions not properly explained will not be considered
correct. Part of proper communication is the appearance and layout. If we cannot “decode” what you
wrote, we cannot grade it as a correct solution.
4. You may consult outside sources, such as textbooks, but
any use
of
any source
must
be documented
in the assignment solutions.
5. You are permitted to discuss
general aspects
of the problem sets with other students in the class, but
you must hand in your own copy of the solutions.
6. Your assignment solutions are due by 11:59PM on the due date and must be submitted on
Brightspace
.
•
Late assignments will be graded with a late penalty of 20% of the full grade per day
up to 48
hours past the deadline
.
7. You are responsible for ensuring that your assignment is submitted correctly and without corruption.
Problem
1
2
3
4
5
6
7
8
Total
Points:
20
10
10
10
10
10
10
10
90
Page 1 of 24
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
In this assignment, you will participate in activities related to implementing and using a simple firewall for a
network. This assignment aims to assess your understanding of implementing and using basic security tools
to enhance network security.
Acknowledgment
This assignment is based off the “Firewall Exploration” SEED Lab developed by Wenliang Du at Syracuse
University.
Background Research
A significant portion of this assignment is to do the required background research on working with basic
networking tools such as
ping
,
telnet
,
iptables
,
conntrack
,
NetFilter
, and
Docker
.
Keep in mind
that a substantial component of any software or computer systems project is to solve and/or eliminate the
underlying technical difficulties. This often means exploring user manuals and documentation.
Submission Requirements
Please read the following instructions very carefully and follow them precisely when submitting your assignment!
The following items are required for a complete assignment submission:
1.
PDF Assignment Report
: Submit a detailed report that carefully and concisely describes what
you have done and what you have observed. Include appropriate code snippets and listings, as well
as screenshots of program outputs and results. You also need to provide an adequate explanation of
the observations that are interesting or surprising. You are encouraged to pursue further investigation
beyond what is required by the assignment description.
2.
ZIP Archive of Source Code
: In addition to embedding source code listings in your assignment
report, create and submit a ZIP archive of all programs that you write for this assignment.
Please
name each of your source code files with the problem number to which they correspond (e.g., for
Problem 2(a), the source code file should be named
Problem2a.c
).
Your source code must compile
and run, producing the desired output. Also, please remember to provide sufficient comments in your
code to describe what it does and why.
3.
ZIP Archive of Screenshot Image Files
: In addition to embedding screenshots of program outputs
and results in your assignment report, create and submit a ZIP archive of all of the raw screenshot
images that you capture for this assignment.
Grading Notes
An important part of this assignment is following instructions. As such, the following grade
penalties
will
be applied for failure to comply with the submission requirements outlined above:
•
Failure to submit an Assignment Report will result in a grade of
0
for the assignment.
•
Failure to submit the Source Code files will result in deduction of
10%
of the full grade of the assignment.
•
Failure to submit the Screenshot Image files will result in deduction of
10%
of the full grade of the
assignment.
•
Failure of Source Code to compile/run will result in a grade of
0
for the corresponding problem(s).
•
Failure to submit any deliverable in the required format (PDF or ZIP) will result in deduction of
5%
of the full grade of the assignment.
Page 2 of 24
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
Part I
Assignment Challenge
1
Introduction
Imagine that you are a new network security administrator at a large technology firm firm called
GlobalTech
Solutions
.
Your direct supervisor has just assigned you to investigate firewall solutions for protecting the
routers and internal networks and servers residing on premise at
GlobalTech Solutions
. You are responsible for
making recommendations to address the needs of
GlobalTech Solutions
and the concerns of your supervisor
by conducting some experiments and documenting your findings. The details of the assignment including
your supervisor’s expectations are provided in the sections below.
The different parts of this assignment are designed to guide your investigation to address the needs of
GlobalTech Solutions
and the concerns of your supervisor. At the end of the assignment, you will be required
to summarize your findings and provide recommendations in a report to your supervisor addressing their
concerns.
2
Context
Your supervisor has sent you the following email explaining their needs and concerns:
Hello,
Welcome to the team! As you are aware, GlobalTech Solutions develops a wide range of technology
solutions and services for clients worldwide.
GlobalTech Solutions prides itself on providing
high-quality solutions delivered on-time and on-budget.
We have recently conducted an internal security audit that suggests we could improve our network
security posture. One of the suggestions from the audit is to investigate firewall solutions to block
potentially problematic applications and protocols (e.g., telnet). We also need a significant effort
to explore solutions that can help to protect our routers and internal networks and servers.
I
am concerned that if we do not have a suitable solution, we will be susceptible to attacks (which
have been on the rise). This could be a significant issue for our systems and data environments.
Naturally, we want to avoid these issues and GlobalTech Solutions has pledged to invest in
improved network security for the organization if we present a suitable proposal.
For your first assignment, we need you to investigate firewall solutions to enhance the network
security of GlobalTech Solutions.
Talking with some other members of the team, our initial
thought is to set up a packet filtering firewall or a stateful inspection firewall using iptables or
a loadable kernel module, but we need to investigate these ideas further (I am not too familiar
with all of this). It is essential that the firewall is configured correctly, so any rules will have to
be checked to ensure they block only what is expected; no more, no less. I also want to know if
there are possible ways to limit network traffic if we suspect something fishy is going on.
I expect a report documenting your experiments and a summary of your findings so that I can
bring it forward to upper-management to secure their investment in this project.
Good luck,
JJ
Page 3 of 24
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
3
Obligations
At the end of this assignment, you will be required to deliver the following information and outcomes to
your supervisor:
1. Provide a detailed report documenting each of your experiments and findings.
This is necessary to
enable your supervisor to make important decisions about how best to proceed with the project proposal
and to demonstrate that you have been thorough in your investigation.
2. Provide a summary of your findings including a discussion of alternative choices and potential challenges,
issues and opportunties addressing each of the concerns mentioned in the email from your supervisor.
Include any necessary recommendations based on your findings.
Page 4 of 24
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
Part II
Environment Setup
This assignment will be conducted using a pre-built virtual machine (VM) image. We will assume that you
already have a virtual machine set up from the Module 1 Assignment. For this assignment, we need to use
multiple machines. Their setup is depicted in Figure
1
. We will use containers to set up this environment.
10.9.0.1
Attacker
Internal Network
10.9.0.11
Router
10.9.0.5
192.168.60.5
192.168.60.6
192.168.60.7
10.9.0.0/24
192.168.60.0/24
192.168.60.11
External Network
Figure 1: Network setup for the Module 4 Assignment
1
Container Setup and Commands
Please download the
Setup.zip
file to your VM from from the assignment resources for this assignment on
Brightspace, unzip it, enter the
Setup
folder, and use the
docker-compose.yml
file to set up the assignment
environment. A detailed explanation of the content in this file can be found in the user manual linked here:
DOCKER MANUAL
In what follows, we list some of the commonly used commands related to Docker and Compose. Since we
are going to use these commands very frequently, aliases have been created for them in the
.bashrc
file in
the provided VM image.
$ docker-compose build
// Build the container image
$ docker-compose up
// Start the container
$ docker-compose down
// Shut down the container
// Aliases for the Compose commands above
$ dcbuild
// Alias for: docker-compose build
$ dcup
// Alias for: docker-compose up
$ dcdown
// Alias for: docker-compose down
Page 5 of 24
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
All the containers will be running in the background. To run commands on a container, we need to get a
shell on that container. We first need to use the
docker ps
command to find out the ID of the container,
and then use
docker exec
to start a shell on that container.
Aliases have been created for them in the
.bashrc
file in the provided VM image.
$ dockps
// Alias for: docker ps --format "{{.ID}} {{.Names}}"
$ docksh <id>
// Alias for: docker exec -it <id> /bin/bash
// The following example shows how to get a shell inside hostC
$ dockps
b1004832e275 hostA-10.9.0.5
0af4ea7a3e2e hostB-10.9.0.6
9652715c8e0a hostC-10.9.0.7
$ docksh 96
root@9652715c8e0a:/#
// Note: If a docker command requires a container ID, you do not need to
//
type the entire ID string. Typing the first few characters will
//
be sufficient, as long as they are unique among all the containers.
If you encounter problems when setting up the environment, please read the “Common Problems” section of
the
DOCKER MANUAL
for potential solutions.
2
User Accounts
As a reminder, the virtual machine has two user accounts. The usernames and passwords are listed below:
1. User ID:
root
, Password:
seedubuntu
.
•
Ubuntu does not allow root to login directly from the login window. You have to login as a normal
user, and then use the command
su
to login to the
root
account.
2. User ID:
seed
, Password:
dees
.
•
This account is already given the root privilege, but to use the privilege, you need to use the
sudo
command.
*Important Note*
It is essential that you set up the virtual machine environments as early as possible
to ensure that you have time to address any technical difficulties that you may face. The instructor and the
TA will not be able to provide adequate technical support close to the assignment due date.
Page 6 of 24
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
Part III
Linux Firewall Exploration
1
Introduction
Firewalls have several types.
In this assignment, you will participate in activities using different types
of firewalls, and through the implementation of some of the key functionalities, you will develop a better
understanding of how firewalls work.
2
IP Addressing and Subnetting Basics
IP addresses allow network resources to be reached through a network interface. If one computer wants to
communicate with another computer, it can address the information to the remote computer’s IP address.
Assuming that the two computers are on the same network, or that the different computers and devices in
between can translate requests across networks, the computers should be able to reach each other and send
information.
Each IP address must be unique on its own network. Networks can be isolated from one another, and they
can be bridged and translated to provide access between distinct networks. A system called
Network Address
Translation
(NAT), allows the addresses to be rewritten when packets traverse network borders to allow them
to continue on to their correct destination. This allows the same IP address to be used on multiple, isolated
networks while still allowing these to communicate with each other if configured correctly.
2.1
IPv4 Addresses
An IPv4 address is a 32-bit value. To aid in human comprehension, we often represent IPv4 addresses using
the
dotted-decimal
notation where, each octet, or 8-bit segment of the address, is divided by a period and
typically expressed as a number 0-255. A typical IPv4 address looks something like this:
192.168.123.132
.
Each IP address has two components: a
network address
and a
host address
. The network address is used to
identify the network that the address is a part of. The host address is used to specify a specific host within
that network. For example, if you divide the IP address
192.168.123.132
into these two parts you get the
following:
192.168.123. network .132 host
-or-
192.168.123.0 // network address
0.0.0.132
// host address
The boundary between the network address and the host address is determined by the network class (see
Section
2.2
) and the NetMask (see Section
2.3
).
2.2
Network Classes
IP addresses are divided into classes.
The most common of these are classes
A
,
B
, and
C
.
Classes
D
and
E
exist, but are not generally used by end users. Each of the classes has a different default NetMask
(see Section
2.3
). You can identify the class of an IP address by looking at its first octet. The ranges of
Class
A
,
B
, and
C
addresses are given below:
•
Class
A
networks use a default NetMask of
255.0.0.0
and have 0-127 as their first octet. The address
10.52.36.11
is a class
A
address.
•
Class
B
networks use a default NetMask of
255.255.0.0
and have 128-191 as their first octet. The
address
172.16.52.63
is a class
B
address.
Page 7 of 24
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
•
Class
C
networks use a default NetMask of
255.255.255.0
and have 192-223 as their first octet. The
address
192.168.123.132
is a class
C
address.
2.3
NetMasks and Subnets
The process of dividing a network into smaller network sections is called
subnetting
. This can be useful for
many different purposes and helps isolate groups of hosts together and deal with them easily. As discussed
in Section
2.1
, each IP address space is divided into a
network address
and a
host address
.
A
NetMask
simply refers to a way of separating the network address and the host address of an IP address.
It consists of the number of contiguous bits reflecting the size of the network address and is typically written
in normal dotted-decimal notation, for example
255.255.255.0
, and is used in routing tables with bitwise
AND operations.
Each bit of the address that is considered significant for describing the network address should be represented
as a “1” in the NetMask. For instance, consider the IP address
192.168.123.132
. As discussed in Section
2.2
,
this is a class
C
address and the network address for class
C
addresses is the first 3 octets, or the first 24 bits.
Since these are the significant bits that we want to preserve, the NetMask, in binary and dotted-decimal
notation, respectively, would be:
1111 1111 1111 1111 1111 1111 0000 0000
-or-
255.255.255.0
Any bit that is a “0” in the binary representation of the NetMask is considered part of the host address and
can be variable.
2.4
CIDR
A system called
Classless Inter-Domain Routing (CIDR)
, was developed as an alternative to traditional
subnetting.
The idea is that you can add a specification in the IP address itself as to the number of
significant bits that make up the network address and the host address.
For example, we could express
the idea that the IP address
192.168.123.132
is associated with the NetMask
255.255.255.0
by using
the CIDR notation of
192.168.123.132/24
. This means that the first 24 bits of the IP address given are
considered significant for describing the network.
A useful calculator utility for understanding IP addresses, NetMasks, CIDR, and available host addresses in
a specified subnet can be found here:
https://www.iplocation.net/subnet-calculator
3
Linux Firewall Basics
In this assignment, you will implement a simple packet filtering type of firewall, which inspects each incoming
and outgoing packets, and enforces the firewall policies set by the administrator. Since the packet processing
is done within the kernel, the filtering must also be done within the kernel.
Therefore, it seems that
implementing such a firewall requires us to modify the Linux kernel. In the past, this had to be done by
modifying and rebuilding the kernel. The modern Linux operating systems provide several new mechanisms
to facilitate the manipulation of packets without rebuilding the kernel image. These two mechanisms are
Loadable Kernel Module
(
LKM
) and
Netfilter
.
Notes about containers.
Since all the containers share the same kernel, kernel modules are global.
Therefore, if we set a kernel module from a container, it affects all the containers and the host.
For this
reason, it does not matter where you set the kernel module. In this assignment, you can just set the kernel
module from the host VM.
Another thing to keep in mind is that containers’ IP addresses are virtual. Packets going to these virtual IP
addresses may not traverse the same path as what is described in the
Netfilter
documentation.
Page 8 of 24
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
3.1
Loadable Kernel Modules
LKM
allows us to add a new module to the kernel at the runtime. This new module enables us to extend
the functionalities of the kernel, without rebuilding the kernel or even rebooting the computer. The packet
filtering part of a firewall can be implemented as an
LKM
.
The following is a simple loadable kernel module. It prints out “
Hello World!
” when the module is loaded;
when the module is removed from the kernel, it prints out “
Bye-bye World!
”. The messages are not printed
out on the screen; they are actually printed into the
/var/log/syslog
file. You can use
dmesg | tail -10
to read the last 10 lines of the message.
#include
<linux/module.h>
#include
<linux/kernel.h>
int
initialization(
void
)
{
printk(KERN_INFO
"Hello World!\n"
);
return
0;
}
void
cleanup(
void
)
{
printk(KERN_INFO
"Bye-bye World!.\n"
);
}
module_init(initialization);
module_exit(cleanup);
We now need to create a
Makefile
, which includes the following contents (the above program is named
hello.c
).
Then just type
make
, and the above program will be compiled into a loadable kernel module
called
hello.ko
.
obj-m += hello.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
Once the module is built by typing
make
, you can use the following commands to load the module, list all
modules, remove the module, and show information about the module:
$ sudo insmod mymod.ko
// insert the module
$ lsmod
// list all modules
$ sudo rmmod mymod.ko
// remove the module
$ modinfo mymod.ko
// show information about the module
3.2
Netfilter
Netfilter
is designed to facilitate the manipulation of packets by authorized users. It achieves this goal by
implementing a number of hooks in the Linux kernel. These hooks are inserted into various places, including
the packet incoming and outgoing paths. If we want to manipulate the incoming packets, we simply need to
connect our own programs (within
LKM
) to the corresponding hooks. Once an incoming packet arrives, our
program will be invoked. Our program can decide whether this packet should be blocked or not; moreover,
we can also modify the packets in the program.
Page 9 of 24
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
3.2.1
Netfilter
Hooks for IPv4
Netfilter
defines five hooks for IPv4.
•
NF_INET_PRE_ROUTING
: All the incoming packets, with the exception of those caused by the promiscuous
mode (in which all network data packets can be accessed and viewed by all network adapters), hit this
hook. This is called before any routing decision is made.
•
NF_INET_LOCAL_IN
: The incoming packet will then go through routing, which decides whether the
packet is for other machines or for the host itself.
In the former case, the packet will go to the
forwarding path, while in the latter case, the packet will go through this hook, before being sent to the
network stack and eventually consumed by the host.
•
NF_INET_FORWARD
: Packets that are forwarded to other hosts reach this hook. This is very useful for
implementing a firewall.
•
NF_INET_LOCAL_OUT
: Packets generated by the local host reach this hook. This is the first hook for
the packets on their way out of the host.
•
NF_INET_POST_ROUTING
: When a packet, forwarded or generated, is going out of the host, it will pass
this hook. Source Network Address Translation is implemented at this hook.
These five hooks and the packet traversal path are depicted in in Figure
2
.
NF_INET_PRE_ROUTING
Routing
NF_INET_FORWARD
NF_INET_LOCAL_IN
NF_INET_LOCAL_OUT
NF_INET_POST_ROUTING
Routing
Network Stack
Figure 2:
Netfilter
hooks in the IPv4 stack
3.2.2
Hooking to
Netfilter
Using
Netfilter
is quite straightforward. All we need to do is to hook our functions (in the kernel module)
to the corresponding
Netfilter
hooks. Here we show an example. The structure of the code follows the
structure of a kernel module as discussion in Section
3.1
. When the kernel module is added to the kernel,
the
registerFilter()
function in the code will be invoked. Inside this function, we register two hooks to
Netfilter
.
To register a hook, you need to prepare a hook data structure, and set all the needed parameters, the most
important of which are a function name (
LINE 1
) and a hook number (
LINE 2
). The hook number is one
of the five hooks in
Netfilter
, and the specified function will be invoked when a packet has reached this
hook. In this example, when a packet gets to the
NF_INET_LOCAL_IN
hook, the function
printInfo()
will
be invoked (this function will be given later). Once the hook data structure is prepared, we attach the hook
to
Netfilter
in
LINE 3
.
Page 10 of 24
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
static struct
nf_hook_ops hook1, hook2;
int
registerFilter(
void
) {
printk(KERN_INFO
"Registering filters.\n"
);
// Hook 1
hook1.hook = printInfo;
// LINE 1
hook1.hooknum = NF_INET_LOCAL_IN;
// LINE 2
hook1.pf = PF_INET;
hook1.priority = NF_IP_PRI_FIRST;
nf_register_net_hook(&init_net, &hook1);
// LINE 3
// Hook 2
hook2.hook = blockUDP;
hook2.hooknum = NF_INET_POST_ROUTING;
hook2.pf = PF_INET;
hook2.priority = NF_IP_PRI_FIRST;
nf_register_net_hook(&init_net, &hook2);
return
0;
}
void
removeFilter(
void
) {
printk(KERN_INFO
"The filters are being removed.\n"
);
nf_unregister_net_hook(&init_net, &hook1);
nf_unregister_net_hook(&init_net, &hook2);
}
module_init(registerFilter);
module_exit(removeFilter);
3.2.3
Hook Functions
We give an example of hook function below. It only prints out the packet information. When
Netfilter
invokes a hook function, it passes three arguments to the function, including a pointer to the actual packet
(
skb
). In the following code,
LINE 1
shows how to retrieve the hook number from the state argument. In
LINE 2
, we use the
ip_hdr()
function to get the pointer for the IP header, and then use the
%pI4
format
string specifier to print out the source and destination IP addresses in
LINE 3
.
unsigned int
printInfo(
void
*priv,
struct
sk_buff *skb,
const struct
nf_hook_state *state)
{
struct
iphdr *iph;
char
*hook;
switch
(state->hook){
// LINE 1
case
NF_INET_LOCAL_IN:
printk(
"*** LOCAL_IN"
);
break
;
// ... (code omitted) ...
}
iph = ip_hdr(skb);
// LINE 2
printk(
" %pI4 --> %pI4\n"
, &(iph->saddr), &(iph->daddr));
// LINE 3
return
NF_ACCEPT;
}
Page 11 of 24
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
If you need to get the headers for other protocols, you can use the following functions defined in various
header files. The structure definition of these headers can be found inside the following folder:
/lib/modules/5.4.0-54-generic/build/include/uapi/linux
where the version number in the path is the resultof
uname -r
, so it may be different if the kernel version
is different.
struct
iphdr
*iph
= ip_hdr(skb)
// (need to include <linux/ip.h>)
struct
tcphdr *tcph = tcp_hdr(skb)
// (need to include <linux/tcp.h>)
struct
udphdr *udph = udp_hdr(skb)
// (need to include <linux/udp.h>)
struct
icmphdr *icmph = icmp_hdr(skb)
// (need to include <linux/icmp.h>)
3.2.4
Blocking Packets
We also provide a hook function example to show how to block a packet, if it satisfies the specified condition.
The following example blocks the UDP packets if their destination IP is
8.8.8.8
and the destination port
is
53
. This means blocking the DNS query to the nameserver
8.8.8.8
.
In the code below,
LINE 1
shows, inside the kernel, how to convert an IP address in the dotted decimal
format (i.e., a string, such as
1.2.3.4
) to a 32-bit binary (
0x01020304
), so it can be compared with the
binary number stored inside packets.
LINE 2
compares the destination IP address and port number with the
values in our specified rule. If they match the rule, the
NF_DROP
(
LINE 3
) will be returned to
Netfilter
,
which will drop the packet. Otherwise, the
NF_ACCEPT
will be returned (
LINE 4
), and
Netfilter
will let
the packet continue its journey (
NF_ACCEPT
only means that the packet is accepted by this hook function; it
may still be dropped by other hook functions).
unsigned int
blockUDP(
void
*priv,
struct
sk_buff *skb,
const struct
nf_hook_state *state)
{
struct
iphdr *iph;
struct
udphdr *udph;
u32
ip_addr;
char
ip[16] =
"8.8.8.8"
;
// Convert the IPv4 address from dotted decimal to a 32-bit number
in4_pton(ip, -1, (u8 *)&ip_addr,
’\0’
, NULL);
// LINE 1
iph = ip_hdr(skb);
if
(iph->protocol == IPPROTO_UDP) {
udph = udp_hdr(skb);
if
(iph->daddr == ip_addr && ntohs(udph->dest) == 53){
// LINE 2
printk(KERN_DEBUG
"****Dropping %pI4 (UDP), port %d\n"
, &(iph->daddr), port);
return
NF_DROP;
// LINE 3
}
}
return
NF_ACCEPT;
// LINE 4
}
3.3
iptables
The
iptables
firewall is designed not only to filter packets, but also to make changes to packets. To help
manage these firewall rules for different purposes,
iptables
organizes all rules using a hierarchical structure:
table, chain, and rules. There are several tables, each specifying the main purpose of the rules as shown in
Table
1
. For example, rules for packet filtering should be placed in the
filter
table, while rules for making
changes to packets should be placed in the
nat
or
mangle
tables.
Page 12 of 24
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
Table 1:
iptables
Tables and Chains
Table
Chain
Functionality
filter
INPUT
Packet filtering
FORWARD
OUTPUT
nat
PREROUTING
Modifying source or destination network addresses
INPUT
OUTPUT
POSTROUTING
mangle
PREROUTING
Packet content modification
INPUT
FORWARD
OUTPUT
POSTROUTING
Each table contains several chains, each of which corresponds to a
Netfilter
hook. Basically, each chain
indicates where its rules are enforced.
For example, rules on the
FORWARD
chain are enforced at the
NF_INET_FORWARD
hook, and rules on the
INPUT
chain are enforced at the
NF_INET_LOCAL_IN
hook.
Each chain contains a set of firewall rules that will be enforced. When we set up firewalls, we add rules to
these chains. For example, if we would like to block all incoming
telnet
traffic, we would add a rule to the
INPUT
chain of the
filter
table. If we would like to redirect all incoming
telnet
traffic to a different port
on a different host, basically doing port forwarding, we can add a rule to the
INPUT
chain of the
mangle
table, as we need to make changes to packets.
3.3.1
Using
iptables
To add rules to the chains in each table, we use the
iptables
command, which is a quite powerful command.
You can find the manual of
iptables
by typing
man iptables
. What makes
iptables
complicated is the
many command-line arguments that we need to provide when using the command. However, if we understand
the structure of these command-line arguments, we will find out that the command is not that complicated.
In a typical
iptables
command, we add a rule to, or remove a rule from, one of the chains in one of the
tables, so we need to specify a table name (the default is
filter
), a chain name, and an operation on
the chain. After that, we specify the rule, which is basically a pattern that will be matched with each of
the packets passing through. If there is a match, an action will be performed on this packet. The general
structure of the command is depicted below:
iptables -t <table> -<operation> <chain> <rule> -j <target>
---------- -------------------- ------- -----------
Table
Chain
Rule
Action
The rule is the most complicated part of the
iptables
command. Additional information will be given later
when using specific rules. In what follows, we list some commonly used commands:
// List all the rules in a table (without line number)
iptables -t nat -L -n
// List all the rules in a table (with line number)
iptables -t filter -L -n --line-numbers
// Delete rule No. 2 in the INPUT chain of the filter table
iptables -t filter -D INPUT 2
Page 13 of 24
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
// Drop all the incoming packets that satisfy the <rule>
iptables -t filter -A INPUT <rule> -j DROP
Note.
Docker relies on
iptables
to manage the networks it creates, so it adds many rules to the
nat
table.
When we manipulate
iptables
rules, we should be careful not to remove Docker rules. For example, it will
be quite dangerous to run the
iptables -t nat -F
command, because it removes all the rules in the
nay
table, including many of the Docker rules. That will cause trouble to Docker containers. Doing this for the
filter
table is fine, because Docker does not touch this table.
3.4
conntrack
Connection tracking (
conntrack
) is a core feature of the Linux kernel’s networking stack.
It allows the
kernel to keep track of all logical network connections or flows, and thereby identify all of the packets which
make up each flow so they can be handled consistently together.
Each incoming packet is marked with a connection state so that further handling will be easier on other
hooks. There are several types of state:
•
NEW
: The connection is starting and the packet is part of a valid initialization sequence. This state only
exists for a connection if the firewall has only seen traffic in one direction.
•
ESTABLISHED
: The connection has been established and a two-way communication has already happened.
•
RELATED
: This is a special state that helps to establish relationships among different connections. For
example, in FTP, the control traffic (traffic going to port 21) is marked as an
ESTABLISHED
connection,
while the data transfer traffic (traffic going to a high port) is marked as a
RELATED
connection.
•
INVALID
: This state is used for packets that do not follow the expected behaviour of a connection.
A
conntrack
entry typically has the following format:
tcp
6 117 SYN_SENT src=192.168.1.6 dst=192.168.1.9 sport=32775 \
dport=22 [UNREPLIED] src=192.168.1.9 dst=192.168.1.6 sport=22 \
dport=32775 [ASSURED] use=2
This example contains all the information that
conntrack
maintains to know the state in which a specific
connection is in. First, we have a protocol, which in this case is
tcp
. Next, we have the protocol given in
in normal decimal coding (e.g.,
tcp
=
6
). The next value shows how long this
conntrack
entry has to live.
This value is set to
117
seconds right now and is decremented regularly until more traffic is seen. This value
is then reset to the default value for the specific state that it is in at that relevant point of time.
Next,
comes the actual state that this entry is in at the present point of time. In the above mentioned case we are
looking at a packet that is in the
SYN_SENT
state. The internal value of a connection is slightly different from
the ones used externally with
iptables
. The value
SYN_SENT
tells us that we are looking at a connection
that has only seen a TCP SYN packet in one direction. Next, we have the source IP address, destination IP
address, source port and destination port. At this point, we see a specific keyword that tells us that we have
seen no return traffic for this connection. Lastly, we see what we expect of return packets. The information
details the source IP address and destination IP address (which are both inverted, since the packet is to be
directed back to us). The same thing goes for the source port and destination port of the connection.
Page 14 of 24
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
4
Problems and Tasks
Problem 1
[20 points]
Implementing a Simple Firewall:
In this problem, you need to use
LKM
and
Netfilter
to
implement a simple packet filtering type of firewall, which inspects each incoming and outgoing packet,
and enforces the firewall policies set by the administrator. This module will fetch the firewall policies
from a data structure, and use the policies to decide whether packets should be blocked or not. Details
of using LKM and Netfilter were provided in Section
3.1
and Section
3.2
.
The complete
Netfiler
sample code is included in the assignment resources on Brightspace in a file called
filter.c
in the
Setup/code/packet_filter
directory. An accompanying
Makefile
is also provided.
(a) [5 points] Compile the sample code using the provided
Makefile
.
Load it into the kernel, and
demonstrate that the firewall is working as expected.
You can use the following command to
generate UDP packets to
8.8.8.8
, which is Google’s DNS server.
dig @8.8.8.8 www.example.com
If your firewall works, your request will be blocked; otherwise, you will get a response.
Do not
forget to explain how you compile the developed kernel module, including your Makefile, and how
the compiled kernel module is inserted it into the Linux kernel.
HINT
: Use
dmesg | tail -10
to read the last 10 lines of the messages that are printed.
Solution:
Award 1 point for an adequate description of how the kernel module was compiled
using a Makefile.
Award 1 point for an adequate description of how the kernel module was
loaded in to the Linux kernel.
Award 3 points for demonstrating that the packet filter is
working as expected with appropriate screenshots.
Students should provide screenshots demonstrating that the packet filter has been compiled
and loaded and works as expected by showing outputs from the
/var/log/syslog
file using
dmesg | tail -10
.
(b) [15 points] Implement two hooks in
filter.c
to achieve the following:
1. Preventing other computers to
ping
the VM (i.e., block ICMP packets)
2. Preventing other computers to
telnet
into the VM (i.e., block TCP packets)
Please implement two different hook functions, but register them to the same
Netfilter
hook. You
should decide what hook to use (see Section
3.2.1
). The default port for
telnet
is TCP port
23
. To
test it, you can start the containers, go to
10.9.0.5
, and run the following commands (
10.9.0.1
is the IP address assigned to the VM; for the sake of simplicity, you can hardcode this IP address
in your firewall rules):
ping 10.9.0.1
telnet 10.9.0.1
You should also demonstrate that traffic to other IP address is not affected.
Solution:
For each hook function: Award 1 point for registering the hook; award 1 point for
unregistering the hook; and award 3 points for a
blockICMP
/
blockTCP
with an appropriate rule
(5 points per hook function; 10 points total). Award 3 points for demonstrating that the packet
filter is working as expected with appropriate screenshots using
ping 10.9.0.1
and
telnet
10.9.0.1
.
Award 2 points demonstrating that the packet filter is working as expected with
appropriate screenshots using
ping
and
telnet
with other IP addresses.
Students should modify the provided
filter.c
included in the Setup files. The added code is
very similar to the provided sample code. The two new hooks are added to the same
LOCAL_IN
hooks, so they will both be invoked when a packet comes into the machine.
Page 15 of 24
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
1. To prevent other computers from being able to
ping
the VM, we need to block ICMP
packets.
hook3.hook = blockICMP;
hook3.hooknum = NF_INET_LOCAL_IN;
hook3.pf = PF_INET;
hook3.priority = NF_IP_PRI_FIRST;
nf_register_net_hook(&init_net, &hook3);
The
blockICMP
function code is similar to the provided
blockUDP
function. It should be
defined with the following rule:
if
(iph->protocol == IPPROTO_ICMP) {
icmph = icmp_hdr(skb);
if
(iph->daddr == ip_addr){
printk(KERN_WARNING
"*** Dropping %pI4 (ICMP)\n"
, &(iph->daddr));
return
NF_DROP;
}
}
return
NF_ACCEPT;
2. To prevent other computers from being able to
telnet
to into VM, we need to block TCP
packets.
hook4.hook = blockTCP;
hook4.hooknum = NF_INET_LOCAL_IN;
hook4.pf = PF_INET;
hook4.priority = NF_IP_PRI_FIRST;
nf_register_net_hook(&init_net, &hook4);
The
blockTCP
function code is similar to the provided
blockUDP
function. It should be
defined with the following rule:
if
(iph->protocol == IPPROTO_TCP) {
tcph = tcp_hdr(skb);
if
(iph->daddr == ip_addr && ntohs(tcph->dest) == port){
printk(KERN_WARNING
"*** Dropping %pI4 (TCP), port %d\n"
,
&(iph->daddr), port);
return
NF_DROP;
}
}
return
NF_ACCEPT;
After inserting the module to the kernel, students should run
ping 10.9.0.1
and
telnet
10.9.0.1
from
10.9.0.5
. Students should provide screenshots demonstrating that the packet
filter works as expected by showing outputs from the
/var/log/syslog
file using
dmesg
and
showing that the see that the packets were dropped. Students should also show that traffic to
other IP addresses was not affected.
*Important Note*
Since you are making changes to the kernel, there is a high chance that you
might crash the kernel. Make sure you back up your files frequently, so you don’t lose them. One
of the common reasons for a system crash is that you forget to unregister hooks. When a module is
removed, these hooks will still be triggered, but the module is no longer present in the kernel. That
will cause system crash. To avoid this, make sure for each hook you add to your module, add a line
in
removeFilter
to unregister it, so when the module is removed, those hooks are also removed.
Page 16 of 24
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
Problem 2
[10 points]
Protecting the Router:
In the previous problem, you built a simple firewall using
Netfilter
.
Actually, Linux already has a built-in firewall, also based on
Netfilter
. This firewall is called
iptables
.
Technically, the kernel part implementation of the firewall is called
Xtables
, while
iptables
is a
user-space program to configure the firewall.
However,
iptables
is often used to refer to both the
kernel-part implementation and the user-space program.
Details of using
iptables
were provided in
Section
3.3
.
Consider the network setup in Figure
1
. In this problem, you need to set up rules to prevent outside
machines from accessing the router machine, except
ping
.
Please execute the following
iptables
command on the router container, and then try to access it from
10.9.0.5
.
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
iptables -P OUTPUT DROP
// Set default rule for OUTPUT
iptables -P INPUT DROP
// Set default rule for INPUT
(a) [4 points] Describe the purpose of each of the firewall rules given in the problem description.
Solution:
Award 1 point for a description of each rule (4 points total).
The purpose of each rule should be described as follows:
1. The first rule allows incoming echo request.
2. The second rule allows the echo reply to go out.
3. The third rule drops all incoming packets.
4. The fourth rule drops all the outgoing packets.
(b) [3 points] Can you
ping
the router? Explain why or why not.
Solution:
Award 1 point clearly stating that you can still
ping
the router. Award 2 points for
a description of how the rules achieve the firewall’s goal.
We can
ping
the router because the first and second rule allow ICMP packets.
(c) [3 points] Can you
telnet
into the router?. Explain why or why not.
NOTE
: A
telnet
server is running on all the containers; an account called
seed
was created on
them with a password
dees
Solution:
Award 1 point clearly stating that you cannot
telnet
into the router.
Award 2
points for a description of how the rules achieve the firewall’s goal.
We cannot
telnet
into the router because the third and fourth rules block all other packets.
Without them, packets that do not satisfy the first and second rules will not be dropped; they
will continue their journeys. These two rules make sure that once they reach the end of their
journeys on these chains, they will be dropped.
Cleanup
Before moving on to the next problem, please restore the
filter
table to its original
state by running the following commands:
iptables -F
iptables -P OUTPUT ACCEPT
iptables -P INPUT ACCEPT
Page 17 of 24
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
Another way to restore the states of all the tables is to restart the container. You can do it using
the following command (you need to find the container’s ID first):
$ docker restart <Container ID>
Problem 3
[10 points]
Protecting the Internal Network:
In this problem, you need to set up firewall rules on the router
to protect the internal network
192.168.60.0/24
. You can use the
FORWARD
chain for this purpose.
The directions of packets in the
INPUT
and
OUTPUT
chains are clear: packets are either coming into (for
INPUT
) or going out (for
OUTPUT
). This is not true for the
FORWARD
chain, because it is bi-directional:
packets going into the internal network or going out to the external network all go through this chain. To
specify the direction, we can add the interface options using
-i xyz
(coming in from the
xyz
interface)
and/or
-o xyz
(going out from the
xyz
interface). The interfaces for the internal and external networks
are different. You can find out the interface names via the
ip addr
command (you should do this on
the router).
In this problem, you want to implement a firewall to protect the internal network. More specifically, we
need to enforce the following restrictions on the ICMP traffic:
1. External hosts cannot
ping
internal hosts.
2. External hosts can
ping
the router.
3. Internal hosts can
ping
external hosts.
4. All other packets between the internal and external networks should be blocked.
You will need to use the
-p icmp
option to specify the match options related to the ICMP protocol. You
can run
iptables -p icmp -h
to find out all the ICMP match options. The following example drops
the ICMP echo request.
iptables -A FORWARD -p icmp --icmp-type echo-request -j DROP
In your assignment report, please include your rules and screenshots to demonstrate that your firewall
works as expected. When you are done with this problem, please remember to clean the table or restart
the container before moving on to the next problem.
Solution:
Award 1 point for each firewall rule to achieve the desired behaviour (4 points total).
Award 6 points for demonstrating that the firewall is working as expected with appropriate screenshots.
Students should have sufficient information to demonstrate each rule is working as expected.
The following rules assume a setup where
eth0
is the interface connecting to the external network
and
eth1
is the interface connecting to the internal network. Students need to double-check this in
their own setup.
iptables -A FORWARD -i eth0 -p icmp --icmp-type echo-request -j DROP
iptables -A FORWARD -i eth1 -p icmp --icmp-type echo-request -j ACCEPT
iptables -A FORWARD -p icmp --icmp-type echo-reply -j ACCEPT
iptables -P FORWARD DROP
Since we add these rules to the
FORWARD
chain, only the packets passing through the router will be
affected. Packets going inside the router or those created by the router will not be affected.
Students should provide screenshots demonstrating that the firewall works as expected.
Before
setting these rules, students should be able to
ping
the router and internal hosts from
10.9.0.5
.
After setting the rules, students should still be able to
ping
the router, but not the internal hosts.
From the internal hosts, students should be able to
ping 10.9.0.5
.
Page 18 of 24
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
Problem 4
[10 points]
Protecting the Internal Servers:
In this problem, you need to protect the TCP servers inside the
internal network (
192.168.60.0/24
). More specifically, you need to achieve the following objectives.
1. All the internal hosts run a telnet server (listening to port
23
). External hosts can only access the
telnet
server on
192.168.60.5
, not the other internal hosts.
2. External hosts cannot access other internal servers.
3. Internal hosts can access all the internal servers.
4. Internal hosts cannot access external servers.
5. In this problem, the connection tracking mechanism is not allowed; it will be used in a later in
Problems 5 and 6.
You will need to use the
-p tcp
option to specify the match options related to the TCP protocol. You
can run
iptables -p tcp -h
to find out all the TCP match options. The following example allows the
TCP packets coming from the interface
eth0
if their source port is
5000
.
iptables -A FORWARD -i eth0 -p tcp --sport 5000 -j ACCEPT
When you are done with this problem, please remember to clean the table or restart the container before
moving on to the next problem.
Solution:
Award 2 points for each firewall rule to achieve the desired behaviour (6 points total).
Award 4 points for demonstrating that the firewall is working as expected with appropriate screenshots.
Students should have sufficient information to demonstrate each rule is working as expected.
The following rules assume a setup where
eth0
is the interface connecting to the external network
and
eth1
is the interface connecting to the internal network. Students need to double-check this in
their own setup.
iptables -A FORWARD -i eth0 -d 192.168.60.5 -p tcp --dport 23 -j ACCEPT
iptables -A FORWARD -i eth1 -s 192.168.60.5 -p tcp --sport 23 -j ACCEPT
iptables -P FORWARD DROP
The first two rules allow the
telnet
traffic from and to
192.168.60.5
. The third rules block all
other traffic from both directions. Students may alternatively want to only block TCP traffic, in
which case the third rule can be replaced with the following rules (
either solution should be awarded
the 2 points
):
iptables -A FORWARD -p tcp -j DROP
iptables -P FORWARD ACCEPT
Students should provide screenshots demonstrating that the firewall works as expected.
Problem 5
[10 points]
Experimenting with Connection Tracking:
In the previous problems, you have only set up stateless
firewalls, which inspect each packet independently. However, packets are usually not independent; they
may be part of a TCP connection, or they may be ICMP packets triggered by other packets. Treating
them independently does not take into consideration the context of the packets, and can thus lead to
inaccurate, unsafe, or complicated firewall rules. For example, if you would like to allow TCP packets to
get into our network only if a connection was made first, you cannot achieve that easily using stateless
packet filters, because when the firewall examines each individual TCP packet, it has no idea whether
the packet belongs to an existing connection or not, unless the firewall maintains some state information
for each connection. If it does that, it becomes a
stateful firewall
.
Page 19 of 24
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
To support stateful firewalls, you need to be able to track connections. This is achieved by the
conntrack
mechanism inside the kernel. In this problem, you will conduct experiments related to
conntrack
, and get
familiar with the connection tracking mechanism. In the experiments, you should check the connection
tracking information on the router container. This can be done using the following command:
conntrack -L
The goal of the problem is to use a series of experiments to help you understand the connection concept
in this tracking mechanism, especially for the ICMP and UDP protocols, because unlike TCP, they do
not have connections. Please conduct the following experiments. For each experiment, please explain
how you conducted your experiment, and describe and explain your observations.
(a) [3 points]
ICMP
: Run the following command and check the connection tracking information on
the router. Describe your observations. How long is the ICMP connection state to be kept?
// On 10.9.0.5, send out ICMP packets
ping 192.168.60.5
Solution:
Award 1 point for describing the commands used to conduct the experiment. Award 2
points for describing the observations and indicating the time the ICMP connection state is to
be kept.
Students are expected to describe their experiment and explain the output of the connection
track entry.
The explanations should follow similarly to what is provided in Section
3.4
.
Students may have different responses depending on the output of the connection tracking entry.
(b) [3 points]
UDP
: Run the following command and check the connection tracking information on
the router. Describe your observation. How long is the UDP connection state to be kept?
// On 192.168.60.5, start a netcat UDP server
nc -lu 9090
// On 10.9.0.5, send out UDP packets
nc -u 192.168.60.5 9090
<type something, then hit return>
Solution:
Award 1 point for describing the commands used to conduct the experiment. Award 2
points for describing the observations and indicating the time the UDP connection state is to
be kept.
Students are expected to describe their experiment and explain the output of the connection
track entry.
The explanations should follow similarly to what is provided in Section
3.4
.
Students may have different responses depending on the output of the connection tracking entry.
(c) [4 points]
TCP
: Run the following command and check the connection tracking information on the
router. Describe your observation. How long is the TCP connection state to be kept?
// On 192.168.60.5, start a netcat TCP server
nc -l 9090
// On 10.9.0.5, send out TCP packets
nc 192.168.60.5 9090
<type something, then hit return>
Page 20 of 24
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
Solution:
Award 1 point for describing the commands used to conduct the experiment. Award 3
points for describing the observations and indicating the time the TCP connection state is to
be kept.
Students are expected to describe their experiment and explain the output of the connection
track entry.
The explanations should follow similarly to what is provided in Section
3.4
.
Students may have different responses depending on the output of the connection tracking entry.
Problem 6
[10 points]
Setting Up a Stateful Firewall:
Now you are ready to set up firewall rules based on connections.
In the following example, the
-m conntrack
option indicates that we are using the
conntrack
module,
which is a very important module for
iptables
; it tracks connections, and
iptables
replies on the
tracking information to build stateful firewalls. The
–ctsate ESTABLISHED,RELATED
indicates whether
a packet belongs to an
ESTABLISHED
or
RELATED
connection. The rule allows TCP packets belonging to
an existing connection to pass through.
iptables -A FORWARD -p tcp -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
The rule above does not cover the SYN packets, which do not belong to any established connection.
Without it, you will not be able to create a connection in the first place. Therefore, you need to add a
rule to accept incoming SYN packet:
iptables -A FORWARD -p tcp -i eth0 --dport 8080 --syn -m conntrack \
--ctstate NEW -j ACCEPT
Finally, you need to set the default policy on
FORWARD
to drop everything. This way, if a packet is not
accepted by the two rules above, they will be dropped.
iptables -P FORWARD DROP
Please rewrite the firewall rules in Problem 4, but this time,
add a rule allowing internal hosts
to visit any external server
(this was not allowed in Problem 4).
After you write the rules using
the connection tracking mechanism, think about how to do it without using the connection tracking
mechanism (you do not need to actually implement them). Based on these two sets of rules, compare
these two different approaches, and explain the advantage and disadvantage of each approach. When you
are done with this problem, please remember to clean the table or restart the container before moving
on to the next problem.
Solution:
Award 1 point for each firewall rule to achieve the desired behaviour (4 points total).
Award 3 points for demonstrating that the firewall is working as expected with appropriate screenshots.
Students should have sufficient information to demonstrate each rule is working as expected. Award 3
points for a comparison of the two different approaches, explaining the advantages and disadvantages
of each.
The following rules assume a setup where
eth0
is the interface connecting to the external network
and
eth1
is the interface connecting to the internal network. Students need to double-check this in
their own setup.
iptables -A FORWARD -i eth0 -d 192.168.60.5 -p tcp --dport 23 --syn -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --syn -j ACCEPT
iptables -A FORWARD -p tcp -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -p tcp -j DROP
iptables -P FORWARD ACCEPT
Page 21 of 24
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
The first rule allows the SYN packet to
192.168.60.5
’s telnet server. The second rule allows the
SYN packet from the internal network to the external network. The third rule allows all the TCP
packets that belong to an existing connection. The fourth and fifth rules depend on the solution to
Problem 4 and either block all other traffic from both directions or only block TCP traffic.
Students should provide screenshots demonstrating that the firewall works as expected.
Comparing the two sets of firewall rules (from Problem 4 and here), it seems that they are similar,
but the third rule in the stateless firewall allows more traffic than the one in the stateful firewall: it
allows all TCP traffic, while in the stateful firewall, only the TCP traffic that belongs to an existing
connection is allowed. This is just one of the advantages. The disadvantage of the stateful firewall
is the resource consumption. Maintaining state information requires more time and more memory.
Students may have different responses for the advantages and disadvantages and points should be
awarded for any reasonable response.
Problem 7
[10 points]
Limiting Network Traffic:
In addition to blocking packets, you can also limit the number of packets
that can pass through the firewall.
This can be done using the
limit
module of
iptables
.
In this
problem, you will use this module to limit how many packets from
10.9.0.5
are allowed to get into the
internal network. You can use
iptables -m limit -h
to see the manual.
$ iptables -m limit -h
limit match options:
--limit avg
max average match rate:
default
3/hour
[Packets per second unless followed by
/sec /minute /hour /day postfixes]
--limit-burst number
number to match in a burst,
default
5
(a) [5 points] Run the following commands on the router, and then
ping 192.168.60.5
from
10.9.0.5
.
Please explain how you conducted your experiment, and describe and explain your observations.
iptables -A FORWARD -s 10.9.0.5 -m limit --limit 10/minute \
--limit-burst 6 -j ACCEPT
iptables -A FORWARD -s 10.9.0.5 -j DROP
Solution:
Award 1 point for describing the experiment setup. Award 1 point for provide the
results of the
ping
. Award 3 points for an adequate discussion of the results.
Students are expected to follow the problem description and set the provided rules.
Student should describe their observations. For example, from the following results, we can see
that the first 6 ICMP packets all passed the firewall, and then after that, the rate is reduced to
1 in every 6 seconds, which is equivalent to 10 per minute. This can be seen in the
icmp_seq
.
// From ping from 10.9.0.5
#
ping 192.168.60.5
PING 192.168.60.5 (192.168.60.5) 56(84) bytes of data.
64 bytes from 192.168.60.5: icmp_seq=1 ttl=63 time=0.069 ms
64 bytes from 192.168.60.5: icmp_seq=2 ttl=63 time=0.058 ms
64 bytes from 192.168.60.5: icmp_seq=3 ttl=63 time=0.058 ms
64 bytes from 192.168.60.5: icmp_seq=4 ttl=63 time=0.116 ms
64 bytes from 192.168.60.5: icmp_seq=5 ttl=63 time=0.059 ms
64 bytes from 192.168.60.5: icmp_seq=6 ttl=63 time=0.061 ms
Page 22 of 24
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
64 bytes from 192.168.60.5: icmp_seq=7 ttl=63 time=0.060 ms
64 bytes from 192.168.60.5: icmp_seq=13 ttl=63 time=0.058 ms
64 bytes from 192.168.60.5: icmp_seq=19 ttl=63 time=0.064 ms
64 bytes from 192.168.60.5: icmp_seq=25 ttl=63 time=0.104 ms
64 bytes from 192.168.60.5: icmp_seq=31 ttl=63 time=0.072 ms
64 bytes from 192.168.60.5: icmp_seq=37 ttl=63 time=0.083 ms
(b) [5 points] Please conduct the experiment from Part (a) without the second rule.
Please explain
how you conducted your experiment, and describe and explain your observations. Explain whether
the second rule is needed or not, and why.
Solution:
Award 1 point for describing the experiment setup. Award 1 point for providing the
results of the
ping
. Award 3 points for an adequate discussion of the results.
The second rule is important. The packets not accepted by the first rule will not be dropped,
they will just continue their journey.
If nobody drops them, then they will eventually be
accepted as well (we will notice this in the
icmp_seq
). This is why we need to add the second
rule to drop everything that is selected.
Page 23 of 24
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
SYSC 4810 — Module 4
Assignment
Due Date: November 14, 2021
Part IV
Summary of Findings
1
Reminder: Obligations
You are required to deliver the following information and outcomes to your supervisor:
1. Provide a detailed report documenting each of your experiments and findings.
This is necessary
to enable your supervisor to make important decisions about how best to proceed with the project
proposal and to demonstrate that you have been thorough in your investigation.
2. Provide a summary of your findings including a discussion of alternative choices and potential
challenges, issues and opportunties addressing each of the concerns mentioned in the email from
your supervisor. Include any necessary recommendations based on your findings.
2
Problems and Tasks
Problem 8
[10 points]
Recommendations:
Write a summary of your findings and recommendations. Write this summary
as if you are going to submit it to your supervisor at
GlobalTech Solutions
. This means that it should
be clear and concise. It should address all of the needs and concerns of your supervisor outlined in the
email message and the obligations above.
HINT:
You may want to refer to specific observations from your experiments obtained in the rest of
the problems in this assignment to justify your recommendations.
Solution:
Award 5 points for each suitable summary of the findings. Award 3 points for a discussion
of alternative choices and potential challenges, issues and opportunties. Award 2 points for suitable
recommendations.
Students may have many different answers. Points should be awarded for reasonable summary of
their findings that are supported by experimental results and that are justified.
END OF ASSIGNMENT
Page 24 of 24
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Documents
Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage

Principles of Information Systems (MindTap Course...
Computer Science
ISBN:9781285867168
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning

Fundamentals of Information Systems
Computer Science
ISBN:9781337097536
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning

Principles of Information Systems (MindTap Course...
Computer Science
ISBN:9781305971776
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning

Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:CengagePrinciples of Information Systems (MindTap Course...Computer ScienceISBN:9781285867168Author:Ralph Stair, George ReynoldsPublisher:Cengage Learning
- Fundamentals of Information SystemsComputer ScienceISBN:9781337097536Author:Ralph Stair, George ReynoldsPublisher:Cengage LearningPrinciples of Information Systems (MindTap Course...Computer ScienceISBN:9781305971776Author:Ralph Stair, George ReynoldsPublisher:Cengage LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage

Principles of Information Systems (MindTap Course...
Computer Science
ISBN:9781285867168
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning

Fundamentals of Information Systems
Computer Science
ISBN:9781337097536
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning

Principles of Information Systems (MindTap Course...
Computer Science
ISBN:9781305971776
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning

Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning