Hello, I am struggling with this assignment. I have a Ubuntu VM built out in AWS and i got a firewall shell script built out and ran on the server. But this instructor calls for testing inbound connection, like web, email, etc. How do I test this if it's just a plain Ubuntu build, no desktop? After that he wants us to modify the script to allow just SSH, HTTP and HTTPS and test those connections TO the machine. How do I do this? Did I set this firewall script up correctly? And how do I test steps 2 and 3 for just a plain jane Ubuntu command line only server? Install and configure a Linux operating system (e.g. Ubuntu, Fedora, Debian) on a virtual machine or physical machine. --> You can use an EC2 instance in AWS or DigitalOcean. Install the iptables firewall tool using the package manager of the Linux operating system you installed in step 1 (e.g. sudo apt-get install iptables for Ubuntu). 1. Create a firewall script that blocks all incoming traffic except for incoming SSH connections --> You need to research this part. Save the firewall script and make it executable (e.g. chmod +x firewall.sh). 2. Run the firewall script to activate the firewall and confirm that the firewall is working by attempting to connect to the machine using various services (e.g. web, email, etc.). --> Need to document testing this step 3. Modify the firewall script to allow incoming traffic for specific services (e.g. HTTP, HTTPS) and confirm that these services are now accessible from the Internet --> Need to document testing this step. FIREWALL.SH script: #!/usr/bin/bash # Flush all current iptables rules iptables -F # Set default policies to drop all incoming and forward traffic iptables -P INPUT DROP iptables -P FORWARD DROP # Allow all outgoing traffic iptables -P OUTPUT ACCEPT # Allow incoming SSH traffic iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT # Allow incoming HTTP traffic iptables -A INPUT -p tcp --dport 80 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp --sport 80 -m conntrack --ctstate ESTABLISHED -j ACCEPT # Allow incoming HTTPS traffic iptables -A INPUT -p tcp --dport 443 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp --sport 443 -m conntrack --ctstate ESTABLISHED -j ACCEPT # Save the new iptables rules iptables-save > /etc/iptables/rules.v4
Hello,
I am struggling with this assignment. I have a Ubuntu VM built out in AWS and i got a firewall shell script built out and ran on the server. But this instructor calls for testing inbound connection, like web, email, etc. How do I test this if it's just a plain Ubuntu build, no desktop? After that he wants us to modify the script to allow just SSH, HTTP and HTTPS and test those connections TO the machine. How do I do this? Did I set this firewall script up correctly? And how do I test steps 2 and 3 for just a plain jane Ubuntu command line only server?
Install and configure a Linux
1. Create a firewall script that blocks all incoming traffic except for incoming SSH connections --> You need to research this part.
Save the firewall script and make it executable (e.g. chmod +x firewall.sh).
2. Run the firewall script to activate the firewall and confirm that the firewall is working by attempting to connect to the machine using various services (e.g. web, email, etc.). --> Need to document testing this step
3. Modify the firewall script to allow incoming traffic for specific services (e.g. HTTP, HTTPS) and confirm that these services are now accessible from the Internet --> Need to document testing this step.
FIREWALL.SH script:
#!/usr/bin/bash
# Flush all current iptables rules
iptables -F
# Set default policies to drop all incoming and forward traffic
iptables -P INPUT DROP
iptables -P FORWARD DROP
# Allow all outgoing traffic
iptables -P OUTPUT ACCEPT
# Allow incoming SSH traffic
iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT
# Allow incoming HTTP traffic
iptables -A INPUT -p tcp --dport 80 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 80 -m conntrack --ctstate ESTABLISHED -j ACCEPT
# Allow incoming HTTPS traffic
iptables -A INPUT -p tcp --dport 443 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 443 -m conntrack --ctstate ESTABLISHED -j ACCEPT
# Save the new iptables rules
iptables-save > /etc/iptables/rules.v4
Step by step
Solved in 3 steps