ubuntu - UFW: Allow ping requests only for specific host -
i setuping server , must disable ping requests except me , list of hosts (aaa.bbb.ccc.ddd).
i using tool ufw, on ubuntu server, read have comment lines:
ok icmp codes
-a ufw-before-input -p icmp --icmp-type destination-unreachable -j accept -a ufw-before-input -p icmp --icmp-type source-quench -j accept -a ufw-before-input -p icmp --icmp-type time-exceeded -j accept -a ufw-before-input -p icmp --icmp-type parameter-problem -j accept -a ufw-before-input -p icmp --icmp-type echo-request -j accept,
however, doing disallow ping, problem because need "aaa.bbb.ccc.ddd" have response ping requests.
can me write correct command?
thank lot in advance.
i stumbled on 4 month old question. should listed on different stackexchange (such serverfault), developer needs configure firewall. is, i'm here answer you.
for firewall rules, you'll want accept packets safe ips first , drop rest. here's how did it:
let's assume want accept 1 safe ip pings , ip address '127.0.0.1'. of course, ip address want (just create more rules or define subnets additional addresses).
step 1
first thing check following in /etc/ufw/sysctl.conf
net/ipv4/icmp_echo_ignore_all=1
...should rewritten 0 if not already...
net/ipv4/icmp_echo_ignore_all=0
step 2
add rules ipv4 /etc/ufw/before.rules
-a ufw-before-input -p icmp --icmp-type echo-request –s 127.0.0.1 -m state --state established -j accept
step 3 (for ipv6 support)
add rules ipv6 /etc/ufw/before6.rules
-a ufw6-before-input -p icmpv6 --icmpv6-type echo-request –s 127.0.0.1 -m state --state established -j accept
step 4
now, restart firewall , drink beverage of choice.
service ufw restart
Comments
Post a Comment