1

I have a problem in configuring the forwarding table in Linux.
We call IP tables for routing table in layer 3, MAC tables for forwarding table in layer 2.
Now I want to add an entry in forwarding table. I know the tool route command can be used to add routing entry in routing table like:

#[root]# route add -net 192.168.10.0 netmask 255.255.255.0 dev eth0

So, is there a tool like 'route' can let me add entry in forwarding table like:

#[root]# 'command name' add 01:02:03:04:05:06 dev eth1

All I required is how to bind the destination MAC address to a fixed network interface?!


Thanks for replying, all of you. Now it seems that I didn't introduce my goal clearly, so most of you were wondering my requirement. We are now working on a data center network experiment that mainly focusing on the forwarding tables size of the switches. In this scenario it is a fat tree topology and another research team have developed a new addressing and routing method that can guarantee two properties: multi-path and small forwarding table size. Here we called the layer 2 table a forwarding table since it is the same calling by Cisco. There is a controller in this network so all the forwarding tables can be obtained by this controller's work. The experiment now is bothering how to write the forwarding table from controller to the switches. That means, how to write the entries like MAC_ADDR--->OUTPUT INTERFACE. Please note that this network is like a big 'LAN' that no need to do the IP routing.

1
  • This should probably be on UNIX/Linux or Server Fault, yes? Jul 25, 2011 at 8:10

4 Answers 4

2

You should be able to do this using the 'arp' utility.

arp -i eth0 -s

1

On Linux you should always use the ip command to change network configuration. The route command is there, but doesn't give you access to all the Linux routing features. Now, MAC forwarding is usually referred to as bridging, for which you can use the brctl tool. But it's not clear from the question how you are using MAC addresses.

13
  • My real problem is how to bind the MAC address to an interface. For example, I want to indicate all the traffic which destination mac address is 01:02:03:04:05:06 to go out from an fixed network interface like eth0 or eth1. 'brctl' can be used like: brctl addif brname eth1, but how can I add an entry in the table which 'brctl showmacs brname' lists?
    – victor
    Jul 25, 2011 at 8:08
  • This depends on the distribution. Many distributions have not incorporated the iproute2 package as a core package yet. Gentoo is one, and several systems in the RPM family are others. Jul 25, 2011 at 8:08
  • Sounds like ebtables is what you are looking for, but I haven't tried it.
    – Keith
    Jul 25, 2011 at 9:06
  • @michael iproute2 has been preferred, and net-tools obsoleted for many years. If any distro doesn't have it then they are really broken with regards to networking.
    – Keith
    Jul 25, 2011 at 9:08
  • #ebtables can not be used to redirect the flow to the fixed output port, it can only be used to filter the flow. I just want to write an entry like: #The flow has this destination MAC address should go out from that interface.
    – victor
    Jul 25, 2011 at 9:19
0

First, a few remarks. Routing is the process of finding direction(s). Forwarding TCP/IP packet through is called forwarding. That's why there're sysctl called net.ipv4.ip_forward and netfilter's chain called FORWARD. There're dynamic and static routing, should I add. And what swithes do is called (surprise) switching.

OSI's 2nd level switches use MAC_Dest-PortNum correspondence table just because those port's are 2nd level — that's enough to switch Ethernet frame to specific port (or broadcast it in absence of specific table entry).

Linux' network interfaces are not just switching ports, they're interfaces. Forwarding of TCP/IP packet (datagram) involves looking up (inside routing table cache) corresponding output interface. And I never heard anything regarding Linux' support of switching.

Conclusion: in case you're to make the packet find its way through Linux system, you have to use routing table. You can use arptables/ebtables/iptables to do some trickery on those packets though, but since you haven't described why do you need it, its rather unclear whether your goal can be achieved and how.

0

As best as I can tell, you want to tell the kernel that Ethernet frames destined for a particular MAC should be delivered to a particular interface. However, that should be done automatically; as long as your two interfaces are bridged together, Ethernet frames will cross the bridge and find their destinations just fine. Of course, you must observe certain guidelines, including not having too many switches between multiple points on your network.

If you already are operating your system as a bridge, and your Ethernet frames are not reaching the correct places, you may have an error in your network; you'll want to double-check to be sure that you do not have any loops in your network wiring and so forth.

If you have a larger network, then IP subnets are going to be the way to go; that way you have the ability to run full-fledged routers that can move layer 3 packets in whatever manner they need to be moved. Generally, you'll want to prefer IP subnetting over clever tricks at layer 2. You shouldn't need to work with MAC addresses unless you're using them as keys for logging. You certainly do not want to base any security on them, as MAC addresses can easily be spoofed/cloned.

You must log in to answer this question.