Sponsored Content
Full Discussion: iptables: block/allow ftp
Special Forums Cybersecurity iptables: block/allow ftp Post 18686 by sTorm on Tuesday 2nd of April 2002 01:54:08 AM
Old 04-02-2002
These two lines are just for the control connection. For the data transfer, two more lines have to be added:

iptables -A FORWARD -i $eth0 -o $eth1 -p TCP --sport ftp-data --dport 1024:65535 -j ACCEPT
iptables -A FORWARD -i $eth1 -o eth0 -p TCP --sport 1024:65535 --dport ftp-data -j ACCEPT

This is for the active mode.
If you want to use passive mode, change the port from "ftp-data" to "1024:65535" in the two lines above. Although I didn't try it, it should work fine.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

iptables, ftp

I have allready opened a thread about this, but my question was really weird formed, so I'm writting it here again: I have a Network with 4 FTP Servers, then a firewall, and then a Network with clients. The clients should have access to the FTP Servers, but it should not be possible to connect... (2 Replies)
Discussion started by: sTorm
2 Replies

2. Shell Programming and Scripting

FTP inside a block of code

I need help on the code below. I am getting a compile error syntax error at line 283 : `<<' unmatched Looks like it doesn't like the << on the ftp line below. If I ran the code outside of this block everything work fine, but when I put in a block of code or in a function, I got syntax error. I... (1 Reply)
Discussion started by: leemjesse
1 Replies

3. Solaris

Want to block ftp for root user

Hi Friends, I would like to block the root user for doing ftp. As I am aware that I need to put the entry for root in /etc/ftpusers.....am I right...??? But I am not able to edit the file & even more command is not working. #ls -l ftp* total 14 -rw-r--r-- 1 root sys 1249 Jun... (3 Replies)
Discussion started by: jumadhiya
3 Replies

4. UNIX for Dummies Questions & Answers

How to block an anonymous ftp user?

Could anyone provide information on how to block a specific client machine from being able to log onto anonymous ftp? (10 Replies)
Discussion started by: dennisheazle
10 Replies

5. Shell Programming and Scripting

Block incoming traffic FTP from internet using iptables

Hi everybody. I have the next scenary: eth0: WAN eth1: DMZ eth2: LAN I need to block all incoming trafic from the internet through my network LAN using iptables. I have squid but i need to do this using ipatbles. I have been listening about iptables -A FORDAWARD but I am stuck right... (0 Replies)
Discussion started by: edeamat
0 Replies

6. AIX

Block users ftp service

Hello everyone I create a file /etc/ftpusers to block users. I put the names of the users and I refresh the service inetd. My question is the user still log in by ftp.???? What I miss Thanks for your opinions. Greetings (2 Replies)
Discussion started by: lo-lp-kl
2 Replies

7. UNIX for Dummies Questions & Answers

iptables-ftp

I have set up a firewall on my centOS 5.6 box. I copied it from info I found online related to web servers. Everything seems to work fine but my ftp from my LAN. I am not able to ftp into the directories at all. I have the box set up as a test web server. Here is my iptable: I have opened ports... (7 Replies)
Discussion started by: ktb231
7 Replies

8. Red Hat

iptables ftp denies ls

Hi, Following is the output of iptables -S command -P INPUT ACCEPT -P FORWARD ACCEPT -P OUTPUT ACCEPT -A INPUT -s 192.168.0.5/32 -p tcp -m tcp --dport 22 -j ACCEPT -A INPUT -s 192.168.0.5/32 -p udp -m udp --dport 22 -j ACCEPT -A INPUT -s 192.168.0.0/24 -p udp -m udp --dport 20 -j... (3 Replies)
Discussion started by: shahdharmit
3 Replies

9. IP Networking

vsftp | active and passive ftp | iptables

I am using vsftp but I can't login with passive mode. I can only login with active mode. I can login with both mode when service of iptables is stop. In active mode : 20,21 must be open from server site. 1023 and over must be open at client site. In passive mode : only 21,1023 and over must be... (1 Reply)
Discussion started by: getrue
1 Replies

10. IP Networking

iptables problem with ftp

I have a pretty stock iptables script. One rule allows active ftp from an outside IP address. To troubleshoot it, I opened up ftp to all connections from the outside. When a user outside our domain connects via FTP, they are denied. If I flush the rules, the ftp takes place successfully. This... (2 Replies)
Discussion started by: bricoleur
2 Replies
Generic packet editor action in tc(8)                                  Linux                                 Generic packet editor action in tc(8)

NAME
pedit - generic packet editor action SYNOPSIS
tc ... action pedit [ex] munge { RAW_OP | LAYERED_OP | EXTENDED_LAYERED_OP } [ CONTROL ] RAW_OP := offset OFFSET { u8 | u16 | u32 } [ AT_SPEC ] CMD_SPEC AT_SPEC := at AT offmask MASK shift SHIFT LAYERED_OP := { ip IPHDR_FIELD | ip BEYOND_IPHDR_FIELD } CMD_SPEC EXTENDED_LAYERED_OP := { eth ETHHDR_FIELD | ip IPHDR_FIELD | ip EX_IPHDR_FIELD | ip6 IP6HDR_FIELD | tcp TCPHDR_FIELD | udp UDPHDR_FIELD } CMD_SPEC ETHHDR_FIELD := { src | dst | type } IPHDR_FIELD := { src | dst | tos | dsfield | ihl | protocol | precedence | nofrag | firstfrag | ce | df } BEYOND_IPHDR_FIELD := { dport | sport | icmp_type | icmp_code } EX_IPHDR_FIELD := { ttl } IP6HDR_FIELD := { src | dst | flow_lbl | payload_len | nexthdr | hoplimit } TCPHDR_FIELD := { sport | dport | flags } UDPHDR_FIELD := { sport | dport } CMD_SPEC := { clear | invert | set VAL | add VAL | preserve } [ retain RVAL ] CONTROL := { reclassify | pipe | drop | shot | continue | pass | goto chain CHAIN_INDEX } DESCRIPTION
The pedit action can be used to change arbitrary packet data. The location of data to change can either be specified by giving an offset and size as in RAW_OP, or for header values by naming the header and field to edit the size is then chosen automatically based on the header field size. Currently this is supported only for IPv4 headers. OPTIONS
ex Use extended pedit. EXTENDED_LAYERED_OP and the add CMD_SPEC are allowed only in this mode. offset OFFSET { u32 | u16 | u8 } Specify the offset at which to change data. OFFSET is a signed integer, it's base is automatically chosen (e.g. hex if prefixed by 0x or octal if prefixed by 0). The second argument specifies the length of data to change, that is four bytes (u32), two bytes (u16) or a single byte (u8). at AT offmask MASK shift SHIFT This is an optional part of RAW_OP which allows to have a variable OFFSET depending on packet data at offset AT, which is binary ANDed with MASK and right-shifted by SHIFT before adding it to OFFSET. eth ETHHDR_FIELD Change an ETH header field. The supported keywords for ETHHDR_FIELD are: src dst Source or destination MAC address in the standard format: XX:XX:XX:XX:XX:XX type Ether-type in numeric value ip IPHDR_FIELD Change an IPv4 header field. The supported keywords for IPHDR_FIELD are: src dst Source or destination IP address, a four-byte value. tos dsfield precedence Type Of Service field, an eight-bit value. ihl Change the IP Header Length field, a four-bit value. protocol Next-layer Protocol field, an eight-bit value. nofrag firstfrag ce df mf Change IP header flags. Note that the value to pass to the set command is not just a bit value, but the full byte including the flags field. Though only the relevant bits of that value are respected, the rest ignored. ip BEYOND_IPHDR_FIELD Supported only for non-extended layered op. It is passed to the kernel as offsets relative to the beginning of the IP header and assumes the IP header is of minimum size (20 bytes). The supported keywords for BEYOND_IPHDR_FIELD are: dport sport Destination or source port numbers, a 16-bit value. Indeed, IPv4 headers don't contain this information. Instead, this will set an offset which suits at least TCP and UDP if the IP header is of minimum size (20 bytes). If not, this will do unex- pected things. icmp_type icmp_code Again, this allows to change data past the actual IP header itself. It assumes an ICMP header is present immediately follow- ing the (minimal sized) IP header. If it is not or the latter is bigger than the minimum of 20 bytes, this will do unex- pected things. These fields are eight-bit values. ip EX_IPHDR_FIELD Supported only when ex is used. The supported keywords for EX_IPHDR_FIELD are: ttl ip6 IP6HDR_FIELD The supported keywords for IP6HDR_FIELD are: src dst flow_lbl payload_len nexthdr hoplimit tcp TCPHDR_FIELD The supported keywords for TCPHDR_FIELD are: sport dport Source or destination TCP port number, a 16-bit value. flags udp UDPHDR_FIELD The supported keywords for UDPHDR_FIELD are: sport dport Source or destination TCP port number, a 16-bit value. clear Clear the addressed data (i.e., set it to zero). invert Swap every bit in the addressed data. set VAL Set the addressed data to a specific value. The size of VAL is defined by either one of the u32, u16 or u8 keywords in RAW_OP, or the size of the addressed header field in LAYERED_OP. add VAL Add the addressed data by a specific value. The size of VAL is defined by the size of the addressed header field in EXTENDED_LAY- ERED_OP. This operation is supported only for extended layered op. preserve Keep the addressed data as is. retain RVAL This optional extra part of CMD_SPEC allows to exclude bits from being changed. Supported only for 32 bits fields or smaller. CONTROL The following keywords allow to control how the tree of qdisc, classes, filters and actions is further traversed after this action. reclassify Restart with the first filter in the current list. pipe Continue with the next action attached to the same filter. drop shot Drop the packet. continue Continue classification with the next filter in line. pass Finish classification process and return to calling qdisc for further packet processing. This is the default. EXAMPLES
Being able to edit packet data, one could do all kinds of things, such as e.g. implementing port redirection. Certainly not the most use- ful application, but as an example it should do: First, qdiscs need to be set up to attach filters to. For the receive path, a simple ingress qdisc will do, for transmit path a classful qdisc (HTB in this case) is necessary: tc qdisc replace dev eth0 root handle 1: htb tc qdisc add dev eth0 ingress handle ffff: Finally, a filter with pedit action can be added for each direction. In this case, u32 is used matching on the port number to redirect from, while pedit then does the actual rewriting: tc filter add dev eth0 parent 1: u32 match ip dport 23 0xffff action pedit pedit munge ip dport set 22 tc filter add dev eth0 parent ffff: u32 match ip sport 22 0xffff action pedit pedit munge ip sport set 23 tc filter add dev eth0 parent ffff: u32 match ip sport 22 0xffff action pedit ex munge ip dst set 192.168.1.199 tc filter add dev eth0 parent ffff: u32 match ip sport 22 0xffff action pedit ex munge ip6 dst set fe80::dacb:8aff:fec7:320e tc filter add dev eth0 parent ffff: u32 match ip sport 22 0xffff action pedit ex munge eth dst set 11:22:33:44:55:66 tc filter add dev eth0 parent ffff: u32 match ip dport 23 0xffff action pedit ex munge tcp dport set 22 SEE ALSO
tc(8), tc-htb(8), tc-u32(8) iproute2 12 Jan 2015 Generic packet editor action in tc(8)
All times are GMT -4. The time now is 09:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy