Skip to contentSkip to conversation

(no subject)

DISCUSSION Anthony de Almeida Lopes 6 participants 6 messages Feb 21, 2004 – Feb 22, 2004

lore
Share & tools
lore
#0 lore raw

Hi, I would like to add a certain rule to my firewall, but I have a dynamic IP, I'm wondering if there is some way I can work with this the line is as follows:

iptables -A INPUT -p tcp -d <MyDynamicIP> --tcp-flags SYN,FIN SYN,FIN -j DROP

Thanks for any information you can provide.

--tony

#1 lore raw
Quoted 6 lines · Anthony de Almeida Lopes

Hi, I would like to add a certain rule to my firewall, but I have a dynamic IP, I'm wondering if there is some way I can work with this the line is as follows:

iptables -A INPUT -p tcp -d <MyDynamicIP> --tcp-flags SYN,FIN SYN,FIN -j DROP

OTOMH:
iptables -A INPUT -p tcp -d ip ad sh dev <external interface, like eth1>|grep inet|awk '{print $2}'|cut -d / -f 1 --tcp-flags SYN,FIN SYN,FIN -j DROP

I may be wrong on the "ip" output, You may need to change $2

#2 lore raw
In reply to Anthony de Almeida Lopes

No, but if you have a dynamic IP on the firewall, you can use the -i <dynamic_ip_network_interface> instead to do the same thing.

Quoted 12 lines · Anthony de Almeida Lopes

Hi, I would like to add a certain rule to my firewall, but I have a dynamic IP, I'm wondering if there is some way I can work with this the line is as follows:

iptables -A INPUT -p tcp -d <MyDynamicIP> --tcp-flags SYN,FIN SYN,FIN -j DROP

Thanks for any information you can provide.

--tony

#3 lore raw
In reply to Anthony de Almeida Lopes

A fast way to do this is with a script and something like this (could be a lot of other options and ways to do this)

MY_IP=ifconfig eth0 | grep "inet addr" | cut -d':' -f2 | cut -d' ' -f1

and then
iptables -A INPUT -p tcp -d $MY_IP --tcp-flags SYN,FIN SYN,FIN -j DROP

of course, you need to change eth0 to the interface that you need to obtain an ip address.

If this interface is related to an ppp interface it could be easy, in a file called ip-up in /etc/ppp you could set your script with the following vars

# When the ppp link comes up, this script is called with the following

# parameters
#       $1      the interface name used by pppd (e.g. ppp3)
#       $2      the tty device name
#       $3      the tty device speed
#       $4      the local IP address for the interface
#       $5      the remote IP address
#       $6      the parameter specified by the 'ipparam' option to pppd

pppd executes this script when it comes up

so you can use $1 where i put $MY_IP in the iptables command.

then, if you need to change some parameters when the ppp connection cames down, just set it in ip-down

and thats it

Hello Anthony,

Saturday, February 21, 2004, 9:46:59 AM, you wrote:

AdAL> Hi, I would like to add a certain rule to my firewall, but I have a AdAL> dynamic IP, I'm wondering if there is some way I can work with this AdAL> the line is as follows:

AdAL> iptables -A INPUT -p tcp -d <MyDynamicIP> --tcp-flags SYN,FIN SYN,FIN -j AdAL> DROP

AdAL> Thanks for any information you can provide.

AdAL> --tony

Signature · 2 lines
Best regards,
 Alexis                            mailto:[email protected]
#4 lore raw

How about a faster way to do that, that is static to any interface that pops up, "iptables -A INPUT -i ! lo --tcp-flags SYN,FIN SYN,FIN -j DROP" that will protect every interface that is not lo(Loop Back).

Quoted 60 lines · On Sat, 21 Feb 2004 19:49:22 -0300 Alexis <[email protected]> wrote:

A fast way to do this is with a script and something like this (could be a lot of other options and ways to do this)

MY_IP=ifconfig eth0 | grep "inet addr" | cut -d':' -f2 | cut -d' ' -f1

and then
iptables -A INPUT -p tcp -d $MY_IP --tcp-flags SYN,FIN SYN,FIN -j DROP

of course, you need to change eth0 to the interface that you need to obtain an ip address.

If this interface is related to an ppp interface it could be easy, in a file called ip-up in /etc/ppp you could set your script with the following vars

# When the ppp link comes up, this script is called with the following

# parameters
#       $1      the interface name used by pppd (e.g. ppp3)
#       $2      the tty device name
#       $3      the tty device speed
#       $4      the local IP address for the interface
#       $5      the remote IP address
#       $6      the parameter specified by the 'ipparam' option to pppd

pppd executes this script when it comes up

so you can use $1 where i put $MY_IP in the iptables command.

then, if you need to change some parameters when the ppp connection cames down, just set it in ip-down

and thats it

Hello Anthony,

Saturday, February 21, 2004, 9:46:59 AM, you wrote:

AdAL> Hi, I would like to add a certain rule to my firewall, but I have a AdAL> dynamic IP, I'm wondering if there is some way I can work with this AdAL> the line is as follows:

AdAL> iptables -A INPUT -p tcp -d <MyDynamicIP> --tcp-flags SYN,FIN SYN,FIN -j AdAL> DROP

AdAL> Thanks for any information you can provide.

AdAL> --tony

Signature · 2 lines
Best regards,
 Alexis                            mailto:[email protected]
Signature · 5 lines
        This e-mail may be privileged and/or confidential, and the sender
does not waive any related rights and obligations. Any distribution, use
or copying of this e-mail or the information it contains by other than an
intended recipient is unauthorized. If you received this e-mail in error,
please advise me (by return e-mail or otherwise) immediately.
#5 lore raw

Thanks, that's also a good idea. I'll try that too :)

Quoted 67 lines · On Sat, 2004-02-21 at 19:23, c0ldbyte wrote:

How about a faster way to do that, that is static to any interface that pops up, "iptables -A INPUT -i ! lo --tcp-flags SYN,FIN SYN,FIN -j DROP" that will protect every interface that is not lo(Loop Back).

Quoted 60 lines · On Sat, 21 Feb 2004 19:49:22 -0300 Alexis <[email protected]> wrote:

A fast way to do this is with a script and something like this (could be a lot of other options and ways to do this)

MY_IP=ifconfig eth0 | grep "inet addr" | cut -d':' -f2 | cut -d' ' -f1

and then
iptables -A INPUT -p tcp -d $MY_IP --tcp-flags SYN,FIN SYN,FIN -j DROP

of course, you need to change eth0 to the interface that you need to obtain an ip address.

If this interface is related to an ppp interface it could be easy, in a file called ip-up in /etc/ppp you could set your script with the following vars

# When the ppp link comes up, this script is called with the following

# parameters
#       $1      the interface name used by pppd (e.g. ppp3)
#       $2      the tty device name
#       $3      the tty device speed
#       $4      the local IP address for the interface
#       $5      the remote IP address
#       $6      the parameter specified by the 'ipparam' option to pppd

pppd executes this script when it comes up

so you can use $1 where i put $MY_IP in the iptables command.

then, if you need to change some parameters when the ppp connection cames down, just set it in ip-down

and thats it

Hello Anthony,

Saturday, February 21, 2004, 9:46:59 AM, you wrote:

AdAL> Hi, I would like to add a certain rule to my firewall, but I have a AdAL> dynamic IP, I'm wondering if there is some way I can work with this AdAL> the line is as follows:

AdAL> iptables -A INPUT -p tcp -d <MyDynamicIP> --tcp-flags SYN,FIN SYN,FIN -j AdAL> DROP

AdAL> Thanks for any information you can provide.

AdAL> --tony

Signature · 2 lines
Best regards,
 Alexis                            mailto:[email protected]
Signature · 3 lines
---------------------------------------------------------------
Please avoid sending me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html