Sponsored Content
Special Forums Cybersecurity ~ IPTables : Limit Incoming UDP Packets With a Certain Length ~ Post 302307356 by otheus on Wednesday 15th of April 2009 06:53:39 AM
Old 04-15-2009
I'm not sure, but the second "-m length --length 20" is redundant. You only get to that table if this condition is true. What I'm not clear about the length module is if it is the rule that gets limited or something else. If it's the rule, then this would drop any packet over 20 bytes after there have been 5 per second.

Do you want to limit it by IP address? Then I recommend you use the "recent" feature:

Code:
iptables -N CHECK1
iptables -A INPUT -p udp -m length --length 20 -j CHECK1

iptables -A CHECK1 -m recent --name longudp --rcheck 1 --hitcount 5 -j DROP
iptables -A CHECK1 -m recent --name longudp --set -j RETURN

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep line length limit

Hi Friends, I am having a funny problem with grep. When I run grep 'expr' file.txt things work fine. But when try to get the line number using the -n option, i.e, grep -n 'expr' file.txt I get a message, "grep: 0652-226 Maximum line length of 2048 exceeded." If the line has more than... (3 Replies)
Discussion started by: hnhegde
3 Replies

2. IP Networking

IPv6 UDP server not accepting packets with global address

Hi All, I am running a IPv6 UDP server, which is bound to in6addr_any. When I send a packet from a client to the link-local address of any interface on the linux box, the server accepts the packets. But when I send the packets to the global address the server doesnt pick the packets. On... (0 Replies)
Discussion started by: muralia
0 Replies

3. UNIX for Dummies Questions & Answers

limit of command length

Hi! Can you please help me with one question? Does rexec command have some limitation of the length of the deliveded cmd? Thanks in advance, Anta (2 Replies)
Discussion started by: Anta
2 Replies

4. Shell Programming and Scripting

AWK limit for (length) function?

I am trying to use the following code: awk '{s=$0;if(length(s) < 750){getline; s=s " " $0}printf("%s\n",s)}' filename but an error shows that 'awk' is too long. Is there a limit to the awk length function? and what could be an alternate solution for long fixed width records? The code... (3 Replies)
Discussion started by: CKT_newbie88
3 Replies

5. Programming

Is there a limit for a code line length in C?

Is there any stabdard limitation on size of a code line in C code? I am interesting in UNIX limitation, particulary on SUN. Thanks! (8 Replies)
Discussion started by: alex_5161
8 Replies

6. UNIX for Dummies Questions & Answers

Linux box drops the incoming packets

Hi all, I am new to Linux kernel. we have a c file that counts the no. of sends and received packets in each interface, and indicate the user about the error/drop ration of incoming and outgoing packets. in our Linux box , the incoming packets are dropped at random interval. we have our... (1 Reply)
Discussion started by: kannandv
1 Replies

7. IP Networking

how to hack linux driver to delay incoming packets

hello, can anyone suggest how to delay the incoming packets ?? or how the packets are prossed inside the kernal and a way to make the packets wait a while?? it wud be vry helpful regards sameer (7 Replies)
Discussion started by: sameer kulkarni
7 Replies

8. Linux

how to allow incoming UDP packets with iptables

I am looking for an iptables command to allow incoming UDP packets for my Linux server also is there a command I can use to set the default action for outgoing packets to accept? Thank you (1 Reply)
Discussion started by: crimputt
1 Replies

9. IP Networking

How to route all incoming packets from one virtual interface?

Hello, I'm trying to route all packets arriving at a particular interface by entering the same interface the virtual interface eth1: 2 and now everything is routed by default gw configured on eth1. eth1 Link encap:Ethernet HWaddr 0a:0e:64:18:52:72 inet addr:192.168.10.15 eth1:2 ... (1 Reply)
Discussion started by: faka
1 Replies

10. IP Networking

How to route packets back to incoming interface?

Hi folks, I have a debian server running an Apache daemon on the eth0 interface. Now from time to time the server has to open an openvpn connection (tun0) to other networks to get some data from there. During this period the Apache is no longer reachable under it's IP address on eth0 because all... (6 Replies)
Discussion started by: flyingwalrus
6 Replies
IPQueue(3pm)						User Contributed Perl Documentation					      IPQueue(3pm)

NAME
IPTables::IPv4::IPQueue - Perl extension for libipq. SYNOPSIS
use IPTables::IPv4::IPQueue qw(:constants); $queue = new IPTables::IPv4::IPQueue(); $msg = $queue->get_message(); $queue->set_verdict($msg->packet_id(), NF_ACCEPT) $queue->set_mode(IPQ_COPY_PACKET, 2048); IPTables::IPv4::IPQueue->errstr; undef $queue; DESCRIPTION
Perlipq (IPTables::IPv4::IPQueue) is a Perl extension for iptables userspace packet queuing via libipq. Packets may be selected from the stack via the iptables QUEUE target and passed to userspace. Perlipq allows these packets to be manipulated in Perl and passed back to the stack. More information on userspace packet queueing may be found in libipq(3). CONSTANTS
Copy Mode IPQ_COPY_META - Copy only packet metadata to userspace. IPQ_COPY_PACKET - Copy metatdata and packet to userspace. Packet Verdicts NF_DROP - Ask kernel to drop packet. NF_ACCEPT - Ask kernel to accept packet and continue processing. ATTRIBUTES
None. METHODS
new( [param => value, ... ] ) Constructor. Creates userspace queuing object and sets the queuing mode. Parameters: protocol copy_mode copy_range The protocol parameter, if provided, must be one of PF_INET or PF_INET6, for IPv4 and IPv6 packet queuing respectively. If no protocol parameter is provided, the default is PF_INET. The default copy mode is IPQ_COPY_META. set_mode(mode [, range]) Set the queuing mode. The mode parameter must be one of: IPQ_COPY_META IPQ_COPY_PACKET When specifying IPQ_COPY_PACKET mode, the range parameter specifies the number of bytes of payload data to copy to userspace. If the range is not provided and the mode is IPQ_COPY_PACKET, the range will default to zero. Typically, a range of 1500 will suffice. This method is called by the constructor. get_message([timeout]) Receives a packet message from the kernel, returning a tainted IPTables::IPv4::IPQueue::Packet object. The optional timeout parameter may be used to specify a timeout for the operation in microseconds. This is implemented internally via the select() syscall. A value of zero or no value means to wait indefinitely. The returned object is a helper object with the following read only attributes: packet_id ID of queued packet. mark Netfilter mark value. timestamp_sec Packet arrival time (seconds). timestamp_usec Packet arrvial time (+useconds). hook Netfilter hook we rode in on. indev_name Name of incoming interface. outdev_name Name of outgoing interface. hw_protocol Hardware protocol. hw_type Hardware media type. hw_addrlen Hardware address length. hw_addr Hardware address. data_len Length of payload data. payload Payload data. Payload data, if present, is a scalar byte string suitable for use with packages such as NetPacket. If the operation timed out, undef will be returned and the errstr() message will be 'Timeout'. See the sample dumper.pl script for a simple example of how this may be handled. set_verdict(id, verdict [, data_len, buf ]) Sets verdict on packet with specified id, and optionally sends modified packet data back to the kernel. The verdict must be one of: NF_DROP NF_ACCEPT close() Destroys userpsace queue context and all associated resources. This is called by the destructor, which means you can just do: undef $queue; instead. errstsr() Class method, returns an error message based on the most recent library error condition and global errno value. EXAMPLE
package example; use strict; $^W = 1; use IPTables::IPv4::IPQueue qw(:constants); my ($queue, $msg); $queue = new IPTables::IPv4::IPQueue(copy_mode => IPQ_COPY_META) or die IPTables::IPv4::IPQueue->errstr; $msg = $queue->get_message() or die IPTables::IPv4::IPQueue->errstr; $queue->set_verdict($msg->packet_id(), NF_ACCEPT) > 0 or die IPTables::IPv4::IPQueue->errstr; CHANGES
o Support for timeouts in get_message() was added in version 1.24. BUGS
None known. COPYRIGHT
Copyright (c) 2000-2002 James Morris <jmorris@intercode.com.au> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. AUTHOR
James Morris <jmorris@intercode.com.au> SEE ALSO
iptables(8) libipq(3) NetPacket(3) The example scripts, passer.pl, passer6.pl and dumper.pl. perl v5.14.2 2011-11-15 IPQueue(3pm)
All times are GMT -4. The time now is 10:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy