How to save iptables persistently – easy way

Save current iptables settings using command iptables-save. We save it to /etc/network/iptables.v4.rules iptables-save > /etc/network/iptables.v4.rules Last we configure our box to restore it upon booting up the network interface. Configure your network interface file /etc/network/interfaces nano /etc/network/interfaces #under iface eth0 inet static .... pre-up iptables-restore < /etc/network/iptables.v4.rules tadaaa! short and...

Edit crontab of another user (linux/ubuntu)

Root access or sudo rights is required to perform this. #crontab manpage crontab [ -u user ] { -l | -r [ -i ] | -e } #Example for editing crontab for user "anotheruser" sudo crontab -u anotheruser -e #Example for listing crontab for user "anotheruser" sudo crontab -u anotheruser...

iptables remove rules using –line-numbers

List the rules for a specific chain. Example below list the “fail2ban-ssh-ddos” chain. iptables -L fail2ban-ssh-ddos --line-numbers Example output: Chain fail2ban-ssh-ddos (2 references) num target prot opt source destination 1 REJECT all -- 192.0.0.8 anywhere reject-with icmp-port-unreachable 2 RETURN all -- anywhere anywhere Delete rule line number 1: iptables -D fail2ban-ssh-ddos...

Installing Pure-FTPd on Ubuntu 12.04

Guide wrote on 13 Jan 2014 Step 1) Install Pure-FTPd using aptitude package tool root@server:~# aptitude -y install pure-ftpd Step 2) Run pure-ftpd as a daemon (background process) root@server:~# echo "yes" > /etc/pure-ftpd/conf/Daemonize Step 3) Disable anonymous ftp login root@server:~# echo "yes" > /etc/pure-ftpd/conf/NoAnonymous Step 4) Jail all local user to their home directories root@server:~# echo "yes" > /etc/pure-ftpd/conf/ChrootEveryone Step 5) Configure FTP server to use IPv4 only root@server:~# echo "yes" > /etc/pure-ftpd/conf/IPV4Only Last Step) Restart pure-FTP server for changes to take effect root@server:~# service pure-ftpd restart Optional configurations you may need: Defining passive ports (passive port range 21000 to 21100 in example below) root@server:~# echo "21000 21100" > /etc/pure-ftpd/conf/PassivePortRange Set maximum number of clients (50 clients in example below) root@server:~# echo "50" >...

Fail2ban – remove banned ip address from iptables

Your colleagues were trying to access production server via FTP. However exceeded the maximum number of failed logins, their IP address got blacklisted on iptables. How do you remove their ip address from the blacklist? Check their ip address with iptables # sudo iptables -L ... Chain fail2ban-vsftpd (1 references) target prot opt source destination DROP all -- 192.168.1.156 anywhere RETURN all -- anywhere anywhere Remove ip address from iptables # sudo iptables -D fail2ban-vsftpd -s 192.168.1.156 -j DROP Verify the iptables # sudo iptables -L ... Chain fail2ban-vsftpd (1 references) target prot opt source destination RETURN all -- anywhere...