iptables语法总结

2026华为OD面试手撕代码真题目录 一般面试的时候每一轮技术面都会出一到两个手撕代码题,这些题的特点就是,非常短小,易于理解。不可能会再出阅读理解一样的机试题的。但是这些题目也非常注意基本功,很注意细节的处理,一般都是easy+medium题目。但是大家一定要注意,因为大部分面试官上面一开始就会让你做题,直接看你所有的做题过程(防止有人水平一般,机试就网上找的答案的蒙混过关),手撕代码题会给你后面的面试定一个基调。 阅读详情

iptables Syntax

As presented earlier, iptables uses the concept of separate rule tables for different packet processing functionality. Nondefault tables are specified by a command-line option. Three tables are available:

  • filter The filter table is the default table. It contains the actual firewall filtering rules. The built-in chains include these:

    • INPUT

    • OUTPUT

    • FORWARD

  • nat The nat table contains the rules for Source and Destination Address and Port Translation. These rules are functionally distinct from the firewall filter rules. The built-in chains include these:

    • PREROUTING (DNAT/REDIRECT)

    • OUTPUT (DNAT/REDIRECT)

    • POSTROUTING (SNAT/MASQUERADE)

  • mangle The mangle table contains rules for setting specialized packet-routing flags. These flags are then inspected later by rules in the filter table. The built-in chains include these:

    • PREROUTING (routed packets)

    • INPUT (packets arriving at the firewall but after the PREROUTING chain)

    • FORWARD (changes packets being routed through the firewall)

    • POSTROUTING (changes packets just before they leave the firewall, after the OUTPUT chain)

    • OUTPUT (locally generated packets)

SYNTAX FORMAT CONVENTIONS

The conventions used to present command-line syntax options are fairly standard in the computer world. For those of you who are new to Linux or to computer documentation in general, Table 3.1 shows the conventions used in the upcoming syntax descriptions.

Table 3.1. Conventions Representing Command-Line Syntax Options

ELEMENT

DESCRIPTION

|

A bar or pipe symbol separates alternate syntax options. For example, most of the iptables commands have both a short and a long form, such as -L and --list , and so they would be listed as alternate options because you would use one or the other of -L or --list .

<value>

Angle brackets indicate a user-supplied value, such as a string or numeric value.

[ ]

Square brackets indicate that the enclosed command, option, or value is optional. For example, most match operators can take a negation operator, !, which matches anything other than the value specified in the match. The negation operator is usually placed between the match operator and the value to be matched.

<value>:<value>

A colon indicates a range of values. The two values define the minimum and maximum values within the range. Because ranges themselves are optional, the convention is more often presented as <value>[:<value>] .



filter Table Commands

The filter table commands are provided by the ip_tables module. The functionality is enabled by loading the module, which is done automatically with the first invocation of the iptables command, or it could be compiled into the kernel itself, which means you don't need to worry about modules being loaded at all.

filter TABLE OPERATIONS ON ENTIRE CHAINS

Table 3.2 shows the iptables operations on entire chains.

Table 3.2. iptables Operations on Entire Chains

OPTION

DESCRIPTION

-N | --new-chain <chain>

Creates a user-defined chain.

-F | --flush [<chain>]

Flushes the chain, or all chains if none is specified.

-X | --delete-chain [<chain>]

Deletes the user-defined chain, or all chains if none is specified.

-P | --policy <chain> <policy>

Defines the default policy for one of the built-in chains, INPUT , OUTPUT , or FORWARD . The policy is either ACCEPT or DROP .

-L | --list [<chain>]

Lists the rules in the chain, or all chains if none is specified.

-Z | --zero

Resets the packet and byte counters associated with each chain.

-h | <some command> -h

Lists the iptables commands and options, or if preceded by an iptables command, lists the syntax and options for that command.

--modprobe=<command>

Use <command> to load the necessary module(s) when adding or inserting a rule into a chain.

-E | --rename-chain <old chain> <new chain>

Renames the user-defined chain <old chain> to the user-defined chain <new chain> .


The -h help command is obviously not an operation on a chain nor is --modprobe=<command> , but I didn't know where else to list the command.

The list command takes additional options, as shown in Table 3.3 .

Table 3.3. Options to the List Chain Command

OPTION

DESCRIPTION

-L -n | --numeric

Lists the IP addresses and port numbers numerically, rather than by name

-L -v | --verbose

Lists additional information about each rule, such as the byte and packet counters, rule options, and relevant network interface

-L -x | --exact

Lists the exact values of the counter, rather than the rounded-off values

-L -line-numbers

Lists the rule's position within its chain


filter TABLE OPERATIONS ON A RULE

The most frequently used commands to create or delete rules within a chain are shown in Table 3.4 .

Table 3.4. Chain Commands on Individual Rules

COMMAND

DESCRIPTION

-A | --append <chain>

Appends a rule to the end of a chain

-I | --insert <chain>

Inserts a rule at the beginning of the chain

-R | --replace <chain> <rule number> <rule specification>

Replaces a rule in the chain

-D | --delete <chain> <rule number>

Deletes the rule at position rule number within a chain


BASIC filter TABLE MATCH OPERATIONS

The basic filter match operations supported in the default iptables filter table are listed in Table 3.5 .

Table 3.5. filter Table Rule Operations

OPTION

DESCRIPTION

-i | --in-interface [!] [<interface>]

For incoming packets on either the INPUT or the FORWARD chains, or their user-defined subchains, specifies the interface name that the rule applies to. If no interface is specified, all interfaces are implied.

-o | --out-interface [!] [<interface>]

For outgoing packets on either the OUTPUT or the FORWARD chains, or their user-defined subchains, specifies the interface name that the rule applies to. If no interface is specified, all interfaces are implied.

-p | --protocol [!] [<protocol>]

Specifies the IP protocol that the rule applies to. The built-in protocols are tcp , udp , icmp , and all. The protocol value can be either the name or the numeric value, as listed in /etc/protocols .

-s | --source | --src [!] <address>[</mask>]

Specifies the host or network source address in the IP header.

-d | --destination | --dst [!] <address>[</mask>]

Specifies the host or network destination address in the IP header.

-j | --jump <target>

Specifies the target disposition for the packet if it matches the rule. The default targets include the built-in targets, an extension, or a user-defined chain.

[!] -f | --fragment

Specifies second and additional fragmented packets. The negated version of this specifies unfragmented packets.

-c | --set-counters <packets> <bytes>

Initializes the packet and byte counters.


RULE TARGETS ARE OPTIONAL

If the packet matches a rule that doesn't have a target disposition, the packet counters are updated, but list traversal continues.


tcp filter TABLE MATCH OPERATIONS

TCP header match options are listed in Table 3.6 .

Table 3.6. tcp filter Table Match Operations

-p tcp OPTION

DESCRIPTION

--source-port | --sport [[!] <port>[:<port>]]

This command specifies the source ports.

--destination-port | --dport [!] <port>[:<port>]

This command specifies the destination ports.

--tcp-flags [!] <mask>[,<mask>] <set>[,<set>]

This command tests the bits in the mask list, out of which the following bits must be set in order to match.

[!] -syn

The SYN flag must be set as an initial connection request.

--tcp-option [!] <number>

The only legal tcp option is the maximum packet size that the sending host is willing to accept.


udp filter TABLE MATCH OPERATIONS

UDP header match options are listed in Table 3.7 .

Table 3.7. udp filter Table Match Operations

-p udp OPTION

DESCRIPTION

--source-port | --sport [!] <port>[:<port>]

Specifies the source ports

--destination-port | --dport [!] <port>[:<port>]

Specifies the destination ports


icmp filter TABLE MATCH OPERATIONS

ICMP header match options are listed in Table 3.8 .

Table 3.8. icmp filter Table Match Operations

MATCH

DESCRIPTION

--icmp-type [!] <type>

Specifies the ICMP type name or number. The ICMP type is used in place of a source port.


The major supported ICMP type names and numeric values are the following:

  • echo-reply (0 )

  • destination-unreachable (3 )

    • network-unreachable

    • host-unreachable

    • protocol-unreachable

    • port-unreachable

    • fragmentation-needed

    • network-unknown

    • host-unknown

    • network-prohibited

    • host-prohibited

  • source-quench (4 )

  • redirect (5 )

  • echo-request (8 )

  • time-exceeded (10 )

  • parameter-problem (11 )

ADDITIONAL ICMP SUPPORT

iptables supports a number of additional, less common or router-specific ICMP message types and subtypes. To see the entire list, use the following iptables help command:

iptables -p icmp -h

























filter Table Target Extensions

The filter table target extensions include logging functionality and the capability to reject a packet rather than dropping it.

Table 3.9 lists the options available to the LOG target. Table 3.10 lists the single option available to the REJECT target.

Table 3.9. LOG Target Extension

-j LOG OPTION

DESCRIPTION

--log-level <syslog level>

Log level is either the numeric or the symbolic login priority, as listed in /usr/include/sys/syslog.h . These are the same log levels used in /etc/ syslog.conf . The levels are emerg (0 ), alert (1 ), crit (2 ), err (3 ), warn (4 ), notice (5 ), info (6 ), memerg (0 ), alert (1 ), crit (2 ), err (3 ), warn (4 ), notice (5 ), info (6 ), and debut (7 ).

--log-prefix <"descriptive string">

The prefix is a quoted string that will be printed at the start of the log message for the rule.

--log-ip-options

This command includes any IP header options in the log output.

--log-tcp-sequence

This command includes the TCP packet's sequence number in the log output.

--log-tcp-option

This command includes any TCP header options in the log output.


Table 3.10. REJECT Target Extension

-j REJECT OPTION

DESCRIPTION

--reject-with <ICMP type 3>

By default, a rejected packet results in an ICMP type 3 icmp-port-unreachable message being returned to the sender. Other type 3 error messages can be returned instead, including icmp-net-unreachable , icmp-host-unreachable , icmp-proto-unreachable , icmp-net-prohibited , and icmp-host-prohibited .

--reject-with tcp-reset

Incoming TCP packets can be rejected with the more standard TCP RST message, rather than an ICMP error message.

--reject-with echo-reply

ping echo-request messages can be rejected with a faked echo-reply message. That is, the firewall generates the reply, but the request is not forwarded to the target host.


THE ULOG TABLE TARGET EXTENSION

Related to the LOG target is the ULOG target, which sends the log message to a userspace program for logging. Behind the scenes for ULOG , the packet gets multicast by the kernel through a netlink socket of your choosing (the default is socket 1). The userspace daemon would then read the message from the socket and do with it what it pleases. The ULOG target is typically used to provide more extensive logging than is possible with the standard LOG target.

As with the LOG target, processing continues after matches on a ULOG targeted rule. The ULOG target has four configuration options, as described in Table 3.11 .

Table 3.11. ULOG Target Extension

OPTION

DESCRIPTION

--ulog-nlgroup <group>

Defines the netlink group that will receive the packet. The default group is 1 .

--ulog-prefix <prefix>

Messages will be prefixed by this value, up to 32 characters in length.

--ulog-cprange <size>

The size in bytes to send to the netlink socket. The default is 0 , which sends the entire packet.

--ulog-qthreshold <size>

The size in packets to queue within the kernel. The default is 1 , which means that one packet is sent per message to the netlink socket.


filter Table Match Extensions

The filter table match extensions provide access to the fields in the TCP, UDP, and ICMP headers, as well as the match features available in iptables, such as maintaining connection state, port lists, access to the hardware MAC source address, and access to the IP TOS field.

MATCH SYNTAX

The match extensions require the -m or --match command to load the module, followed by any relevant match options.


multiport filter TABLE MATCH EXTENSION

multiport port lists can include up to 15 ports per list. Whitespace isn't allowed. There can be no blank spaces between the commas and the port values. Port ranges cannot be interspersed in the list. Also, the -m multiport command must exactly follow the -p <protocol> specifier.

Table 3.12 lists the options available to the multiport match extension.

Table 3.12. multiport Match Extension

m | --match multiport OPTION

DESCRIPTION

--source-port <port> [,<port>]

Specifies the source port(s).

--destination-port <port> [,<port>]

Specifies the destination port(s).

--port <port>[,<port>]

Source and destination ports are equal, and they match a port in the list.


The multiport syntax can be a bit tricky. Some examples and cautions are included here. The following rule blocks incoming packets arriving on interface eth0 destined for the UDP ports associated with NetBIOS and SMB, common ports that are exploited on Microsoft Windows computers and targets for worms:

iptables -A INPUT -i eth0 -p udp/
-m multiport --destination-port 135,136,137,138,139 -j DROP

The next rule blocks outgoing connection requests sent through the eth0 interface to high ports associated with the TCP services NFS, socks , and squid :

iptables -A OUTPUT -o eth0 -p tcp/
-m multiport --destination-port 2049,1080,3128 --syn -j REJECT

What is important to note in this example is that the multiport command must exactly follow the protocol specification. A syntax error would have resulted if the --syn were placed between the -p tcp and the -m multiport .

To show a similar example of --syn placement, the following is correct:

iptables -A INPUT -i <interface> -p tcp -m multiport --source-port 80,443 ! --syn -j ACCEPT

However, this causes a syntax error:

iptables -A INPUT -i <interface> -p tcp ! --syn -m multiport --source-port 80,443 -j ACCEPT

Furthermore, the placement of source and destination parameters
is not obvious. The following two variations are correct:
iptables -A INPUT -i <interface> -p tcp -m multiport  --source-port 80,443 /
! --syn -d $IPADDR --dport 1024:65535 -j ACCEPT
and

iptables -A INPUT -i <interface> -p tcp -m multiport --source-port 80,443/

         -d $IPADDR ! --syn --dport 1024:65535 -j ACCEPT


However, this causes a syntax error:

iptables -A INPUT -i <interface> -p tcp -m multiport /
--source-port 80,443 /
-d $IPADDR --dport 1024:65535 ! --syn -j ACCEPT

This module has some surprising syntax side effects. Either of the two preceding correct rules produces a syntax error if the reference to the SYN flag is removed:

iptables -A INPUT -i <interface> -p tcp -m multiport /
--source-port 80,443 /
-d $IPADDR --dport 1024:65535 -j ACCEPT

The following pair of rules, however, does not:

iptables -A OUTPUT -o <interface> /
-p tcp -m multiport --destination-port 80,443 /
! --syn -s $IPADDR --sport 1024:65535 -j ACCEPT

iptables -A OUTPUT -o <interface> /
-p tcp -m multiport --destination-port 80,443 /
--syn -s $IPADDR --sport 1024:65535 -j ACCEPT

Note that the --destination-port argument to the multiport module is not the same as the --destination-port or --dport argument to the module that performs matching for the -p tcp arguments.

limit filter TABLE MATCH EXTENSION

Rate-limited matching is useful for choking back the number of log messages that would be generated during a flood of logged packets.

Table 3.13 lists the options available to the limit match extension.

Table 3.13. limit Match Extension

-m | --match limit OPTION

DESCRIPTION

--limit <rate>

Maximum number of packets to match within the given time frame

--limit-burst <number>

Maximum number of initial packets to match before applying the limit


The burst rate defines the number of initial matches to be accepted. The default value is five matches. When the limit has been reached, further matches are limited to the rate limit. The default limit is three matches per hour. Optional time frame specifiers include /second , /minute , /hour , and /day .

In other words, by default, when the initial burst rate of five matches is reached within the time limit, at most three more packets will match over the next hour, one every 20 minutes, regardless of how many packets are received. If a match doesn't occur within the rate limit, the burst is recharged by one.

It's easier to demonstrate rate-limited matching than it is to describe it in words. The following rule will limit logging of incoming ping message matches to one per second when an initial five echo-requests are received within a given second:

iptables -A INPUT -i eth0 /
-p icmp --icmp-type echo-request /
-m limit --limit 1/second -j LOG

It's also possible to do rate-limited packet acceptance. The following two rules, in combination, will limit acceptance of incoming ping messages to one per second when an initial five echo-requests are received within a given second:

iptables -A INPUT -i eth0 /
-p icmp --icmp-type echo-request /
-m limit --limit 1/second -j ACCEPT

iptables -A INPUT -i eth0 /
-p icmp --icmp-type echo-request -j DROP

The next rule limits the number of log messages generated in response to dropped ICMP redirect messages. When an initial five messages have been logged within a 20-minute time frame, at most three more log messages will be generated over the next hour, one every 20 minutes:

iptables -A INPUT -i eth0 /
-p icmp --icmp-type redirect /
-m limit -j LOG

The assumption in the final example is that the packet and any additional unmatched redirect packets are silently dropped by the default DROP policy for the INPUT chain.

dstlimit filter TABLE MATCH EXTENSION

The dstlimit match extension enables rate limiting on a per-destination basis, whether per IP address or per port. Note the difference between the dstlimit match extension and the limit match extension, which has one limit for packets of a certain type.

Table 3.14 lists the options for the dstlimit match extension.

Table 3.14. dstlimit Match Extension

OPTION

DEFINITION

--dstlimit <average>

Maximum average match rate in packets per second.

--dstlimit-mode <mode>

Defines the limit to be per IP (dstip ), per IP and port tuple (dstip-dstport ), per source IP and destination IP tuple (srcip-dstip ), or per source IP and destination IP and destination port tuple (srcipdstip-dstport ).

--dstlimit-name <name>

Specifies the name for the file to be placed in /proc/net/ipt_dstlimit/ .

[--dstlimit-burst <burst>]

Specifies the number of packets that should be matched when received as a burst of packets. The default is 5 .

[--dstlimit-htable-size <size>]

Defines the number of buckets in the hashtable.

[--dstlimit-htable-max <entries>]

Defines the limit for the number of entries in the hashtable.

[--dstlimit-htable-gcinterval <interval>]

Defines the length of time between cleanup of the hashtable. The value for <interval> is in milliseconds, with the default being 1000 ms.

[--dstlimit-htable-expire <time>]

Defines the amount of time before an idle entry is purged from the hashtable. The value is in milliseconds, with the default being 10000 ms.


state filter TABLE MATCH EXTENSION

Static filters look at traffic on a packet-by-packet basis alone. Each packet's particular combination of source and destination addresses and ports, the transport protocol, and the current TCP state flag combination is examined without reference to any ongoing context. ICMP messages are treated as unrelated, out-of-band IP Layer 3 events.

The state extension provides additional monitoring and recording technology to augment the stateless, static packet-filter technology. State information is recorded when a TCP connection or UDP exchange is initiated. Subsequent packets are examined not only based on the static tuple information, but also within the context of the ongoing exchange. In other words, some of the contextual knowledge usually associated with the upper TCP Transport layer, or the UDP Application layer, is brought down to the filter layer.

After the exchange is initiated and accepted, subsequent packets are identified as part of the established exchange. Associated ICMP messages are identified as being related to a particular exchange.

(In computer terminology, a collection of values or attributes that together uniquely identify an event or object is called a tuple . A UDP or TCP packet is uniquely identified by the tuple combination of its protocol, UDP or TCP, the source and destination addresses, and the source and destination ports.)

For session monitoring, the advantages of maintaining state information are less obvious for TCP because TCP maintains state information by definition. For UDP, the immediate advantage is the capability to distinguish responses from other datagrams. In the case of an outgoing DNS request, which represents a new UDP exchange, the concept of an established session allows an incoming UDP response datagram from the host and port the original message was sent to, within a certain time-limited window. Incoming UDP datagrams from other hosts or ports are not allowed. They are not part of the established state for this particular exchange. When applied to TCP and UDP, ICMP error messages are accepted if the error message is related to the particular session.

In considering packet flow performance and firewall complexity, the advantages are more obvious for TCP flows. Flows are primarily a firewall performance and optimization technology. The main goal of flows is to allow bypassing the firewall inspection path for a packet. Much faster TCP packet handling is obtained in some cases because the remaining firewall filters can be skipped if the TCP packet is immediately recognized as part of an allowed, ongoing connection. For TCP connections, flow state can be a major win in terms of filtering performance. Also, standard TCP application protocol rules can be collapsed into a single initial allow rule. The number of filter rules is reduced (theoretically, but not necessarily in practice, as you'll see later in the book).

The main disadvantage is that maintaining a state table requires more memory than standard firewall rules alone. Routers with 70,000 simultaneous connections, for example, would require tremendous amounts of memory to maintain state table entries for each connection. State maintenance is often done in hardware for performance reasons, where associative table lookups can be done simultaneously or in parallel. Whether implemented in hardware or software, state engines must be capable of reverting a packet to the traditional path if memory isn't available for the state table entry.

Also, table creation, lookup, and teardown take time in software. The additional processing overhead is a loss in many cases. State maintenance is a win for ongoing exchanges such as an FTP transfer or a UDP streaming multimedia session. Both types of data flow represent potentially large numbers of packets (and filter rule match tests). State maintenance is not a firewall performance win for a simple DNS or NTP client/server exchange, however. State buildup and teardown can easily require as much processingand more memorythan simply traversing the filter rules for these packets.

The advantages are also questionable for firewalls that filter primarily web traffic. Web client/server exchanges tend to be brief and ephemeral.

Telnet and SSH sessions are in a gray area. On heavily trafficked routers with many such sessions, the state maintenance overhead may be a win by bypassing the firewall inspection. For fairly quiescent sessions, however, it's likely that the connection state entry will timeout and be thrown away. The state table entry will be re-created when the next packet comes along, after it has passed the traditional firewall rules.

Table 3.15 lists the options available to the state match extension.

Table 3.15. state Match Extension

-m | --match state OPTION

DESCRIPTION

--state <state>[,<state>]

Matches if the connection state is one in the list. Legal values are NEW , ESTABLISHED , RELATED , or INVALID .


TCP connection state and ongoing UDP exchange information can be maintained, allowing network exchanges to be filtered as NEW , ESTABLISHED , RELATED , or INVALID :

  • NEW is equivalent to the initial TCP SYN request, or to the first UDP packet.

  • ESTABLISHED refers to the ongoing TCP ACK messages after the connection is initiated, to subsequent UDP datagrams exchanged between the same hosts and ports, and to ICMP echo-reply messages sent in response to a previous echo-request .

  • RELATED currently refers only to ICMP error messages. FTP secondary connections are managed by the additional FTP connection tracking support module. With the addition of that module, the meaning of RELATED is extended to include the secondary FTP connection.

  • An example of an INVALID packet is an incoming ICMP error message that wasn't a response to a current session, or an echo-reply that wasn't a response to a previous echo-request .

Ideally, using the ESTABLISHED match allows the firewall rule pair for a service to be collapsed into a single rule that allows the first request packet. For example, using the ESTABLISHED match, a web client rule requires allowing only the initial outgoing SYN request. A DNS client request requires only the rule allowing the initial UDP outgoing request packet.

With a deny-by-default input policy, connection tracking can be used (theoretically) to replace all protocol-specific filters with two general rules that allow incoming and outgoing packets that are part of an established connection, or packets related to the connection. Application-specific rules are required for the initial packet alone.

Although such a firewall setup might very well work for a small or residential site in most cases, it is unlikely to perform adequately for a larger site or a firewall that handles many connections simultaneously. The reason goes back to the case of state table entry timeouts, in which a state entry for a quiescent connection is replaced because of table size and memory constraints. The next packet that would have been accepted by the deleted state entry requires a rule to allow the packet, and the state table entry must be rebuilt.

A simple example of this is a rule pair for a local DNS server operating as a cache-and-forward name server. A DNS forwarding name server uses server-to-server communication. DNS traffic is exchanged between source and destination ports 53 on both hosts. The UDP client/server relationship can be made explicit. The following rules explicitly allow outgoing (NEW ) requests, incoming (ESTABLISHED ) responses, and any (RELATED ) ICMP error messages:

iptables -A INPUT -m state /
--state ESTABLISHED,RELATED -j ACCEPT

iptables -A OUTPUT --out-interface <interface> -p udp /
-s $IPADDR --source-port 53 -d $NAME_SERVER --destination-port 53 /
-m state --state NEW,RELATED -j ACCEPT

DNS uses a simple query-and-response protocol. But what about an application that can maintain an ongoing connection for extended periods, such as an FTP control session or a telnet or SSH session? If the state table entry is cleared out prematurely for some reason, future packets won't have a state entry to be matched against to be identified as part of an ESTABLISHED exchange.

The following rules for an SSH connection allow for that possibility:

iptables -A INPUT -m state /
--state ESTABLISHED,RELATED -j ACCEPT

iptables -A OUTPUT -m state /
 --state ESTABLISHED,RELATED -j ACCEPT

iptables -A OUTPUT --out-interface <interface> -p tcp /
-s $IPADDR --source-port $UNPRIVPORTS /
-d $REMOTE_SSH_SERVER --destination-port 22 /
-m state --state NEW, -j ACCEPT

iptables -A OUTPUT --out-interface <interface> -p tcp ! --syn /
-s $IPADDR --source-port $UNPRIVPORTS /
-d $REMOTE_SSH_SERVER --destination-port 22 /
-j ACCEPT

iptables -A INPUT --in-interface <interface> -p tcp ! --syn /
-s $REMOTE_SSH_SERVER --source-port 22 /
-d $IPADDR --destination-port $UNPRIVPORTS /
-j ACCEPT
ac filter TABLE MATCH EXTENSION

Table 3.16 lists the options available to the mac match extension.

Table 3.16. mac Match Extension

-m | --match mac OPTION

DESCRIPTION

--mac-source [!] <address>

Matches the Layer 2 Ethernet hardware source address, specified as xx:xx:xx:xx:xx:xx: , in the incoming Ethernet frame


Remember that MAC addresses do not cross router borders (or network segments). Also remember that only source addresses can be specified. The mac extension can be used only on an in-interface , such as the INPUT , PREROUTING , and FORWARD chains.

The following rule allows incoming SSH connections from a single local host:

iptables -A INPUT -i <local interface> -p tcp /
 -m mac --mac-source xx:xx:xx:xx:xx:xx /
--source-port 1024:65535 /
-d <IPADDR> --dport 22 -j ACCEPT





owner filter TABLE MATCH EXTENSION

Table 3.17 lists the options available to the owner match extension.

Table 3.17. owner Match Extension

-m | --match owner OPTION

DESCRIPTION

--uid-owner <userid>

Matches on the creator's UID

--gid-owner <groupid>

Matches on the creator's GID

--pid-owner <processid>

Matches on the creator's PID

--sid-owner <sessionid>

Matches on the creator's SID or PPID

--cmd-owner <name>

Matches on a packet created by a process with command name name


The match refers to the packet's creator. The extension can be used on the OUTPUT chain only.

These match options don't make much sense on a firewall router; they make more sense on an end host.

So, let's say that you have a firewall gateway with a monitor, perhaps, but no keyboard. Administration is done from a local, multiuser host. A single user account is allowed to log in to the firewall from this host. On the multiuser host, administrative access to the firewall could be locally filtered as shown here:

iptables -A OUTPUT -o eth0 -p tcp /
-s <IPADDR> --sport 1024:65535 /
-d <fw IPADDR> --dport 22 /
 -m owner --uid-owner <admin userid> /
--gid-owner <admin groupid> -j ACCEPT

mark filter TABLE MATCH EXTENSION

Table 3.18 lists the options available to the mark match extension.

Table 3.18. mark Match Extension

-m | -match mark OPTION

DESCRIPTION

--mark <value>[/<mask>]

Matches packets having the Netfilter-assigned mark value


The mark value and the mask are unsigned long values. If a mask is specified, the value and the mask are AND ed together.

In the example, assume that an incoming telnet client packet between a specific source and destination had been marked previously:

iptables -A FORWARD -i eth0 -o eth1 -p tcp /
-s <some src address> --sport 1024:65535 /
-d <some destination address> --dport 23 /
-m mark --mark 0x00010070 /
-j ACCEPT

The mark value being tested for here was set at some earlier point in the packet processing. The mark value is a flag indicating that this packet is to be handled differently from other packets.

tos filter TABLE MATCH EXTENSION

Table 3.19 lists the options available to the tos match extension.

Table 3.19. tos Match Extension

-m | --match tos OPTION

DESCRIPTION

--tos <value>

Matches on the IP TOS setting


The tos value can be one of either the string or numeric values:

  • minimize-delay, 16, 0x10

  • maximize-throughput, 8, 0x08

  • maximize-reliability, 4, 0x04

  • minimize-cost, 2, 0x02

  • normal-service, 0, 0x00

THE VALUE OF TOS BITS

The TOS bits are of historical interest only. Linux does support their use locally, and various Linux firewall documents refer to the bits and their uses. Nevertheless, the fact remains that the TOS bits are not used or examined generally.


The TOS field has been redefined as the Differentiated Services (DS) field for use by the Differentiated Services Control Protocol (DSCP).

For more information on Differentiated Services, see these sources:

  • RFC 2474, "Definition of the Differentiated Services Field (DS Field) in the IPv4 and IPv6 Headers"

  • RFC 2475, "An Architecture for Differentiated Services"

  • RFC 2990, "Next Steps for the IP QoS Architecture"

  • RFC 3168, "The Addition of Explicit Congestion Notification (ECN) to IP"

  • RFC 3260, "New Terminology and Clarifications for Diffserv"

unclean filter TABLE MATCH EXTENSION

The specific packet-validity checks performed by the unclean module are not documented. The module is considered to be experimental, and the iptables authors recommend against its use for now.

The following line shows the unclean module syntax. The module takes no arguments:

-m | --match unclean

The unclean extension might be "blessed" by the time this book is published. In the meantime, the module lends itself to an example of the LOG options:

iptables -A INPUT -p ! tcp -m unclean /
-j LOG --log-prefix "UNCLEAN packet: " /
--log-ip-options

iptables -A INPUT -p tcp -m unclean /
-j LOG --log-prefix "UNCLEAN TCP: " /
--log-ip-options /
--log-tcp-sequence --log-tcp-options

iptables -A INPUT -m unclean -j DROP

addrtype filter TABLE MATCH EXTENSION

The addrtype match extension is used to match packets based on the type of address used, such as unicast, broadcast, and multicast. The types of addresses include those listed in Table 3.20 .

Table 3.20. Address Types Used with the addrtype Match

NAME

DESCRIPTION

ANYCAST

An anycast packet

BLACKHOLE

A blackhole address

BROADCAST

A broadcast address

LOCAL

A local address

MULTICAST

A multicast address

PROHIBIT

A prohibited address

UNICAST

A unicast address

UNREACHABLE

An unreachable address

UNSPEC

An unspecified address


Two commands are used with the addrtype match, as listed in Table 3.21 .

Table 3.21. addrtype Match Commands

OPTION

DESCRIPTION

--src-type <type>

Matches for addresses with a source of type <type> .

--dst-type <type>

Matches for addresses with a destination of type <type> .


iprange filter TABLE MATCH

Sometimes defining a range of IP addresses using CIDR notation is insufficient for your needs. For example, if you need to limit a certain range of IPs that don't fall on a subnet boundary or cross that boundary by only a couple addresses, the iprange match type will do the job.

Using the iprange match, you specify an arbitrary range of IP addresses for the match to take effect. The iprange match can also be negated. Table 3.22 lists the commands for the iprange match.

Table 3.22. iprange Match Commands

COMMAND

DESCRIPTION

[!] --src-range <ip address-ip address>

Specifies (or negates) the range of IP addresses to match. The range is given with a single hyphen and no spaces.

[!] --dst-range <ip address-ip address>

Specifies (or negates) the range of IP addresses to match. The range is given with a single hyphen and no spaces.


length filter TABLE MATCH

The length filter table match examines the length of the packet. If the packet's length matches the value given or optionally falls within the range given, the rule is invoked. Table 3.23 lists the one and only command related to the length match.

Table 3.23. length Match Command

COMMAND

DESCRIPTION

--length <length>[:<length>]

Matches a packet of <length> or within the range <length:length >


NAT Table Target Extensions

As mentioned earlier, iptables supports four general kinds of NAT: source NAT (SNAT); destination NAT (DNAT); masquerading (MASQUERADE), which is a specialized case of the SNAT implementation; and local port direction (REDIRECT) to the local host. As part of the NAT table, each of these targets is available when a rule specifies the nat table by using the -t nat table specifier.

SNAT NAT TABLE TARGET EXTENSION

Source Address and Port Translation (NAPT) is the kind of NAT people are most commonly familiar with. As shown in Figure 3.5 , Source Address Translation is done after the routing decision is made. SNAT is a legal target only in the POSTROUTING chain. Because SNAT is applied immediately before the packet is sent out, only an outgoing interface can be specified.

 

Figure 3.5. NAT packet traversal.

 


Some documents refer to this form of source NAT (the most common form) as NAPT, to acknowledge the port number modification. The other form of traditional, unidirectional NAT is basic NAT, which doesn't touch the source port. That form is used when you are translating between the private LAN and a pool of public addresses.

NAPT is used when you have a single public address. The source port is changed to a free port on the firewall/NAT machine because it's translating for any number of internal computers, and the port that the internal machine is using might already be in use by the NAT machine. When the responses come back, the port is all that the NAT machine has to determine that the packet is really meant for an internal computer rather than itself and then to determine which internal computer the packet is meant for.

The general syntax for SNAT is as follows:

iptables -t nat -A POSTROUTING --out-interface <interface>  ...  /
-j SNAT --to-source <address>[-<address>][:<port>-<port>]

The source address can be mapped to a range of possible IP addresses, if more than one is available.

The source port can be mapped to a specific range of source ports on the router.

MASQUERADE NAT TABLE TARGET EXTENSION

Source Address Translation has been implemented in two different ways in iptables, as SNAT and as MASQUERADE. The difference is that the MASQUERADE target extension is intended for use with connections on interfaces with dynamically assigned IP addresses, particularly in the case in which the connection is temporary and the IP address assignment is likely to be different at each new connection. As discussed previously, in the section "NAT Table Features ," MASQUERADE can be useful for phone dial-up connections in particular.

Because masquerading is a specialized case of SNAT, it is likewise a legal target only in the POSTROUTING chain, and the rule can refer to the outgoing interface only. Unlike the more generalized SNAT, MASQUERADE does not take an argument specifying the source address to apply to the packet. The IP address of the outgoing interface is used automatically.

The general syntax for MASQUERADE is as follows:

iptables -t nat -A POSTROUTING --out-interface <interface>  ...  /
-j MASQUERADE [--to-ports <port>[-<port>]]

The source port can be mapped to a specific range of source ports on the router.

DNAT NAT TABLE TARGET EXTENSION

Destination Address and Port Translation is a highly specialized form of NAT. A residential or small business site is most likely to find this feature useful if its public IP address is dynamically assigned or if the site has a single IP address, and the site administrator wants to forward incoming connections to internal servers that aren't publicly visible. In other words, the DNAT features can be used to replace the previously required third-party port-forwarding software, such as ipmasqadm .

Referring back to Figure 3.5 , Destination Address and Port Translation is done before the routing decision is made. DNAT is a legal target in the PREROUTING and OUTPUT chains. On the PREROUTING chain, DNAT can be a target when the incoming interface is specified. On the OUTPUT chain, DNAT can be a target when the outgoing interface is specified.

The general syntax for DNAT is as follows:

iptables -t nat -A PREROUTING --in-interface <interface>  ...  /
-j DNAT --to-destination <address>[-<address>][:<port>-<port>]

iptables -t nat -A OUTPUT --out-interface <interface> ... /
-j DNAT --to-destination <address>[-<address>][:<port>-<port>]

The destination address can be mapped to a range of possible IP addresses, if more than one is available.

The destination port can be mapped to a specific range of alternate ports on the destination host.

REDIRECT NAT TABLE TARGET EXTENSION

Port redirection is a specialized case of DNAT. The packet is redirected to a port on the local host. Incoming packets that would otherwise be forwarded on are redirected to the incoming interface's INPUT chain. Outgoing packets generated by the local host are redirected to a port on the local host's loopback interface.

REDIRECT is simply an alias, a convenience, for the specialized case of redirecting a packet to this host. It offers no additional functional value. DNAT could just as easily be used to cause the same effect.

REDIRECT is likewise a legal target only in the PREROUTING and OUTPUT chains. On the PREROUTING chain, REDIRECT can be a target when the incoming interface is specified. On the OUTPUT chain, REDIRECT can be a target when the outgoing interface is specified.

The general syntax for REDIRECT is as follows:

iptables -t nat -A PREROUTING --in-interface <interface>  ...  /
-j REDIRECT [--to-ports <port>[-<port>]]

iptables -t nat -A OUTPUT --out-interface <interface> ... /
-j REDIRECT [--to-ports <port>[-<port>]]

The destination port can be mapped to a different port or to a specific range of alternate ports on the local host.

BALANCE NAT TABLE TARGET EXTENSION

The BALANCE target enables a round-robin method of sending connections to more than one target host. The BALANCE target uses a range of addresses for this purpose and thus provides a rudimentary load-balancing.

The general syntax for BALANCE is as follows:

iptables -t nat -A PREROUTING -p tcp -j BALANCE /
--to-destination <ip address>-<ip address>

The CLUSTERIP target also provides some of these same options.

mangle Table Commands

The mangle table targets and extensions apply to the OUTPUT and PREROUTING chains. Remember, the filter table is implied by default. To use the mangle table features, you must specify the mangle table with the -t mangle directive.

mark mangle TABLE TARGET EXTENSION

Table 3.24 lists the target extensions available to the mangle table.

Table 3.24. mangle Target Extensions

-t mangle OPTION

DESCRIPTION

-j MARK --set-mark <value>

Sets the value of the Netfilter mark value for this packet

-j TOS --set-tos <value>

Sets the TOS value in the IP header


There are two mangle table target extensions: MARK and TOS . MARK contains the functionality to set the unsigned long mark value for the packet maintained by the iptables mangle table.

An example of usage follows:

iptables -t mangle -A PREROUTING --in-interface eth0 -p tcp /
-s <some src address> --sport 1024:65535 /
-d <some destination address> --dport 23 /
-j MARK --set-mark 0x00010070

TOS contains the functionality to set the TOS bits in the IP header.

An example of usage follows:

iptables -t mangle -A OUTPUT ...  -j TOS --set-tos <tos>

The possible tos values are the same values available in the filter table's TOS match extension module.

MATLAB - 利用非线性模型预测控制(Nonlinear MPC)来控制四旋翼飞行器 本示例展示了如何利用非线性模型预测控制(MPC)为四旋翼飞行器设计一个跟踪轨迹的控制器。 阅读详情

相关推荐

从网格剖分到结果外推:一文拆解HFSS快速扫频(Fast Sweep)的底层逻辑与性能调优

本文深入解析了HFSS快速扫频(Fast Sweep)技术的底层逻辑与性能调优方法。通过ALPS算法实现频带外推,快速扫频相比离散扫频和插值扫频能提升3-5倍计算效率,特别适用于天线阵列、微波滤波器等宽频带分析场景。文章详细介绍了算法架构、参数优化策略及工程实践中的精度保障机制,帮助工程师高效完成电磁仿真。

weixin_28693447的博客 92

如何用iptables实现NAT

准备工作: 1)在使用iptables防火墙之前,必须先打开IP转发功能。# echo “1” > /proc/sys/net/ipv4/ip_forward2)以上内容(第6步生成的内容)保存到 /etc/sysconfig/iptables文件中。3)每修改一次iptables文件后,都要重启iptalbes    # service iptables re

ruixj的专栏 2万+

详解modbus TCP通讯,并利用其实现欧姆龙PLC和西门子PLC的通讯

大家好,之前需要更新的MQTT通讯【2】因为硬件不足还不能发布出来,但最近在项目中涉及到西门子和欧姆龙之间的modbus TCP通讯,想到modbus TCP通讯是个非常常见并广泛使用的通讯协议,今天就结合最近做的测试给大家好好讲解一下,先提示一下,这边只给大家讲解如何实现,至于报文是什么,如何用socket来编写功能块或dll这边不会讲解,这块我会根据私信的小伙伴数量来考虑要不要出一篇如何用ST语言来编写modbus TCP功能块的博客。

dy186187的博客 1万+

Iptables Tutorial 1.2.1(3)

Chapter 12. Debugging your scripts One of the big and underestimated sides of writing your own rulesets is how to debug the rulesets on your own, and how to find where you have done your mistakes in the rulesets. This chapter will show you a few basic ste

子曰小玖的博客 2598

西电微机系统课程设计步进电机开环控制系统

** 微机系统与应用课程设计 课题二 步进电机开环控制系统设计** 一、程设计目的 掌握微机系统总线与各芯片管脚连接方法,提高接口扩展硬件电路的连接能力。 加深对 A/D 和并行接口芯片的工作方式和编程方法的理解。 搞懂步进电机的工作原理及控制方式,掌握开环控制系统的设计思路和实现方法。 二、课程设计的内容 手动调节电位器旋钮(0V~5V),通过 ADC0809 模拟输入水库水位 0 米~50...

qq_37015775的博客 4038

HDFView安装及使用教程

简介:直接用记事本打开hdf5文件的话,是一团乱码。HDFView是用来查看hdf5文件的软件,可以免费使用,好多人都有闪退的情况,这是因为没有添加环境变量。

qq_43722079的博客 7万+

iptables raw表

转载地址:http://hi.baidu.com/farmerluo/blog/item/21e8dab45688c87e8ad4b261.html 1)  什么是raw表?做什么用的? iptables有5个链:PREROUTING,INPUT,FORWARD,OUTPUT,POSTROUTING,4个表:filter,nat,mangle,raw. 4个表的优先级由高到低的顺

leo_wanta的专栏 2653

processing与arduino互动编程

Arduino开发板对AVR单片机二次编译封装,无需考虑单片机编程寄存器、地址指针等复杂细节processing借助arduino读取各种传感器的数值,控制各种机电装置。

weixin_45679408的博客 824

iptables 详解(NAT)

前提基础: 当主机收到一个数据包后,数据包先在内核空间中处理,若发现目的地址是自身,则传到用户空间中交给对应的应用程序处理,若发现目的不是自身,则会将包丢弃或进行转发。 iptables实现防火墙功能的原理是:在数据包经过内核的过程中有五处关键地方,分别是PREROUTING、INPUT、OUTPUT、FORWARD、POSTROUTING,称为钩子函数,iptables这款用户空间的

changexhao的专栏 6647

《第二十二篇》Cross-Attention:注意力机制详解-代码实现和公式详解《二》

本文详细介绍了Cross-Attention的原理、公式和实现。Cross-Attention用于Transformer解码器和Encoder-Decoder结构,通过查询向量(Q)与键、值向量(K、V)的交互实现序列对齐。核心公式为softmax(QK^T/√d_k)V,其中Q来自Decoder,K、V来自Encoder。文章还给出了多头注意力机制公式和PyTorch实现代码,包括投影计算、注意力分数计算和输出处理。代码示例展示了如何构建一个完整的Cross-Attention模块,并演示了其在解码器查询

guoguozgw的博客 2210

FANUC机器人_CRX协作机器人的开机和示教器的初始化设置基本步骤(二)

FANUC机器人_CRX协作机器人的开机和示教器的初始化设置基本步骤

Robot_PLC_HMI_Automation 2732

防火墙开放相应端口 3306 开启方式 和 iptables: Index of insertion too big. 和 Unknown operation ‘iptables‘

3306 开启方式 通过以下命令查询,3306端口,竟然返回空的,3306端口没有开启 netstat -an|grep 3306 然后就使用以下命令 iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT 来开启3306,但是显示以下错误 iptables: Index of insertion too big. 是什么原因呢? 还有什么方法可以开启3306的端口吗? 需要做远程链接

huaishitou的专栏 1万+

YOLOv8改进策略【Conv和Transformer】| CVPR-2023 BiFormer 稀疏自注意力,减少内存占用

本文记录的是利用双级路由注意力机制优化的目标检测网络模型。传统的复杂度高,随着输入空间分辨率增加,计算量呈平方增长,导致严重的可扩展性问题。而本文所使用的在获取全局信息的同时,通过区域到区域路由和令牌到令牌注意力的合理设计,减少了不必要的计算量。BiFormer: Vision Transformer with Bi-Level Routing Attention采用四阶段金字塔结构,与一些先进的视觉Transformer类似。在每个阶段,首先使用重叠的补丁嵌入(在第一阶段)或补丁合并模块(在第二到第四阶段

Limiiiing的博客 614

iptables语法

zhubinqiang的专栏 594

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

Iptables的规则语法

(一) 基本语法 iptables-t filter -A INPUT -p icmp -j DROP 高级语法 iptables-t filter -A INPUT -m mac –mac-source 00:1C:23:3B:2E:B1 -j DROP 区别高级语法与基本语法的不同:首先filter的机制是由iptables_filter.ko模块所提供的功能,而这个模块本身就已提供

无心出岫 8485

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

iptables系列教程(二)| iptables语法规则

目录 iptables 命令基本语法 -t table command参数 条件匹配参数 目的动作 iptables 常用附加模块: iptables 规则备份和恢复 iptables 命令基本语法 “ iptables [-t table] command [链名] [条件匹配] [-j 目标动作] 以下是对 iptables 命令的拆分讲解: -t table 用来指明使用的表,有三种选项:filter,nat,mangle。若未指定,则默认使用filter表。 com.

Dragon的博客 4504

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

iptables之语法

一iptables概念 防火墙分类 分为硬件防火墙和软件防火墙 硬件防火墙一般放在外网的最前面,公司的拓扑的最外面 iptables虽然称为防火墙,但是不能当做整个公司的出口防火墙,和动戈几千万,几百万的硬件防火墙还是不能相比的一般用来在公司的局域网做防护,还可以在服务器上做一些端口,流量,安全防护. 但是真的有人盯上了,当大流量打过来的时候,没有硬件高防设备来保护,还是会瘫痪的 iptabl...

weixin_30644369的博客 213

10、7 iptables语法

iptables命令是Linux上常用的防火墙软件,是netfilter项目的一部分。可以直接配置,也可以通过许多前端和图形界面配置。 语法: iptables [options] [参数] Options: -n:不针对IP反解析主机名 -v:显示更详细的信息 -t:指定表(iptables...

chunyouban0052的博客 176

【网络】iptables 2 查看规则语法、添加规则语法

参数 简写 含义 --table -t 指定规则表,缺省时指向filter表 --list -L 列出一个链或全部链的规则,查看操作必带该参数,但可以不指定值指定值,仅列出指定链的规则;不指定值,则列出全部链的规则 例子 说明 iptables -t 表名 -L 查看对应表的所有规则-t选项指定要操作的表,省略"-t 表名"时,默认表示操作filter表,-...

m0_45406092的博客 1189

Iptables命令语法

命令语法: iptables [-t 表名] <-A | I | D | R> <链名> [规则编号] [-i(in) | o(out) 网卡名称] [-p 协议类型] [-s 源IP地址 | 源子网] [--sport 源端口号] [-d 目标IP地址 | 目标子网] [--dport 目标端口号] <-j 动作>注释:[-t 表名]:指默认策略将应用于哪个...

xwupiaomiao的博客 385

02iptables语法

ACCEPT:允许通过 DROP:直接丢弃,不给出任何回应 REJECT:拒绝通过,必要时会给出提示 LOG:记录日志信息,然后传给下一条规则继续匹配

weixin_46686336的博客 221

8、iptables 语法规则

文章目录1.语法构成2.常见的动作类型3.添加新的规则4.查看规则列表5.删除清空规则6.设置默认策略7.通用匹配8.隐含匹配9.显示匹配10.SNAT11.DNAT12.备份和还原 1.语法构成 iptables [-t 表名] 选项 [链名] [条件] [-j 控制类型] 注意事项: 不指定表名时,默认指filter表 不指定链名时,默认指表内的所有链 选项、链名、控制类型使用大写字母,其余均为小写 2.常见的动作类型 ACCEPT:允许通过 DROP:直接丢弃,不给出任何回应 REJECT:拒绝

LiuWei 790

iptables 命令格式、语法

转自:[url=http://hi.baidu.com/linuxtrip/item/67b8b54636fa613afa896091]第三章:iptables语法 --- 重点(转)[/url] [b]iptables [/b]是与Linux 内核集成的 IP 信息包过滤系统。如果 Linux 系统连接到因特网或 LAN、服务器或代理服务器, 利用该系统有利于在 Linux 系统上更好地控...

如果你真的想做一件事,你一定会找到方法; 如果你不想做一件事,你一定会找到借口。 247

iptables 指令语法

iptables 指令语法 iptables [-t table] command [match] [-j target/jump] [-t table] 指定规则表 -t 参数用来,内建的规则表有三个,分别是:nat、mangle 和 filter,当未指定规则表时,则一律视为是 filter。个规则表的功能如下: nat:此规则表拥有 PREROUTING 和 POSTROUTING 两个规则...

下一站浮华的博客 477

【转】iptables__规则语法

http://www.cnblogs.com/linuxer/archive/2012/04/19/2870537.html (一)基本语法iptables-t filter -A INPUT -p icmp -j DROP 高级语法iptables-t filter -A INPUT -m mac –mac-source 00:1C:23:3B:2E:B1 -j DRO...

Lucius0504的博客 155

iptables基本介绍与语法

防火墙 iptables 基本管理 》安装 iptables-services 并启动服务,默认已经安装,不要使用yum卸载,会将依赖卸载导致网络出现问题。 iptables 四表五链: 1)iptables 的 4 个表(区分大小写) : nat (地址转换表) (INPUT OUTPUT PREROUTIN POSTROUTING) filter (数据过滤表) (INPUT OUTPUT ...

weixin_46389364的博客 300
上一篇: Linux下的优秀开源软件
下一篇: Linux iptables防火墙构建示例
zzulp
博客等级 码龄19年 464粉丝 176原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值