Linux: disable the use of loopback and send data through the wire between 2 eth cards of one comp

I have a comp with 2 cards associated with a patch cord (live broadcast from 1st to 2nd).

Linux is installed, I want to send data from the 1st network card to the 2nd. And I want to make the packet go through the cable. I can configure any ip on the cards.

With ping, I get constant counters on the cards.

Is this possible with tcp / ip sockets?

PS. I need to write a program. which will send packets through eth, so the stackoverflow related question. Maybe some OS-dependent way, they will help me too.

+5
source share
3 answers

. iproute2 ip route show table local. , , IP-, NIC, .

Ethernet-, (.. ip route delete 192.168.122.1 dev eth0 table local). , : ​​ .

+5

ip route... table local . , - .

, IP-, ​​ , NAT, IP-.

eth0 eth1 - ethernet; IP0 IP1 - IP-; MAC0 MAC1 - MAC-. IP-: IP00 IP11.

arp -s IP00 MAC0
arp -s IP11 MAC1
ip route add IP00 dev eth1
ip route add IP11 dev eth0
iptables -t nat -A POSTROUTING -d IP11 -j SNAT --to-source IP00
iptables -t nat -A POSTROUTING -d IP00 -j SNAT --to-source IP11
iptables -t nat -A PREROUTING -d IP00 -j DNAT --to-destination IP0
iptables -t nat -A PREROUTING -d IP11 -j DNAT --to-destination IP1

IP- IP00 IP11 .

+4

, ( PF_PACKET), IP .

0

All Articles