Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux: disable using loopback and send data via wire between 2 eth cards of one comp [closed]

I have a comp with 2 eth cards, connected with patch-cord (direct eth. cable from 1st to 2nd).

The linux is installed, I want to send data from 1st network card to 2nd. And I want to force the packet to pass via cable. I can set up any ip on cards.

With ping I get counters on cards constant.

Is it possible with tcp/ip sockets?

PS. I need to write a program. which will send packets via eth, so stackoverflow-related question. There can be some OS-dependent way, they will help me too

like image 984
osgx Avatar asked Apr 29 '10 01:04

osgx


People also ask

What is loopback Linux?

A loopback device in Linux is a virtual device that can be used like any other media device. Examples of normal media devices are hard disk partitions like /dev/hda1 , /dev/hda2 , /dev/sda1 , or entire disks like the floppy disk /dev/fd0 etc.

What is the purpose of loopback?

The loopback interface is used to identify the device. While any interface address can be used to determine if the device is online, the loopback address is the preferred method. Whereas interfaces might be removed or addresses changed based on network topology changes, the loopback address never changes.

What is loopback in Ifconfig?

The loopback address is the reserved network interface that is used by the local machine to allow interprocess communication. This enables the host to send packets to itself. The ifconfig command uses the loopback address for configuration and testing, as explained in ifconfig Command.


1 Answers

Have a look in local routing table. With iproute2 tools installed do ip route show table local. As you can see, all packets destinated to your local IPs would never go thru NICs since they are marked as local.

To force packets go via ethernet card remove the appropriate route (i.e. ip route delete 192.168.122.1 dev eth0 table local). To restore this route just set the interface down and up: the kernel would do the work to insert these routes.

like image 186
PoltoS Avatar answered Oct 20 '22 19:10

PoltoS