Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.networking > #881
| From | Pascal Hambourg <boite-a-spam@plouf.fr.eu.org> |
|---|---|
| Newsgroups | comp.os.linux.networking |
| Subject | Re: Ping second NIC over wire(ignoring loopback) |
| Date | 2011-12-06 23:36 +0100 |
| Organization | Plouf ! |
| Message-ID | <jbm5db$oor$1@saria.nerim.net> (permalink) |
| References | <017af28c-53eb-4fc0-ab46-45944bc1ed49@j10g2000vbe.googlegroups.com> |
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.
Back to comp.os.linux.networking | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Ping second NIC over wire(ignoring loopback) Giro <giray.curgunlu@gmail.com> - 2011-12-06 00:47 -0800
Re: Ping second NIC over wire(ignoring loopback) Pascal Hambourg <boite-a-spam@plouf.fr.eu.org> - 2011-12-06 23:36 +0100
Re: Ping second NIC over wire(ignoring loopback) Rick Jones <rick.jones2@hp.com> - 2011-12-06 23:47 +0000
Re: Ping second NIC over wire(ignoring loopback) David Schwartz <davids@webmaster.com> - 2011-12-12 18:37 -0800
Re: Ping second NIC over wire(ignoring loopback) Mikhail Reznikov <mirekez@gmail.com> - 2024-02-07 04:18 -0800
csiph-web