Skip to Content
Mastering Linux Security and Hardening
book

Mastering Linux Security and Hardening

by Donald A. Tevault
January 2018
Intermediate to advanced
376 pages
8h 45m
English
Packt Publishing
Content preview from Mastering Linux Security and Hardening

Hands-on lab for basic iptables usage

You'll do this lab on your Ubuntu virtual machine.

  1. Shut down your Ubuntu virtual machine, and create a snapshot. 
You'll roll back to this snapshot for the lab in the next section.
  1. Look at your iptables rules, or lack thereof, with:
        sudo iptables -L
  1. Create the rules that you need for a basic firewall, allowing for Secure Shell access but denying everything else:
        sudo iptables -A INPUT -m conntrack                                       --ctstate ESTABLISHED,RELATED                      -j ACCEPT        sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT        sudo iptables -A INPUT -j DROP
  1. View the results with:
        sudo iptables -L
  1. Oops, it looks like you forgot about that loopback interface. Add a rule for it at the top of the list:
 sudo iptables -I INPUT 1 -i ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Security and Hardening, The Practical Security Guide

Linux Security and Hardening, The Practical Security Guide

Jason Cannon
Mastering Linux Administration

Mastering Linux Administration

Alexandru Calcatinge, Julian Balog

Publisher Resources

ISBN: 9781788620307Other