Networking Forums

Networking Forums > Computer Networking > Linux Networking > Dual NIC and crossover cable

Reply
Thread Tools Display Modes

Dual NIC and crossover cable

 
 
devlin
Guest
Posts: n/a

 
      08-04-2005, 09:32 PM
Hello,
I'm having a bit of a odd networking problem.

I've got a linux 2.4 computer with two network cards and would
like to ping from one port to the other through a crossover
cable. (it's for basic hardware verification).

If I just ping the other NIC linux is clever enough and route it
through the loopback instead, so I have turned off loopback interface.

lo : off
eth0 : 192.168.2.2
eth1 : 192.168.2.5

By adding an explicit -host route for the 'other' network card I am
able to send out ping echo request on eth0 (as seen on the
LED/iptables/sniffer)
# ping -I eth0 192.168.2.5

But I don't recive any echo request on eth1 (according to
iptables/sniffer).
Where does this ping end up ?

I must be doing something wrong..any suggestions ?

Thanks.
Devlin

 
Reply With Quote
 
 
 
 
David Efflandt
Guest
Posts: n/a

 
      08-05-2005, 01:10 AM
On 4 Aug 2005 14:32:19 -0700, devlin <(E-Mail Removed)> wrote:
> Hello,
> I'm having a bit of a odd networking problem.
>
> I've got a linux 2.4 computer with two network cards and would
> like to ping from one port to the other through a crossover
> cable. (it's for basic hardware verification).
>
> If I just ping the other NIC linux is clever enough and route it
> through the loopback instead, so I have turned off loopback interface.
>
> lo : off
> eth0 : 192.168.2.2
> eth1 : 192.168.2.5
>
> By adding an explicit -host route for the 'other' network card I am
> able to send out ping echo request on eth0 (as seen on the
> LED/iptables/sniffer)
> # ping -I eth0 192.168.2.5
>
> But I don't recive any echo request on eth1 (according to
> iptables/sniffer).
> Where does this ping end up ?
>
> I must be doing something wrong..any suggestions ?


I imagine you have conflicting routing (same network for both interfaces).
I have not tried this, but try configuring each nic for netmask
255.255.255.255 and broadcast same as its IP and then host routes to the
other IP:

route add -host 192.168.2.5 /dev/eth0
route add -host 192.168.2.2 /dev/eth1

But Linux may still know that both IPs are local, so it might not even
go out over the wire.

 
Reply With Quote
 
Toni Erdmann
Guest
Posts: n/a

 
      08-05-2005, 10:01 AM
David Efflandt wrote:
> On 4 Aug 2005 14:32:19 -0700, devlin <(E-Mail Removed)> wrote:
>>Hello,
>>I'm having a bit of a odd networking problem.
>>
>>I've got a linux 2.4 computer with two network cards and would
>>like to ping from one port to the other through a crossover
>>cable. (it's for basic hardware verification).
>>
>>If I just ping the other NIC linux is clever enough and route it
>>through the loopback instead, so I have turned off loopback interface.
>>
>>lo : off
>>eth0 : 192.168.2.2
>>eth1 : 192.168.2.5
>>
>>By adding an explicit -host route for the 'other' network card I am
>>able to send out ping echo request on eth0 (as seen on the
>>LED/iptables/sniffer)
>> # ping -I eth0 192.168.2.5
>>
>>But I don't recive any echo request on eth1 (according to
>>iptables/sniffer).
>>Where does this ping end up ?
>>
>>I must be doing something wrong..any suggestions ?

>
> I imagine you have conflicting routing (same network for both interfaces).
> I have not tried this, but try configuring each nic for netmask
> 255.255.255.255 and broadcast same as its IP and then host routes to the
> other IP:
>
> route add -host 192.168.2.5 /dev/eth0
> route add -host 192.168.2.2 /dev/eth1
>
> But Linux may still know that both IPs are local, so it might not even
> go out over the wire.
>


That's true!

Using "-I eth0" with "ping" is the way to tell the kernel to realy use
the NIC (as long as theer's no routing conflict).
But there's no way to tell the kernel that the answer must also use
the NIC. There's a short-cut in the IP-Stack.

Next problem is a kind of security feature. The Kernel does not
accept IP packets coming from a NIC where the source IP address
is a local one. Some other PC could otherwise spoof the source IP
address and perform DoS attacs and your Kernel would allow the
traffic, because he thinks it's local traffic.

There was a thread in this newsgroup last year (April/May) about that.
Try to find "Toni Erdmann" with Google-News.

HTH
Toni
 
Reply With Quote
 
Jaggu
Guest
Posts: n/a

 
      08-08-2005, 04:09 PM
Hi all...

Me too have similar situation and am doing my first linux project.
Could you please tell me where ..which location of kernel part I can
find this funda happening ....like Linux/IP stack comparing or finding
the source and destination address are same and re-directing packets to
echo port if source and destination IP address are same?

like file path...?

thanks a lot

 
Reply With Quote
 
Tauno Voipio
Guest
Posts: n/a

 
      08-08-2005, 04:58 PM
Jaggu wrote:
> Hi all...
>
> Me too have similar situation and am doing my first linux project.
> Could you please tell me where ..which location of kernel part I can
> find this funda happening ....like Linux/IP stack comparing or finding
> the source and destination address are same and re-directing packets to
> echo port if source and destination IP address are same?
>
> like file path...?
>


It's sufficient that the destination address of
a packet is any of the local IP addresses to
route the packet via lo.

It's in the IP routing. Unless you understand it,
please do not mess with it. It's the core part
of the networking - a careless modification
will break things, for sure.

Please tell what you're trying to accomplish.
Maybe there's a totally different way to achieve
the desired results.

--

Tauno Voipio
tauno voipio (at) iki fi

 
Reply With Quote
 
Jaggu
Guest
Posts: n/a

 
      08-08-2005, 05:35 PM
Hi Tauno, Thanks a lot....I have an single network interface in the
embedded system I use, as such this port cannot be seen outside(so I
cannot connect to other hosts through cross over cable) rather its data
transmitting pin is internally connected to receiver pin ans other pins
also.

I need to run some application like FTP(on same host) and during it I
need to profile the system (ethernet driver, ftp protocol, kernel, file
system etc) that is my major intention. As such I cannot do FTP because
the packets are not really transmitted to the interface instead they
get software loopbacked(source and destination is same).

so In this situation how can I make packets travel to ether core and
come back?
(I dont want to use raw sockets....and writing data directly to
ethernet core)

thank you

 
Reply With Quote
 
Tauno Voipio
Guest
Posts: n/a

 
      08-08-2005, 06:46 PM
Jaggu wrote:
> Hi Tauno, Thanks a lot....I have an single network interface in the
> embedded system I use, as such this port cannot be seen outside(so I
> cannot connect to other hosts through cross over cable) rather its data
> transmitting pin is internally connected to receiver pin ans other pins
> also.
>
> I need to run some application like FTP(on same host) and during it I
> need to profile the system (ethernet driver, ftp protocol, kernel, file
> system etc) that is my major intention. As such I cannot do FTP because
> the packets are not really transmitted to the interface instead they
> get software loopbacked(source and destination is same).
>
> so In this situation how can I make packets travel to ether core and
> come back?
> (I dont want to use raw sockets....and writing data directly to
> ethernet core)



Is this the same question you posted earlier
to another group?

IIRC, the suggestion was to use raw sockets. What's
wrong with the solution? If the problem is
learning the raw sockets, just go bite the
bullet and tackle the learning: the knowledge
may be worth its tedium in gold later.

There is little (or actually: no) sense to
test the interface with a high-level application
like FTP (it's FTP-TCP-IP-Ethernet). The added
protocol layers only complicate your task, if the
purpose is to show that the interface works.

If you want to show that a high-level
application runs on your interface, you
*do* have to provide the physical layer
interface and another computer to run
the test with.

(Been there - done that: some embedded
Ethernet interfaces and TCP/IP stacks)

--

Tauno Voipio
tauno voipio (at) iki fi

 
Reply With Quote
 
Jaggu
Guest
Posts: n/a

 
      08-08-2005, 08:11 PM
Hi Tauno,

>
>>

> IIRC, the suggestion was to use raw sockets. What's
> wrong with the solution? If the problem is
> learning the raw sockets, just go bite the
> bullet and tackle the learning: the knowledge
> may be worth its tedium in gold later.


raw sockets is fine, I do agree, I love to do that , problem is
this doesn't solve my final intention.When I profile with this solution
I cannot precisely estimate the overall burden to processor given due
to high speed ports like ethernet etc in real time. In real time the
burden depends on device driver and protocol (depends on application).
With raw sockets I cannot estimate top layers burden.
>
> There is little (or actually: no) sense to
> test the interface with a high-level application
> like FTP (it's FTP-TCP-IP-Ethernet). The added
> protocol layers only complicate your task, if the
> purpose is to show that the interface works.
>


No, my intention is not show that the interface works. I know its
non-sense to profile real scenario without actual hardware setup like
without PHY.Iam helpless, am provided as such.I know added protocol
complicates my task but gives me to estimate real time scenario.

thanks for your time and consideration

 
Reply With Quote
 
Toni Erdmann
Guest
Posts: n/a

 
      08-09-2005, 07:54 AM
Jaggu wrote:
> Hi all...
>
> Me too have similar situation and am doing my first linux project.
> Could you please tell me where ..which location of kernel part I can
> find this funda happening ....like Linux/IP stack comparing or finding
> the source and destination address are same and re-directing packets to
> echo port if source and destination IP address are same?
>
> like file path...?
>
> thanks a lot
>


We faced the problem to have a 'ppp0' and 'eth0'
interface and we wanted to send data over ppp0
and receive it thru eth0 (and back) - just to measure
the delays.

Our solution was to modify
"net/ipv4/fib_frontend.c" of 2.4.19 near line 233
to let UDP packets pass, even though the source IP
address is a local one.

The solution was proposed by Ben Greear in 'linux.kernel' mailing list.

http://groups.google.de/groups?q=Gre...ofh.it&rnum=10

http://groups.google.de/groups?hl=de...om%26rnum%3D19

http://groups.google.de/groups?hl=de...om%26rnum%3D27

Toni
 
Reply With Quote
 
Toni Erdmann
Guest
Posts: n/a

 
      08-09-2005, 08:11 AM
Jaggu wrote:

> Hi Tauno, Thanks a lot....I have an single network interface in the
> embedded system I use, as such this port cannot be seen outside(so I
> cannot connect to other hosts through cross over cable) rather its data
> transmitting pin is internally connected to receiver pin ans other pins
> also.
>
> I need to run some application like FTP(on same host) and during it I
> need to profile the system (ethernet driver, ftp protocol, kernel, file
> system etc) that is my major intention. As such I cannot do FTP because
> the packets are not really transmitted to the interface instead they
> get software loopbacked(source and destination is same).
>
> so In this situation how can I make packets travel to ether core and
> come back?
> (I dont want to use raw sockets....and writing data directly to
> ethernet core)
>
> thank you
>


We used 'ppp0' and 'eth0'. The solution below worked for
this configuration. Don't know, whether it works for a
single NIC or not.

You need this patch based on 2.4.19
(just comment or delete those two lines)

--- linux-2.4.19/net/ipv4/fib_frontend.c Fri Aug 2 17:39:46 2002
+++ linux-2.4.19.dev/net/ipv4/fib_frontend.c Sun Sep 15 21:16:44 2002
@@ -233,8 +233,19 @@

- if (res.type != RTN_UNICAST)
- goto e_inval_res;


You need two applications that bind to the interface explicitly
(as "ping -I eth0" does).

int sockfd;
char interface_name[32]; // = "eth0"
struct ifreq iface;

socket(sockfd, ..., SOCK_DGRAM, ....)
bind(sockfd,....,"port")

strncpy(iface.ifr_ifrn.ifrn_name,interface_name,IF NAMSIZ);
if ( setsockopt(sockfd,SOL_SOCKET,SO_BINDTODEVICE,
(void *)&iface,sizeof(iface)) < 0 )
{
perror("setsockopt(...,SO_BINDTODEVICE,...) failed\n" );
exit(1);
}

sendto(sockfd,...)

Toni
 
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
crossover cable Greg Network Routers 8 02-21-2006 04:12 PM
Turning a crossover cable into a straight through cable Larry Roberts Windows Networking 8 02-18-2005 10:30 AM
Can I convert a FastCat5e network cable into a crossover cable? Sherri & Garry January Windows Networking 10 10-30-2003 04:19 AM
Can I convert a FastCat5e network cable into a crossover cable? Sherri & Garry January Home Networking 10 10-30-2003 04:19 AM
Can I convert a FastCat5e network cable into a crossover cable? Sherri & Garry January Windows Networking 8 10-30-2003 04:19 AM



1 2 3 4 5 6 7 8 9 10 11