Networking Forums

Networking Forums > Computer Networking > Linux Networking > Ping second NIC over wire(ignoring loopback)

Reply
Thread Tools Display Modes

Ping second NIC over wire(ignoring loopback)

 
 
Giro
Guest
Posts: n/a

 
      12-06-2011, 07:47 AM
Hi,

Is there any way to let two local network interfaces communicate with
each other without using the loopback device?

On the same computer, I have interfaces eth1 (192.168.0.11) and eth2
(192.168.0.12). I want to
ping from eth1 to eth2, and make the packet physically hit the wire,
instead of going through the loopback device.

The same issue has been posted a while ago without any solution. I
hope someone has an idea today.

https://groups.google.com/group/comp...0bf3538cd67224

Thanks
Giro
 
Reply With Quote
 
 
 
 
Pascal Hambourg
Guest
Posts: n/a

 
      12-06-2011, 09:36 PM
Hello,

Giro a écrit :
>
> Is there any way to let two local network interfaces communicate with
> each other without using the loopback device?


Not easily.
First, the kernel forces packets with a local destination address
through the loopback interface. Second, the kernel discards packets
received on a non-loopback interface with a local source address.

> On the same computer, I have interfaces eth1 (192.168.0.11) and eth2
> (192.168.0.12). I want to
> ping from eth1 to eth2, and make the packet physically hit the wire,
> instead of going through the loopback device.


The above restrictions can be worked around with iptables NAT rules and
static ARP entries, tricking the kernel into believing that it is
communicating with a remote host. Sensitive people beware : what follows
is ugly.

Say that "remote" eth1 will be seen as 192.168.0.21 and "remote" eth2 as
192.168.0.22.

# make sure packets to "remote" addresses are routed through the correct
# interface
ip route add 192.168.0.21 dev eth2
ip route add 192.168.0.22 dev eth1

# create static ARP entries for the remote addresses
arp -s 192.168.0.21 $eth1_mac_address
arp -s 192.168.0.22 $eth2_mac_address

# replace the source address of outgoing packets with the "remote"
# addresses
iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to 192.168.0.21
iptables -t nat -A POSTROUTING -o eth2 -j SNAT --to 192.168.0.22

# replace the destination address of incoming packets with the real
# local addresses
iptables -t nat -A PREROUTING -i eth1 -j DNAT --to 192.168.0.11
iptables -t nat -A PREROUTING -i eth2 -j DNAT --to 192.168.0.12

With this a packet sent to 192.168.0.21 or 192.168.0.22 and its reply
should go on the wire.
 
Reply With Quote
 
Rick Jones
Guest
Posts: n/a

 
      12-06-2011, 10:47 PM
Giro <(E-Mail Removed)> wrote:
> Is there any way to let two local network interfaces communicate
> with each other without using the loopback device?


> On the same computer, I have interfaces eth1 (192.168.0.11) and eth2
> (192.168.0.12). I want to ping from eth1 to eth2, and make the
> packet physically hit the wire, instead of going through the
> loopback device.


> The same issue has been posted a while ago without any solution. I
> hope someone has an idea today.


> https://groups.google.com/group/comp...0bf3538cd67224


If you are not particularly tied to the "ping" being an ICMP Echo
Request and Exho Response, and are content to simply know that the two
interfaces can speak to one another, there is a linux port of the
HP-UX linkloop command. I believe a SLES 11 package exists, and one
can go to http://sourceforge.net/projects/linkloop/ .

rick jones
--
The glass is neither half-empty nor half-full. The glass has a leak.
The real question is "Can it be patched?"
these opinions are mine, all mine; HP might not want them anyway...
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      12-13-2011, 01:37 AM
On Dec 6, 12:47*am, Giro <giray.curgu...@gmail.com> wrote:

> On the same computer, I have interfaces eth1 (192.168.0.11) and eth2
> (192.168.0.12). *I want to
> ping from eth1 to eth2, and make the packet physically hit the wire,
> instead of going through the loopback device.


Your question is based on a common misunderstanding. Under the end
system model that Linux follows, IP addresses belong to *systems*, not
interfaces. You have two interfaces and you also have two IP
addresses.

You can certainly form a ping request to a MAC address assigned to one
interface and send it out another one. But the operating system's IP
stack will play no part in your shenanigans.

DS
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: problem with ethernet loopback test using loopback plug/stub: receiving socket not seeing packet. Rick Jones Linux Networking 10 08-22-2010 07:17 PM
Is Ignoring Michael (TKIP) a mad/bad idea? Adrian C Home Networking 8 06-21-2010 05:04 PM
UK phone spammer ignoring TPS, something.info. Spin Dryer Broadband 12 03-17-2009 07:11 PM
Linux ignoring SYN packets ErMejo Linux Networking 7 05-22-2008 08:45 AM
BT ignoring pings on their routers of late? ale.cx Broadband 1 02-10-2007 11:33 PM



1 2 3 4 5 6 7 8 9 10 11