1

I'm wondering one thing. I'm playing with an EC2 instance and would like to use some local subnet in the 192.168.1.0/29 range. So I've setup aliases on eth0 as follow:

[root@server jvehent]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 12:25:8B:0a:B1:EB  
          inet addr:10.28.118.95  Bcast:10.28.118.255  Mask:255.255.254.0
[...]
eth0:1    Link encap:Ethernet  HWaddr 12:25:8B:0a:B1:EB    
          inet addr:192.168.1.1  Bcast:192.168.1.7  Mask:255.255.255.248
[...]
eth0:2    Link encap:Ethernet  HWaddr 12:25:8B:0a:B1:EB    
          inet addr:192.168.1.2  Bcast:192.168.1.7  Mask:255.255.255.248
[...]
eth0:3    Link encap:Ethernet  HWaddr 12:25:8B:0a:B1:EB    
          inet addr:192.168.1.3  Bcast:192.168.1.7  Mask:255.255.255.248
[...]
eth0:4    Link encap:Ethernet  HWaddr 12:25:8B:0a:B1:EB  
          inet addr:192.168.1.4  Bcast:192.168.1.7  Mask:255.255.255.248
[...]
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0

Very well, so I get the following routing table

[root@server jvehent]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0    0.0.0.0         255.255.255.248 U     0      0        0 eth0
10.28.118.0     0.0.0.0         255.255.254.0   U     0      0        0 eth0
0.0.0.0         10.28.118.1     0.0.0.0         UG    0      0        0 eth0

Now, If I want two services to talk to each other using the local aliases, I can set netcat as follow:

listening netcat:

nc -l 192.168.1.4 1664

connecting netcat:

nc -s 192.168.1.1 192.168.1.4 1664

And, from what I see, that traffic goes through the localhost interface. I'm checking with tcpdump -i lo and I see packets going through. Nothing on eth0.

My basic knowledge of the kernel tell me that since the kernel owns all the ip, it does all the operations internally and copy the packets from a socket to another without passing it to the NIC. correct ?

Is there a way to force the kernel to send those packets on the network ?

2
  • Can you tell me why you would want to force it?
    – Zoredache
    May 26, 2011 at 7:20
  • I don't. I'm purely to satisfy my curiosity :) May 26, 2011 at 21:06

1 Answer 1

1

Yes, No. Yep the kernel short circuits it by passing it to the loopback interface. No you couldn't send them out to the network because the network wouldn't send them back. The NIC can send or receive a packet, it can't both send the packet and receive it back at the same time. (Perhaps a switch could be programmed to simulate this, but you're on an EC2 instance, and there is no switch in the first place; heck there's no NIC)

2
  • you probably mean that the NIC cannot loop on itself ? I wanted to send the packet over the wire directly to the switch and back. May 26, 2011 at 1:25
  • 1
    Honestly I'm not sure how NIC hardware/firmware or a switch would handle a packet that has the same source and destination, it certainly wouldn't make sense. Further, neither are real in the case of EC2, you can't send a packet on the wire because there is no wire. In EC2 you're dealing with a virtual machine, that means there is no actual machine, no actual NIC, no actual switch; it's all 'virtual' bits running around a hypervisor.
    – Chris S
    May 26, 2011 at 3:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .