Skip to contentSkip to conversation

Ping With Iptables.

DISCUSSION Hélio Dubeux 3 participants 4 messages Oct 29, 2002

lore
Share & tools
lore
#0 lore raw

Hi, everybody. This is my first message here and i hope you can help me.
I have a Linux Box as a Gateway of my network. And i want do allow internal machines to ping the Internet but i also want to block external machines to ping my Gateway. Is this is possible plz send me something... Thanx.

----------------------
Hélio Dubeux Neto

_________________________________________________________________
MSN Hotmail, o maior webmail do Brasil. http://www.hotmail.com

#1 lore raw

Hello,

Quoted 3 lines

I have a Linux Box as a Gateway of my network. And i want do allow internal machines to ping the Internet but i also want to block external machines to ping my Gateway. Is this is possible plz send me something... Thanx.

#let the internal net ping the world iptables -A FORWARD -p icmp -s $YOUR_NET -j ACCEPT

#disallow the world to ping the gateway
iptables -I INPUT -p icmp -d $GATEWAY_IP -j DROP

Of course this is very rough, i do not know your rulesets, it is possible that it can be done better to suit your current chains and rules.

Note, the -I INPUT - if we have other icmp rules, they may ACCEPT the pings earlier than if we had just appended the rule, hence we're inserting.

#2 lore raw
Quoted 7 lines · Maciej Soltysiak

Hello,

Quoted 4 lines

I have a Linux Box as a Gateway of my network. And i want do allow internal machines to ping the Internet but i also want to block external machines to ping my Gateway. Is this is possible plz send me something... Thanx.

Quoted 8 lines

#let the internal net ping the world iptables -A FORWARD -p icmp -s $YOUR_NET -j ACCEPT

#disallow the world to ping the gateway
iptables -I INPUT -p icmp -d $GATEWAY_IP -j DROP

Of course this is very rough, i do not know your rulesets, it is possible that it can be done better to suit your current chains and rules.

I would instead recommend
iptables -P INPUT DROP

and then only add rules for the things you really do want to come in to the firewall (established & related is probably a good start).

"Allow what you know you want, and drop everything else" is a good policy.

Antony.

Signature · 3 lines
G- GIT/E d- s+:--(-) a+ C++++$ UL++++$ P+(---)>++ L+++(++++)$ !E W(-) N(-) o? 
w-- O !M V+++(--) !PS !PE Y+ PGP+> t- tv@ b+++ DI++ D--- e++>+++ h++ r@? 5? 
!X- !R K--?
#3 lore raw
Quoted 5 lines

I would instead recommend
iptables -P INPUT DROP

and then only add rules for the things you really do want to come in to the firewall (established & related is probably a good start).

Well of course, i wrote that, keeping in mind that he could have other rules like:
-s 0/0 -j ACCEPT

Quoted 1 line

"Allow what you know you want, and drop everything else" is a good policy.

Is the best in most cases.

Quoted 1 line

Antony.

Maciej