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
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With