I'm running kernel 2.0.32 from Redhat 5.0. I have my Linux box with both
a serial port out to a permanent modem link and an ethernet to my
The ppp is configured with the IP address allocated by the ISP
(139.x.y.z), and I've configured the ethernet with an IP address from my
allocated class C subnet. All is happy, my LAN can gateway through to the
'net, everybody out on the net can get back (yes, I know, the firewall
happens next week :-)).
Anyway, the problem is when I telnet/ftp/other from the Linux box
*itself* to the net. The source address in the IP packets has the address
of the ppp port, not the address reported by gethostbyname. This makes it
difficult for our office (for example) to allow me in by IP address,
because the IP address is something that the DNS refers back to my ISP,
rather than my allocated address.
Anyway, long and involved story, but it caused me to start grovelling
around in the networking source (it was also an excuse to start hacking
Linux). I worked my way through connect() and found ip_my_addr() in
net/ipv4/devinet.c. This allocated the loopback address (127.0.0.1) to
the source address of an outgoing IP packet. Later, ip_build_header in
net/ipv4/ip_output.c replaces the loopback address with either the source
address of the route or the interface address of the outgoing port.
I hesitate greatly before saying that this is wrong, but I would have
thought that the first address returned from gethostbyname(hostname()) is
what should be in the source IP address of the packet.
Am I off the beaten track, totally confused, got it all wrong, or <gasp>
found a bug?