Someone might have noticed that if you have a point-to-point link and an
Ethernet or similar link in the same machine, they have the same interface
(IP) address and thus cannot be firewalled with the normal interface-based
firewall in the Linux (1.2.x at least) networking code. Here's a patch for
that.
This changes the firewalling code so that the interface address specified to
ipfw (iface xxx.xxx.xxx.xxx) is the address of the _other_ end of the link
(not this machine) for point-to-point links (and this machine's address for
all other links, as it has always been).
This has been tested (on my own system for about a week), and I have mailed
it to Alan Cox.
Patch to Linux 1.2.13 linux/net/inet/ip_fw.c follows; I place it in the
public domain. The only fix to /sbin/ipfw this needs is a correction to the
man page to say that the interface address is the other end of the link for
point-to-point links.
--- ip_fw.c.org Fri Nov 17 18:59:46 1995
*/
if(f->fw_via.s_addr && rif)
{
- if(rif->pa_addr!=f->fw_via.s_addr)
- continue; /* Mismatch */
+ /*
+ * For point-to-point links, the address is
+ * the address of the other end of the link;
+ * for others, the interface address
+ */
+ if(rif->flags&IFF_POINTOPOINT)
+ {
+ if (rif->pa_dstaddr!=f->fw_via.s_addr)
+ continue; /* Mismatch */
+ }
+ else
+ {
+ if (rif->pa_addr!=f->fw_via.s_addr)
+ continue; /* Mismatch */
+ }
}
/*
* Drop through - this is a match
--