Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
03-24-2014, 05:28 PM
|
#1
|
LQ Newbie
Registered: Feb 2014
Posts: 5
Rep: 
|
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.
|
|
|
03-25-2014, 03:33 PM
|
#2
|
Senior Member
Registered: Apr 2009
Posts: 1,893
Rep: 
|
You can set relative two interfaces to bridge mode to avoid source MAC change.
|
|
|
03-25-2014, 04:02 PM
|
#3
|
LQ Newbie
Registered: Feb 2014
Posts: 5
Original Poster
Rep: 
|
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.
|
|
|
03-25-2014, 04:52 PM
|
#4
|
Moderator
Registered: Mar 2008
Posts: 22,270
|
Some types of tunnels could do what you want.
|
|
|
03-26-2014, 03:20 PM
|
#5
|
Senior Member
Registered: Apr 2009
Posts: 1,893
Rep: 
|
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.
|
|
|
03-26-2014, 05:05 PM
|
#6
|
LQ Newbie
Registered: Feb 2014
Posts: 5
Original Poster
Rep: 
|
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.
|
|
|
03-27-2014, 03:47 PM
|
#7
|
Senior Member
Registered: Apr 2009
Posts: 1,893
Rep: 
|
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.
|
|
|
03-27-2014, 06:19 PM
|
#8
|
Member
Registered: Jan 2003
Location: Cambridgeshire, UK
Distribution: Mint (Desktop), Debian (Server)
Posts: 891
Rep: 
|
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.
|
|
|
All times are GMT -5. The time now is 08:09 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|