Host primary interface address as source address in IP header

Host primary interface address as source address in IP header

Post by Ron Wa » Sun, 17 May 1998 04:00:00



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
internal LAN.

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?

Ron

 
 
 

1. Host primary interface address as source address in IP header

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
internal LAN.

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?

Ron

2. backspace key

3. ICMP HOST cannot build IP Header address to echo ICMP HOST

4. Free software listings?

5. Checksum of ip headers : is it changed when switching source and dest addresses ?

6. Boot loses keyboard

7. Can't ping the host name or host IP address from host.

8. I want to get rid of Kerberos. How?

9. Setting default source IP address with multiple interface machine?

10. Multiple IP addresses (or hosts) on one LAN interface

11. Can an network interface have no pre-defined IP source address?

12. Changing IP address on Solaris 9 with multiple virtual IP addresses

13. WANTED: pingmac <IP ADDR> which returns <MAC ADDRESS of IP ADDRESS>