Firewall: Difference between revisions

From Server STB
Jump to navigation Jump to search
No edit summary
No edit summary
Line 21: Line 21:
## blok port 22 dari ip 192.168.10.0/24
## blok port 22 dari ip 192.168.10.0/24
echo "sshd: 192.168.10.0/255.255.255.0" >> /etc/hosts.deny
echo "sshd: 192.168.10.0/255.255.255.0" >> /etc/hosts.deny
# open port 22 dari ip 192.168.10.202
## open port 22 dari ip 192.168.10.202
echo "sshd: 192.168.10.202" >> /etc/hosts.allow
echo "sshd: 192.168.10.202" >> /etc/hosts.allow
# open port 22 dari ip 192.168.10.36
## open port 22 dari ip 192.168.10.36
echo "sshd: 192.168.10.36" >> /etc/hosts.allow
echo "sshd: 192.168.10.36" >> /etc/hosts.allow
# open port 22 dari ip 192.168.10.29
## open port 22 dari ip 192.168.10.29
echo "sshd: 192.168.10.29" >> /etc/hosts.allow
echo "sshd: 192.168.10.29" >> /etc/hosts.allow
echo "sshd: 192.168.10.19" >> /etc/hosts.allow
echo "sshd: 192.168.10.19" >> /etc/hosts.allow

Revision as of 01:50, 21 September 2023

Htaccess

    1. !/bin/sh
    2. apt-get update
    3. apt-get install iptables
    4. apt-get install iptables-persistent

iptables -V iptables -I INPUT -p tcp -s 192.168.10.202 -j ACCEPT iptables -A INPUT -p tcp --dport 80 -j ACCEPT iptables -A INPUT -p tcp --dport 22 -j ACCEPT iptables -A INPUT -p tcp --dport 443 -j ACCEPT iptables -A INPUT -p tcp --dport 1912 -j ACCEPT iptables -A INPUT -p tcp --dport 3306 -j ACCEPT iptables -A INPUT -p tcp --dport 5432 -j ACCEPT iptables -A INPUT -p tcp -s 192.168.10.0/24 -j DROP iptables -L

    1. iptables-save > /etc/iptables/rules.v4
    2. systemctl enable iptables-persistent
    3. service iptables-persistent start
    1. blok port 22 dari ip 192.168.10.0/24

echo "sshd: 192.168.10.0/255.255.255.0" >> /etc/hosts.deny

    1. open port 22 dari ip 192.168.10.202

echo "sshd: 192.168.10.202" >> /etc/hosts.allow

    1. open port 22 dari ip 192.168.10.36

echo "sshd: 192.168.10.36" >> /etc/hosts.allow

    1. open port 22 dari ip 192.168.10.29

echo "sshd: 192.168.10.29" >> /etc/hosts.allow echo "sshd: 192.168.10.19" >> /etc/hosts.allow