Server hardening and optimization for the would be node operator

Sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow _PORT_Y_NUMBER
sudo ufw allow _PORT_X_NUMBER
sudo ufw enable
sudo ufw status verbose
sudo ufw status numbered
sudo ufw delete _your_number_to_delete
Sudo ufw allow from _ip.ip.ip.ip to any port _yourport
netstat -tulpn
ss -tulpn
sudo passwd -l root
sudo passwd -u root
usermod -aG sudo your_user_name
sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
sudo apt install lynis
sudo lynis audit system
Example of a Lynis audit where the server has a way to go before we can consider it a hardened server
find /directoryto/check -type f -exec md5sum {} \; > checklist.chk
md5sum -c checklist.chk
sudo apt-get install chrony -y
# 3 sources per time servers.
pool iburst maxsources 3
pool iburst maxsources 3
pool iburst maxsources 3

keyfile /etc/chrony/chrony.keys

driftfile /var/lib/chrony/chrony.drift

logdir /var/log/chrony

maxupdateskew 10.0


# Make steps in 100ms.
makestep 0.1 3
chronyc sourcestats -v
chronyc activity
chronyc tracking
sudo apt install tuned tuned-utils tuned-utils-systemtap
sudo systemctl enable --now tuned
tuned-adm active
tuned-adm profile
sudo tuned-adm profile network-latency
# Use Google's congestion control algorithm
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
#Prevent SYN attack, enable SYNcookies (they will kick-in when the #max_syn_backlog reached)
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_max_syn_backlog = 4096
# Disables IP source routing
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
# Add if ip6 used:
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0
# Enable IP spoofing protection, turn on source route verification
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
# Disable ICMP Redirect Acceptance
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
# Enable Log Spoofed Packets, Source Routed Packets, Redirect #Packets
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.default.log_martians = 1
# Don't relay bootp
net.ipv4.conf.all.bootp_relay = 0
# Don't proxy arp for anyone
net.ipv4.conf.all.proxy_arp = 0
# Turn on the tcp_timestamps, accurate timestamp make TCP congestion # control algorithms work better
net.ipv4.tcp_timestamps = 1
# Enable ignoring broadcasts request
net.ipv4.icmp_echo_ignore_broadcasts = 1
# Enable bad error message Protection
net.ipv4.icmp_ignore_bogus_error_responses = 1
# Enable a fix for RFC1337 - time-wait assassination hazards in TCP
net.ipv4.tcp_rfc1337 = 1
# Accept packets with SRR option? No
net.ipv4.conf.all.accept_source_route = 0
# Ignore all ICMP ECHO and TIMESTAMP requests sent to it via
# broadcast/multicast

net.ipv4.icmp_echo_ignore_broadcasts = 1
# Ignore bad ICMP errors
# Prometheus : monitoring & time series db
image: prom/prometheus:latest
container_name: prometheus
restart: unless-stopped
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--web.enable-lifecycle'
- 9090:9090
# Node-exporter : Monitoring host metrics
image: prom/node-exporter:latest
container_name: node-exporter
restart: unless-stopped
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
- 9100:9100
scrape_interval: 1m
- job_name: "prometheus"
scrape_interval: 1m
- targets: ["localhost:9090"]
- job_name: "node"



-- 0100000101000100010000010010000001001110010011110101001001010100010010000010000001010000010011110100111101001100

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Deploy Your App in Style in 2022 🚀

Some feedback from the team…

Beta Books on Sale November 27

Harmony Launcher DEX — TestNet Perks/Rewards | HARL Alpha NFT!!

Magic Product Updates: June Edition

A Brief History of Open Source from the Netflix Cloud Security Team

WordPress Hosting with Free Migration

An Overview of Kunernetes and Industry Use Case of Kubernetes

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ADA North Pool

ADA North Pool 0100000101000100010000010010000001001110010011110101001001010100010010000010000001010000010011110100111101001100

More from Medium

Contabo Server Setup

December Development Update

Battle of the DEX’s

Indigo Trading Strategies