Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

The loopback network interface "is a virtual network device implemented entirely in software," according to another question on Unix.SE.

But how is this implementation actually accomplished, and how do you manipulate it?

As far as I know, IPs are marked as local in the local routing table:

ip route show table local  

Sending to an IP marked as local will trigger the loopback device. But is this detection done purely by routing tables or also by some other kernel operations?

My ultimate goal is to manipulate the loop-device configuration, so that sending datagrams between two WLAN adapters on my laptop will result in real traffic / datagrams in the network and not in local loops. That is:

Interface 1 -> WLAN -> Interface 2 

and NOT:

Interface 1 -> LOOP -> Interface 2
share
    
...What exactly is it you want to change about its behavior? –  bahamat Aug 27 '12 at 16:09
    
Under what operating system? –  Gilles Aug 27 '12 at 23:50
    
@Gilles, ip route show table local indicates it's Linux –  poige Aug 28 '12 at 2:19
    
cross-post –  don_crissti Aug 28 '12 at 20:53
    
See updated unix.stackexchange.com/a/46448/6622 –  poige Oct 19 '12 at 23:55

2 Answers 2

On a very basic level, it's a device that's implemented purely in software. Similar to the way that a VM is entirely software, so is the loopback (although using quite different mechanisms).

Ordinarily when an interface sends a packet it eventually is put to the wire and flushed. The loopback on the other hand, instead of being put to the wire the outgoing packet is moved to the incoming queue for that interface and then processed like any incoming packet.

While netfilter is evaluating a packet there are two times when a routing decision is made. Once for incoming packets (e.g., was this packet received on the right interface?) and once for outgoing packets (e.g., what interface should this packet be transmitted on?). This routing decision is when the kernel checks the packet against the local routing table.

share

Routing table → device → device driver (loopback)

UPD. (2012-10-20): Recently ran into sysctl's doc.: «…

accept_local - BOOLEAN
    Accept packets with local source addresses. In combination
    with suitable routing, this can be used to direct packets
    between two local interfaces over the wire and have them
    accepted properly.

    rp_filter must be set to a non-zero value in order for
    accept_local to have an effect.

…», so it answers to the 2nd part of your question, hopefully.

share

This site is currently not accepting new answers.

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