- 论坛徽章:
- 0
|
arp_filter:
when
/proc/sys/net/ipv4/conf/DEV/arp_filter is set to 1
or
/proc/sys/net/ipv4/conf/all/arp_filter is set to 1
then the flag will cause any probe received on interface
DEV to be dropped if the route from TARGET to SENDER points
to different interface. With the usual local networks in
table main in the form "from 0/0 to local_net lookup main"
we see that the TARGET is ignored. As result, we drop
probes received from SENDER that comes from wrong
interface. As result, if the route from TARGET to
SENDER1 is via DEV1 and from TARGET to SENDER2 is
via DEV2, then we will reply only through one device
for each of the senders. Of course, the arp_filter
relies on the routing and as result the bahavior
depends on the used ip rules and routes. The above
is a simple example for normal local networks. The
arp_filter simply checks the route for the reversed
addresses. It should point to the input device.
rp_filter:
The rp_filter flag (DEV/rp_filter or all/rp_filter)
set to 1 has similar semantic. It has nearly the same
function as arp_filter and can control the ARP for
the same purposes: symmetric talks (in and out using
same device) but it covers the IP traffic too. It is
assumed that where ARP is received (replied more
exactly) there the IP traffic will be accepted too.
It has mostly security function and can defend
against IP spoofing. It controls the reverse path
protection: we accept traffic from SENDER to TARGET
received on DEV only when the reverse path (from
TARGET to SENDER) points to the input interface
DEV. It is used usually for "external" interfaces.
How you can use it:
ifconfig eth0 192.168.1.2
ifconfig eth1 192.168.2.2
echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_filter
echo 1 > /proc/sys/net/ipv4/conf/eth1/arp_filter
arp_annouce and arp_ignore have been used in LVS commonly.
arp_announce - INTEGER
Define different restriction levels for announcing the local
source IP address from IP packets in ARP requests sent on
interface:
0 - (default) Use any local address, configured on any interface
1 - Try to avoid local addresses that are not in the target's
subnet for this interface. This mode is useful when target
hosts reachable via this interface require the source IP
address in ARP requests to be part of their logical network
configured on the receiving interface. When we generate the
request we will check all our subnets that include the
target IP and will preserve the source address if it is from
such subnet. If there is no such subnet we select source
address according to the rules for level 2.
2 - Always use the best local address for this target.
In this mode we ignore the source address in the IP packet
and try to select local address that we prefer for talks with
the target host. Such local address is selected by looking
for primary IP addresses on all our subnets on the outgoing
interface that include the target IP address. If no suitable
local address is found we select the first local address
we have on the outgoing interface or on all other interfaces,
with the hope we will receive reply for our request and
even sometimes no matter the source IP address we announce.
The max value from conf/{all,interface}/arp_announce is used.
Increasing the restriction level gives more chance for
receiving answer from the resolved target while decreasing
the level announces more valid sender's information.
arp_ignore - INTEGER
Define different modes for sending replies in response to
received ARP requests that resolve local target IP addresses:
0 - (default): reply for any local target IP address, configured
on any interface
1 - reply only if the target IP address is local address
configured on the incoming interface
2 - reply only if the target IP address is local address
configured on the incoming interface and both with the
sender's IP address are part from same subnet on this interface
3 - do not reply for local addresses configured with scope host,
only resolutions for global and link addresses are replied
4-7 - reserved
8 - do not reply for all local addresses
The max value from conf/{all,interface}/arp_ignore is used
when ARP request is received on the {interface}
Note:
1. The arp problem only occurs on Linux with kernels 2.2 and later.Other OS's honor the arp flag.
2. arp_ignore works only on physical interfaces. The old eth0:0 notation is a hang-over from the days of ip aliases, where in a round-about way you could establish virtual interfaces (sort of). These days an interface can have 0 or more addresses. The arp_ignore semantics apply to such addresses.
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/42903/showart_390354.html |
|