0

BSD/MacOS X has a command "route" for altering the system routing table. One of the options that it supports is -proto1 (as well as proto2/proto3) which are for setting a route to be protocol specific. I am wanting to use this to set a route that is specific to UDP.

I have tried using -proto1 udp alone with the add function. Alas, this does not work. I've been trying to find an example of the use of -proto1, but I've been unable to find an example of this option to the route command.

Can anyone explain how this is used or point to an example? Thank you.

brant
  • 369
  • 3
  • 8

1 Answers1

1

The route command's -proto* flags set matching the RTF_PROTO* flag bits in the appropriate routing table entry's rt_flags field (i.e. they have no other value parameter -- they each represent individual bits).

They do not make the route "protocol specific", but rather are generic flag bits that can be used in a protocol specific way by whatever lower layer protocol the route uses.

In the BSD networking code protocol specific parts of the code will often define more meaningful names to map to the same flag bits. For example in the ARP layer the RTF_ANNOUNCE flag is the same bit in the rt_flags field as the RTF_PROTO2 bit.

In the case of ARP the flag is set in the routing table by the arp command (if the word pub is given on the command line when creating an ARP entry manually), not by the route command. However the netstat -r command may show the flag on the resulting routing table entry as 2, indicating RTF_PROTO2 (as would route -v show).

If you want to force all packets for a specific transport protocol, e.g. UDP or TCP, then you will have to investigate different mechanisms than the routing table -- for example some firewalls can forward packets to specified interfaces based on protocol value given in the IP header.

Greg A. Woods
  • 2,663
  • 29
  • 26