Copyright © 2001-2006 Thomas M. Eastep
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover, and with no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.
Proxy ARP (RFC 1027) is a way to make a machine physically located on one network appear to be logically part of a different physical network connected to the same router/firewall. Typically it allows us to hide a machine with a public IP address on a private network behind a router, and still have the machine appear to be on the public network "in front of" the router. The router "proxys" ARP requests and all network traffic to and from the hidden machine to make this fiction possible.
Consider a router with two interface cards, one connected to a public network PUBNET and one connected to a private network PRIVNET. We want to hide a server machine on the PRIVNET network but have it accessible from the PUBNET network. The IP address of the server machine lies in the PUBNET network, even though we are placing the machine on the PRIVNET network behind the router.
By enabling proxy ARP on the router, any machine on the PUBNET network that issues an ARP "who has" request for the server's MAC address will get a proxy ARP reply from the router containing the router's MAC address. This tells machines on the PUBNET network that they should be sending packets destined for the server via the router. The router forwards the packets from the machines on the PUBNET network to the server on the PRIVNET network.
Similarly, when the server on the PRIVNET network issues a "who has" request for any machines on the PUBNET network, the router provides its own MAC address via proxy ARP. This tells the server to send packets for machines on the PUBNET network via the router. The router forwards the packets from the server on the PRIVNET network to the machines on the PUBNET network.
The proxy ARP provided by the router allows the server on the PRIVNETnetwork to appear to be on the PUBNET network. It lets the router pass ARP requests and other network packets in both directions between the server machine and the PUBNET network, making the server machine appear to be connected to the PUBNET network even though it is on the PRIVNET network hidden behind the router.
Before you try to use this technique, I strongly recommend that you read the Shorewall Setup Guide.
The following figure represents a Proxy ARP environment.
Proxy ARP can be used to make the systems with addresses
126.96.36.199 and 188.8.131.52 appear to be on the upper
(130.252.100.*) subnet. Assuming that the upper firewall interface is eth0
and the lower interface is eth1, this is accomplished using the following
#ADDRESS INTERFACE EXTERNAL HAVEROUTE PERSISTENT 184.108.40.206 eth1 eth0 no yes 220.127.116.11 eth1 eth0 no yes
Be sure that the internal systems
(18.104.22.168 and 22.214.171.124 in the above example) are not included
in any specification in
I've used an RFC1918 IP address for eth1 - that IP address is largely irrelevant (see below).
The lower systems (126.96.36.199 and 188.8.131.52) should have their subnet mask and default gateway configured exactly the same way that the Firewall system's eth0 is configured. In other words, they should be configured just like they would be if they were parallel to the firewall rather than behind it.
Do not add the Proxy ARP'ed address(es) (184.108.40.206 and 220.127.116.11 in the above example) to the external interface (eth0 in this example) of the firewall.
It should be stressed that entries in the proxyarp file do not automatically enable traffic between the external network and the internal host(s) — such traffic is still subject to your policies and rules.
While the address given to the firewall interface is largely irrelevant, one approach you can take is to make that address the same as the address of your external interface!
In the diagram above,
has been given the address 18.104.22.168, the same as
eth0. Note though that the VLSM is 32 so there is no
network associated with this address. This is the approach that I take with my DMZ.
To permit Internet hosts to connect to the local systems, you use ACCEPT rules. For example, if you run a web server on 22.214.171.124 which you have configured to be in the loc zone then you would need this entry in /etc/shorewall/rules:
#ACTION SOURCE DEST PROTO DEST # PORT ACCEPT net loc:126.96.36.199 tcp 80
Your distribution's network configuration GUI may not be capable of configuring a device in this way. It may complain about the duplicate address or it may configure the address incorrectly. Here is what the above configuration should look like when viewed using ip (the line "inet 188.8.131.52/32 scope global eth1" is the most important):
gateway:~# ip addr ls eth1 3: eth1: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:a0:cc:d1:db:12 brd ff:ff:ff:ff:ff:ff inet 184.108.40.206/32 scope global eth1 gateway:~#
Note in particular that there is no broadcast address. Here is an
ifcfg-eth-id-00:a0:cc:d1:db:12 file from SUSE that
produces this result (Note: SUSE ties the configuration file to the card
by embedding the card's MAC address in the file name):
BOOTPROTO='static' BROADCAST='220.127.116.11' IPADDR='18.104.22.168' MTU='' NETMASK='255.255.255.255' NETWORK='22.214.171.124' REMOTE_IPADDR='' STARTMODE='onboot' UNIQUE='8otl.IPwRm6bNMRD' _nm_name='bus-pci-0000:00:04.0'
Here is an excerpt from a Debian /etc/network/interfaces file that does the same thing:
... auto eth1 iface eth1 inet static address 126.96.36.199 netmask 255.255.255.255 broadcast 0.0.0.0 ...
A word of warning is in order here. ISPs typically configure their routers with a long ARP cache timeout. If you move a system from parallel to your firewall to behind your firewall with Proxy ARP, it will probably be HOURS before that system can communicate with the Internet.
If you sniff traffic on the firewall's external interface, you can see incoming traffic for the internal system(s) but the traffic is never sent out the internal interface.
You can determine if your ISP's gateway ARP cache is stale using ping and tcpdump. Suppose that we suspect that the gateway router has a stale ARP cache entry for 188.8.131.52. On the firewall, run tcpdump as follows:
tcpdump -nei eth0 icmp
Now from 184.108.40.206, ping the ISP's gateway (which we will assume is 220.127.116.11):
We can now observe the tcpdump output:
13:35:12.159321 0:4:e2:20:20:33 0:0:77:95:dd:19 ip 98: 18.104.22.168 > 22.214.171.124: icmp: echo request (DF) 13:35:12.207615 0:0:77:95:dd:19 0:c0:a8:50:b2:57 ip 98: 126.96.36.199 > 188.8.131.52 : icmp: echo reply
Notice that the source MAC address in the echo request is different from the destination MAC address in the echo reply!! In this case 0:4:e2:20:20:33 was the MAC of the firewall's eth0 NIC while 0:c0:a8:50:b2:57 was the MAC address of the system on the lower left. In other words, the gateway's ARP cache still associates 184.108.40.206 with the NIC in that system rather than with the firewall's eth0.
If you have this problem, there are a couple of things that you can try:
A reading of TCP/IP Illustrated, Vol 1 by Stevens reveals that a “gratuitous” ARP packet should cause the ISP's router to refresh their ARP cache (section 4.7). A gratuitous ARP is simply a host requesting the MAC address for its own IP; in addition to ensuring that the IP address isn't a duplicate...
if the host sending the gratuitous ARP has just changed its hardware address..., this packet causes any other host...that has an entry in its cache for the old hardware address to update its ARP cache entry accordingly.
Which is, of course, exactly what you want to do when you switch a host from being exposed to the Internet to behind Shorewall using proxy ARP (or one-to-one NAT for that matter). Happily enough, recent versions of Redhat's iputils package include “arping”, whose “-U” flag does just that:
arping -U -I <net if> <newly proxied IP> arping -U -I eth0 220.127.116.11 # for example
Stevens goes on to mention that not all systems respond correctly to gratuitous ARPs, but googling for “arping -U” seems to support the idea that it works most of the time.
To use arping with Proxy ARP in the above example, you would have to:
shorewall clear ip addr add 18.104.22.168 dev eth0 ip addr add 22.214.171.124 dev eth0 arping -U -c 10 -I eth0 126.96.36.199 arping -U -c 10 -I eth0 188.8.131.52 ip addr del 184.108.40.206 dev eth0 ip addr del 220.127.116.11 dev eth0 shorewall start
You can call your ISP and ask them to purge the stale ARP cache entry but many either can't or won't purge individual entries.
There are two distinct versions of arping available:
arping by Thomas Habets (Debian package arping).
arping as part of the iputils package by Alexey Kuznetsov (Debian package iputils-arping).
You want the second one by Alexey Kuznetsov.
 Courtesy of Bradey Honsinger