Re: Sending a packet with 127.0.0.2 source address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I looked my kernel sources ( v2.6.25.20 ) and did not find this macro.
The checks in route.c are made by ipv4_is_loopback() function which is defined
in include/linux/in.h as of:
static inline bool ipv4_is_loopback(__be32 addr)
{
	return (addr & htonl(0xff000000)) == htonl(0x7f000000);
}

but I would not like to modify it as it may touch other programms. All
what I need is to send requests with 127.x source IPs through NATed
interface and receive responses to them. The patching of the route.c
checks just do the thing. But your idea is good when you need a
special private subnet not affected by another subnets. Thanks for the
suggestion.

2009/4/27 Jeff Haran <jharan@xxxxxxxxxxx>:
> Just an FYI, another option that I have useful in the past to enable
> this kind of thing is to modify the definition of the LOOPBACK(x) macro
> in include/linux/in.h to exclude from consideration the subset of the
> 127/8 network that you don't want the stack to interpret as a loopback
> network. For example, changing this:
>
> #define LOOPBACK(x) (((x) & htonl(0xff000000)) == htonl(0x7f000000))
>
> to this:
>
> #define LOOPBACK(x) ((((x) & htonl(0xff000000)) == htonl(0x7f000000)) &&
> \
>                        (((x) & htonl(0x00ff0000)) !=
> htonl(0x00010000)))
>
> enables the stack to treat 127.1/16 as a "normal" non-loopback address
> range.
>
> This can be handy in the creation of private IPv4 networks that wont
> conflict with the address ranges assigned to other external network
> interfaces on the hosts using the private 127.1/16 network when you
> don't have control over the network addresses being assigned to those
> external networks.
>
> I don't know if that is sufficient for make NAT work the way you want.
>
> Jeff Haran
>



-- 
Best regards
Anatoly Muliarski
--
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux