\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Mikaël LE BERRE (mikael.leberre)} \pdfinfo{ /Title (firewall-cmd.pdf) /Creator (Cheatography) /Author (Mikaël LE BERRE (mikael.leberre)) /Subject (firewall-cmd Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{3D8CDB} \definecolor{LightBackground}{HTML}{F2F7FC} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{firewall-cmd Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Mikaël LE BERRE (mikael.leberre)} via \textcolor{DarkBackground}{\uline{cheatography.com/113443/cs/21731/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Mikaël LE BERRE (mikael.leberre) \\ \uline{cheatography.com/mikael-leberre} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 4th February, 2020.\\ Updated 25th February, 2020.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Initial information}} \tn % Row 0 \SetRowColor{LightBackground} Get the status of firewalld & firewall-cmd -{}-state \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Reload the firewall & firewall-cmd -{}-reload \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} List of all supported zones & firewall-cmd -{}-get-zones \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} List of all supported services & firewall-cmd -{}-get-services \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} List of all supported icmptypes & firewall-cmd -{}-get-icmptypes \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} List all zones with the enabled features & firewall-cmd -{}-list-all-zones \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} Print zone with the enabled features & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-list-all \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} Get the default zone & firewall-cmd -{}-get-default-zone \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} Set the default zone & firewall-cmd -{}-set-default-zone=\textless{}zone\textgreater{} \tn % Row Count 18 (+ 2) % Row 9 \SetRowColor{white} Get active zones & firewall-cmd -{}-get-active-zones \tn % Row Count 20 (+ 2) % Row 10 \SetRowColor{LightBackground} Get zone related to an interface & firewall-cmd -{}-get-zone-of-interface=\textless{}interface\textgreater{} \tn % Row Count 23 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.4623 cm} x{8.8077 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Interface}} \tn % Row 0 \SetRowColor{LightBackground} Add an interface to a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-add-interface=\textless{}interface\textgreater{} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Change the zone an interface belongs to & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-change-interface=\textless{}interface\textgreater{} \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} Remove an interface from a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-remove-interface=\textless{}interface\textgreater{} \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} Query if an interface is in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-query-interface=\textless{}interface\textgreater{} \tn % Row Count 12 (+ 3) % Row 4 \SetRowColor{LightBackground} List the enabled services in a zone & firewall-cmd {[} -{}-zone=\textless{}zone\textgreater{} {]} -{}-list-services \tn % Row Count 15 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.4623 cm} x{8.8077 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Service}} \tn % Row 0 \SetRowColor{LightBackground} Enable a service in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-add-service=\textless{}service\textgreater{} {[}-{}-timeout=\textless{}seconds\textgreater{}{]} \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} Disable a service in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-remove-service=\textless{}service\textgreater{} \tn % Row Count 7 (+ 3) % Row 2 \SetRowColor{LightBackground} Query if a service is enabled in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-query-service=\textless{}service\textgreater{} \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.4623 cm} x{8.8077 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Source}} \tn % Row 0 \SetRowColor{LightBackground} Enable a source in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-add-source=\textless{}address\textgreater{} {[}-{}-timeout=\textless{}seconds\textgreater{}{]} \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} Disable a source in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-remove-source=\textless{}address\textgreater{} \tn % Row Count 7 (+ 3) % Row 2 \SetRowColor{LightBackground} Query if a source is enabled in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-query-source=\textless{}address\textgreater{} \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.2534 cm} x{10.0166 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{ICMP}} \tn % Row 0 \SetRowColor{LightBackground} Enable ICMP blocks in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-add-icmp-block=\textless{}icmptype\textgreater{} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Disable ICMP blocks in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-remove-icmp-block=\textless{}icmptype\textgreater{} \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} Query ICMP blocks in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-query-icmp-block=\textless{}icmptype\textgreater{} \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} {\bf{Example:}} & firewall-cmd -{}-zone=public -{}-add-icmp-block=echo-reply \tn % Row Count 12 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{port and protocol combination}} \tn % Row 0 \SetRowColor{LightBackground} Enable a port and protocol combination in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-add-port=\textless{}port\textgreater{}{[}-\textless{}port\textgreater{}{]}/\textless{}protocol\textgreater{} {[}-{}-timeout=\textless{}seconds\textgreater{}{]} \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} Disable a port and protocol combination in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-remove-port=\textless{}port\textgreater{}{[}-\textless{}port\textgreater{}{]}/\textless{}protocol\textgreater{} \tn % Row Count 9 (+ 4) % Row 2 \SetRowColor{LightBackground} Query if a port and protocol combination in enabled in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-query-port=\textless{}port\textgreater{}{[}-\textless{}port\textgreater{}{]}/\textless{}protocol\textgreater{} \tn % Row Count 13 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{port forwarding or port mapping}} \tn % Row 0 \SetRowColor{LightBackground} Enable port forwarding or port mapping in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-add-forward-port=port=\textless{}port\textgreater{}{[}-\textless{}port\textgreater{}{]}:proto=\textless{}protocol\textgreater{} \{ :toport=\textless{}port\textgreater{}{[}-\textless{}port\textgreater{}{]} | :toaddr=\textless{}address\textgreater{} | :toport=\textless{}port\textgreater{}{[}-\textless{}port\textgreater{}{]}:toaddr=\textless{}address\textgreater{} \} \tn % Row Count 9 (+ 9) % Row 1 \SetRowColor{white} Disable port forwarding or port mapping in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-remove-forward-port=port=\textless{}port\textgreater{}{[}-\textless{}port\textgreater{}{]}:proto=\textless{}protocol\textgreater{} \{ :toport=\textless{}port\textgreater{}{[}-\textless{}port\textgreater{}{]} | :toaddr=\textless{}address\textgreater{} | :toport=\textless{}port\textgreater{}{[}-\textless{}port\textgreater{}{]}:toaddr=\textless{}address\textgreater{} \} \tn % Row Count 18 (+ 9) % Row 2 \SetRowColor{LightBackground} Query port forwarding or port mapping in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-query-forward-port=port=\textless{}port\textgreater{}{[}-\textless{}port\textgreater{}{]}:proto=\textless{}protocol\textgreater{} \{ :toport=\textless{}port\textgreater{}{[}-\textless{}port\textgreater{}{]} | :toaddr=\textless{}address\textgreater{} | :toport=\textless{}port\textgreater{}{[}-\textless{}port\textgreater{}{]}:toaddr=\textless{}address\textgreater{} \} \tn % Row Count 27 (+ 9) % Row 3 \SetRowColor{white} {\bf{Example:}} & firewall-cmd -{}-zone=home -{}-add-forward-port=port=22:proto=tcp:toaddr=127.0.0.2 \tn % Row Count 31 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Permanent}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{The permanent options are not affecting runtime directly. These options are only available after a reload or restart. To have runtime and permanent setting, you need to supply both. The {\bf{–permanent}} option needs to be the first option for all permanent calls.% Row Count 6 (+ 6) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{6.7353 cm} x{10.5347 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{panic mode}} \tn % Row 0 \SetRowColor{LightBackground} Enable panic & firewall-cmd -{}-enable-panic \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Disable panic mode & firewall-cmd -{}-disable-panic \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Query panic mode & firewall-cmd -{}-query-panic \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{Block all network traffic in case of emergency} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.4261 cm} x{9.8439 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Masquerading}} \tn % Row 0 \SetRowColor{LightBackground} Enable masquerading in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-add-masquerade \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Disable masquerading in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-remove-masquerade \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} Query masquerading in a zone & firewall-cmd {[}-{}-zone=\textless{}zone\textgreater{}{]} -{}-query-masquerade \tn % Row Count 9 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Direct options}} \tn % Row 0 \SetRowColor{LightBackground} Pass a command through to the firewall. \textless{}args\textgreater{} can be all iptables, ip6tables and ebtables command line arguments & firewall-cmd -{}-direct -{}-passthrough \{ ipv4 | ipv6 | eb \} \textless{}args\textgreater{} \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} Add a new chain \textless{}chain\textgreater{} to a table \textless{}table\textgreater{}. & firewall-cmd {[}-{}-permanent{]} -{}-direct -{}-add-chain \{ ipv4 | ipv6 | eb \} \textless{}table\textgreater{} \textless{}chain\textgreater{} \tn % Row Count 11 (+ 5) % Row 2 \SetRowColor{LightBackground} Remove a chain with name \textless{}chain\textgreater{} from table \textless{}table\textgreater{}. & firewall-cmd {[}-{}-permanent{]} -{}-direct -{}-remove-chain \{ ipv4 | ipv6 | eb \} \textless{}table\textgreater{} \textless{}chain\textgreater{} \tn % Row Count 16 (+ 5) % Row 3 \SetRowColor{white} Query if a chain with name \textless{}chain\textgreater{} exists in table \textless{}table\textgreater{}. Returns 0 if true, 1 otherwise. & firewall-cmd {[}-{}-permanent{]} -{}-direct -{}-query-chain \{ ipv4 | ipv6 | eb \} \textless{}table\textgreater{} \textless{}chain\textgreater{} \tn % Row Count 21 (+ 5) % Row 4 \SetRowColor{LightBackground} Get all chains added to table \textless{}table\textgreater{} as a space separated list. & firewall-cmd {[}-{}-permanent{]} -{}-direct -{}-get-chains \{ ipv4 | ipv6 | eb \} \textless{}table\textgreater{} \tn % Row Count 25 (+ 4) % Row 5 \SetRowColor{white} Add a rule with the arguments \textless{}args\textgreater{} to chain \textless{}chain\textgreater{} in table \textless{}table\textgreater{} with priority \textless{}priority\textgreater{}. & firewall-cmd {[}-{}-permanent{]} -{}-direct -{}-add-rule \{ ipv4 | ipv6 | eb \} \textless{}table\textgreater{} \textless{}chain\textgreater{} \textless{}priority\textgreater{} \textless{}args\textgreater{} \tn % Row Count 31 (+ 6) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Direct options (cont)}} \tn % Row 6 \SetRowColor{LightBackground} Remove a rule with the arguments \textless{}args\textgreater{} from chain \textless{}chain\textgreater{} in table \textless{}table\textgreater{}. & firewall-cmd {[}-{}-permanent{]} -{}-direct -{}-remove-rule \{ ipv4 | ipv6 | eb \} \textless{}table\textgreater{} \textless{}chain\textgreater{} \textless{}args\textgreater{} \tn % Row Count 5 (+ 5) % Row 7 \SetRowColor{white} Query if a rule with the arguments \textless{}args\textgreater{} exists in chain \textless{}chain\textgreater{} in table \textless{}table\textgreater{}. Returns 0 if true, 1 otherwise. & firewall-cmd {[}-{}-permanent{]} -{}-direct -{}-query-rule \{ ipv4 | ipv6 | eb \} \textless{}table\textgreater{} \textless{}chain\textgreater{} \textless{}args\textgreater{} \tn % Row Count 11 (+ 6) % Row 8 \SetRowColor{LightBackground} Get all rules added to chain \textless{}chain\textgreater{} in table \textless{}table\textgreater{} as a newline separated list of arguments. & firewall-cmd {[}-{}-permanent{]} -{}-direct -{}-get-rules \{ ipv4 | ipv6 | eb \} \textless{}table\textgreater{} \textless{}chain\textgreater{} \tn % Row Count 16 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{The direct options give a more direct access to the firewall. These options require user to know basic iptables concepts.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \end{document}