\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{nhatlong0605} \pdfinfo{ /Title (lfcs-module3-networking.pdf) /Creator (Cheatography) /Author (nhatlong0605) /Subject (LFCS\_Module3\_Networking 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}{34A327} \definecolor{LightBackground}{HTML}{F2F9F1} \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{LFCS\_Module3\_Networking Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{nhatlong0605} via \textcolor{DarkBackground}{\uline{cheatography.com/68292/cs/17207/}}} \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}nhatlong0605 \\ \uline{cheatography.com/nhatlong0605} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 24th September, 2018.\\ Updated 13th November, 2018.\\ 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{multicols*}{3} \begin{tabularx}{5.377cm}{x{2.58804 cm} x{2.38896 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Persistent Network Config in CentOS}} \tn % Row 0 \SetRowColor{LightBackground} nmcli & Network Manager command line \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} nmtui & network Manger graphical \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} nmcli connection up ens33 & Switch on ens33 interface \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{/etc/sysconfig/network-scripts} & Config file \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.9954 cm} x{3.9816 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Common Network Tools}} \tn % Row 0 \SetRowColor{LightBackground} dig & Verify DNS relay \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} nmap & Scanning ports \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{iptables Syntax}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{iptables \{-A|I\} chain {[}-i/o iface{]} {[}-s/d ipaddr{]} {[}-p udp/tcp/icmp{[}-{}-dport/sport nn...{]}{]} -j {[}LOG|ACCEPT|DROP|REJECT{]} \newline \newline -A|I: Append or Insert \newline -i/o: INPUT or OUTPUT chain \newline -s/d: source IP or destination IP \newline -p udp/tcp/icmp: protocol to use \newline -{}-dport/sport nn: destination port or source port \newline -j LOG|ACCEPT|DROP|REJECT: Write line to syslog or Accept or Drop silently (external traffic) or reject non-silently (internal traffic)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.4931 cm} x{3.4839 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Configuring Local time}} \tn % Row 0 \SetRowColor{LightBackground} hwclock & Display kernel hardware clock \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} hwclock -{}-systohc & Synchronise system tim to hardware time \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} hwclock -{}-hctosys & Synchronise hardware clock to system \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} timedatectl & Utilitiy to config time \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{NTPD and Chronyd}} \tn % Row 0 \SetRowColor{LightBackground} vim /etc/ntp.conf & Config file; Server {\emph{server name}} iburst \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} systemctl restart ntpd & Restart NTP service \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} ntpq -p & Show current time info \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} systemctl status chrony & Show current status of chrony \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} vim /etc/chrony.conf & Chrony config file \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} chronyc sources & Current time server status \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} chrony tracking & Current chrony tracking status \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} iptables -A INPUT -p udp -{}-dport 123 -j ACCEPT & Allow traffic to time server \tn % Row Count 16 (+ 3) % Row 8 \SetRowColor{LightBackground} iptables -A OUTPUT -p udp -{}-dport 123 -j ACCEPT & // \tn % Row Count 19 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.53367 cm} x{1.44333 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{IP Traffic Route}} \tn % Row 0 \SetRowColor{LightBackground} route -n & IP routing table \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} ip route list & List of ip route \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} ip route add 8.8.0.0/16 proto static metric 10 via inet 10.9.185.143 dev eth0 & Add new IP route \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} ip route del 8.8.0.0/16 proto static metric 10 via inet 10.9.185.143 dev eth0 & Delete IP route \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Firewalld}} \tn % Row 0 \SetRowColor{LightBackground} firewall-cmd -{}-list-all & Show current firewall configuration \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} firewall-cmd -{}-get-services & Show current services on Firewall \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{/usr/lib/firewalld/services} & List of services config file \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} firewall-cmd -{}-add-service samba -{}-permanent & Add Samba service to Firewall persistently \tn % Row Count 9 (+ 3) % Row 4 \SetRowColor{LightBackground} firewall-cmd -{}-add-port 4000-4005/tcp -{}-permanent & Add port 4000-4005 on TCP persistently \tn % Row Count 12 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.53827 cm} x{2.43873 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{SSH}} \tn % Row 0 \SetRowColor{LightBackground} vim \seqsplit{/etc/ssh/sshd\_config} & Config file for SSH Daemon (SSH server) \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} vim \seqsplit{/etc/ssh/ssh\_config} & Config file for SSH Client \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} systemctl status sshd & Current status of process \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} systemctl enable sshd & Start SSH at boot \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} ssh -X {\emph{user@ip}} & SSH with graphical application \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} ssh-keygen & Generating public and private key \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} scp /etc/hosts 192.168.4.240:/tmp (vice versa) & Copy /etc/hosts over SSH to /tmp \tn % Row Count 16 (+ 3) % Row 7 \SetRowColor{white} rsync -avz /tmp \seqsplit{student@192.168.4.240:/tmp} & Rsync from host to remote \tn % Row Count 19 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Config static network}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{vim \seqsplit{/etc/network-scripts/ifcfg-eht0} \newline BOOTPROTO=none \newline IPADDR=192.168.0.222 \newline PREFIX=24 \newline GATEWAY=192.168.0.1 \newline DNS1=8.8.8.8 \newline \newline systemctl restart network} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.74195 cm} x{3.23505 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Hostname}} \tn % Row 0 \SetRowColor{LightBackground} vim /etc/hostname & Hostname config file \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} hostnamectl & Tool for setting hostname \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} vim /etc/hosts & Local resolving of hostname \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} vim \seqsplit{/etc/resolv.conf} & DNS config file \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} vim \seqsplit{/etc/nsswitch.conf} & Specify which config file to be processed \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Firewall using iptables}} \tn % Row 0 \SetRowColor{LightBackground} systemctl stop firewalld & Stop Firewalld \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} iptables -L -v & List iptables policy verbosely \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} iptables -P INPUT(OUTPUT) DROP & Set INPUT(OUTPUT) to DROP \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} iptables -A INPUT -i lo -j ACCEPT & Allow incoming traffic to loopback interface \tn % Row Count 9 (+ 3) % Row 4 \SetRowColor{LightBackground} iptables -A OUTPUT -o lo -j ACCEPT & Allow outgoing traffic to loopback interface \tn % Row Count 12 (+ 3) % Row 5 \SetRowColor{white} iptables -A INPUT -p tcp -{}-dport 22 -j ACCEPT & Allow packet through port on TCP going to system \tn % Row Count 15 (+ 3) % Row 6 \SetRowColor{LightBackground} iptables -A OUTPUT -m state -{}-state ESTABLISHED, RELATED -j ACCEPT & Allow all old to get out of system; doesn't all new traffic \tn % Row Count 19 (+ 4) % Row 7 \SetRowColor{white} iptables -A OUTPUT -p tcp -{}-dport 22 -j ACCEPT & // \tn % Row Count 22 (+ 3) % Row 8 \SetRowColor{LightBackground} iptables -A INPUT -m state -{}-state ESTABLISHED, RELATED -j ACCEPT & // \tn % Row Count 26 (+ 4) % Row 9 \SetRowColor{white} iptables -A OUTPUT -p tcp -{}-dport 80 -j ACCEPT & Allow TCP traffic going out through port 80 \tn % Row Count 29 (+ 3) % Row 10 \SetRowColor{LightBackground} iptables -A OUTPUT -p udp -{}-dport 53 -j ACCEPT & Allow traffic going out through DNS (port 53) \tn % Row Count 32 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Firewall using iptables (cont)}} \tn % Row 11 \SetRowColor{LightBackground} iptables-save \textgreater{} \seqsplit{/etc/sysconfig/iptables} & Save iptables to start automatically at boot \tn % Row Count 3 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}