LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-24-2014, 05:28 PM   #1
cairn
LQ Newbie
 
Registered: Feb 2014
Posts: 5

Rep: Reputation: Disabled
Mac address


I have an application that needs to forward complete packets from another device, and the MAC address has to be that of the original device, but the middle device keeps amending the MAC address when the packet is sent out. I know I will need to update the OS but were do I need to do this. The device in the middle is placing the copied packets (inc. Ethernet data) using libpcap inject method, but the packets outputted have the mac address of the middle device, not the originator. I have read that this can happen dependant upon the OS. I've attempted a number of things in net/Ethernet/eth.c but nothing appears to make a difference. Do I need to be making changes in the IPv4 forwarding code, or where else? This is on an embedded Linux machine.
 
Old 03-25-2014, 03:33 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,893

Rep: Reputation: 163Reputation: 163
You can set relative two interfaces to bridge mode to avoid source MAC change.
 
Old 03-25-2014, 04:02 PM   #3
cairn
LQ Newbie
 
Registered: Feb 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
That would be Ok if the devices were connected via an Ethernet connection. The middle device only has one Ethernet port an so is connected via another comms bus, hence wanting to know what would be needed to be updated in the OS to prevent the middle devices mac address being written when the packet is injected.
 
Old 03-25-2014, 04:52 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,270

Rep: Reputation: 3656Reputation: 3656Reputation: 3656Reputation: 3656Reputation: 3656Reputation: 3656Reputation: 3656Reputation: 3656Reputation: 3656Reputation: 3656Reputation: 3656
Some types of tunnels could do what you want.
 
Old 03-26-2014, 03:20 PM   #5
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,893

Rep: Reputation: 163Reputation: 163
hence wanting to know what would be needed to be updated in the OS to prevent the middle devices mac address being written when the packet is injected.
It is a little complicated. If you already did something in net/Ethernet/eth.c and it doesn't help, you perhaps should check driver code.
 
Old 03-26-2014, 05:05 PM   #6
cairn
LQ Newbie
 
Registered: Feb 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
I've found the code in eth.c is OK for setup, but is no good for processing each packet. Looking in neighbour.c as this appears to place the packet data into the xmit queue, but still not sure what will be needed.
 
Old 03-27-2014, 03:47 PM   #7
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,893

Rep: Reputation: 163Reputation: 163
If your real requirement want to change kernel code to prevent source MAC from change under router mode, it is really hard to cover all case because the idea break up basic concept of router mode. If just for special purpose, one case, it is Ok.
 
Old 03-27-2014, 06:19 PM   #8
baldy3105
Member
 
Registered: Jan 2003
Location: Cambridgeshire, UK
Distribution: Mint (Desktop), Debian (Server)
Posts: 891

Rep: Reputation: 184Reputation: 184
MAC addresses are layer 2 addresses. A Router is a layer 3 device and therefore a layer 2 boundary. MAC addresses do not traverse the router because the router is removing the IP packet from the ethernet frame, routing it and then re-encapsulateing it - the original MAC address is lost. A packet that has been routed to an Ethernet network will carry the MAC address of the router - thats just the way it works.

If you want to pass ethernet frames intact from one ethernet segment to another you will have to bridge it, not route it.

Otherwise you are going to have to write your own routing code. You would have to keep track of the original MAC/IP mapping, maybe you can route the packet, then look up the source ip address in the arp table and rewrite the source mac address of the outbound frame prior to transmission. You would have to do this for every routed hop from source to destination.

In my experience, breaking standards like this is a bad idea that will come back to bite you in the ass. The real solution is to find the application that needs this functionality and fix it because it sounds like thats what is broken.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I find what MAC address web pages see as my MAC address rob.rice General 20 05-29-2010 03:08 AM
Ethernet MAC Addresses database; MAC address-based processing cctualatin Linux - Newbie 1 04-14-2009 09:59 AM
Single DHCP server ,to provide the ip address to a MAC address in two different subne alix123 Linux - Software 5 05-09-2007 12:16 AM
how to get ip address, broadcast address, mac address of a machine sumeshstar Programming 2 03-12-2005 05:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration