File:  [NetBSD Developer Wiki] / wikisrc / users / kefren.mdwn
Revision 1.2: download - view: text, annotated - select for diffs
Mon Jun 28 08:31:35 2010 UTC (3 years, 9 months ago) by kefren
Branches: MAIN
CVS tags: HEAD
added a quick mpls how-to

#Some quick info about MPLS:

You need to compile your kernel with options MPLS and psuedo-device ifmpls
For pure LSR - that only switch labels without encap/decap from other protocols (e.g. INET) you need only to work on routing table. For example:

<pre># route add -mpls 41 -tag 25 -inet
add host 41: gateway
# route add -mpls 42 -tag 30 -inet
add host 42: gateway
# route add -mpls 51 -tag 25 -inet
add host 51: gateway</pre>

Translation of first line: if it receives an MPLS frame with label 41 forward it to INET next-hop, tagged with label 25

You also need to tweak sysctl to accept and forward MPLS:

<pre># sysctl -w net.mpls.accept=1
net.mpls.accept: 0 -> 1
# sysctl -w net.mpls.forwarding=1
net.mpls.forwarding: 0 -> 1</pre>

Verify routes with route get or better with netstat -nrT:

Destination        Gateway            Flags    Refs      Use    Mtu     Tag Interface
41             UGHS        0    37241      -      25 sk0
42             UGHS        0        0      -      30 sk0
51             UGHS        0        0      -      25 sk0

#Interacting with other protocols

If you want to also decapsulate/encapsulate from MPLS to some other protocol (like INET or INET6), you have to create an mpls interface and put in up: ifconfig mpls0 create up. YOU NEED TO ADD AN ADDRESS OF THAT PROTOCOL ON THIS INTERFACE - whenever that address is private or not.

E.g. for INET - setting a fictitious address:

# ifconfig mpls0 create up
# ifconfig mpls0

After that create routes like this - use -ifa flag in order to avoid self-generated packets having source address, but route them thru mpls0 interface.

# route add -ifa -ifp mpls0 -tag 25 -inet
add net gateway

Verify the route:

# route -n get
   route to:
        Tag: 25
 local addr:
  interface: mpls0
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
       0         0         0       813       344         0         0         0 

or with netstat -rT:
204.152.190/24      UGS         0    95362      -      25 mpls0

I'm working on LDP daemon, it should be available in a couple of weeks.

CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb