File:  [NetBSD Developer Wiki] / wikisrc / users / kefren / mpls.mdwn
Revision 1.3: download - view: text, annotated - select for diffs
Thu Nov 1 09:21:52 2012 UTC (8 years, 5 months ago) by wiki
Branches: MAIN
CVS tags: HEAD
web commit by kefren: minor corrections, sync info with reality

    1: #Some quick info about MPLS:
    2: 
    3: You need to compile your kernel with options MPLS and psuedo-device ifmpls
    4: For pure LSR - that only switch labels without encap/decap from other protocols (e.g. INET) - you need to work on routing table, ONLY. For example:
    5: 
    6: <pre># route add -mpls 41 -tag 25 -inet 193.28.151.97
    7: add host 41: gateway 193.28.151.97
    8: # route add -mpls 42 -tag 30 -inet 193.28.151.97
    9: add host 42: gateway 193.28.151.97
   10: # route add -mpls 51 -tag 25 -inet 193.28.151.97
   11: add host 51: gateway 193.28.151.97</pre>
   12: 
   13: Translation of first line: if it receives an MPLS frame with label 41 forward it to INET next-hop 193.28.151.97, but switch (change) label 41 with label 25
   14: 
   15: You also need to tweak sysctl to accept and forward MPLS:
   16: 
   17: <pre># sysctl -w net.mpls.accept=1
   18: net.mpls.accept: 0 -> 1
   19: # sysctl -w net.mpls.forwarding=1
   20: net.mpls.forwarding: 0 -> 1</pre>
   21: 
   22: 
   23: Verify routes with route get or better with netstat -nrT:
   24: 
   25: <pre>
   26: ...
   27: MPLS:
   28: Destination        Gateway            Flags    Refs      Use    Mtu     Tag Interface
   29: 41                 193.28.151.97      UGHS        0    37241      -      25 sk0
   30: 42                 193.28.151.97      UGHS        0        0      -      30 sk0
   31: 51                 193.28.151.97      UGHS        0        0      -      25 sk0
   32: </pre>
   33: 
   34: #Interacting with other protocols
   35: 
   36: If you want to also decapsulate/encapsulate from MPLS to some other protocol (like INET or INET6), then you have to create an mpls interface and put in up state.
   37: 
   38: 
   39: <pre>
   40: # ifconfig mpls0 create up
   41: </pre>
   42: 
   43: After that, create routes using ifa flag in order to specify the source interface (used for source IP Address of host generated packets), but route them through mpls0 interface.
   44: 
   45: <pre>
   46: # route add 204.152.190.0/24 -ifa 193.28.151.105 -ifp mpls0 -tag 25 -inet 193.28.151.97
   47: add net 204.152.190.0: gateway 193.28.151.97
   48: </pre>
   49: 
   50: Verify the route:
   51: 
   52: <pre>
   53: # route -n get 204.152.190.0/24
   54:    route to: 204.152.190.0
   55: destination: 204.152.190.0
   56:        mask: 255.255.255.0
   57:     gateway: 193.28.151.97
   58:         Tag: 25
   59:  local addr: 193.28.151.105
   60:   interface: mpls0
   61:       flags: <UP,GATEWAY,DONE,STATIC>
   62:  recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
   63:        0         0         0       813       344         0         0         0 
   64: sockaddrs: <DST,GATEWAY,NETMASK,IFP,IFA,TAG>
   65: </pre>
   66: 
   67: or with netstat -rT:
   68: <pre>
   69: ...
   70: 204.152.190/24     193.28.151.97      UGS         0    95362      -      25 mpls0
   71: ...
   72: </pre>
   73: 
   74: Test if it's working using traceroute -M. Notice first hop is reporting label 25.
   75: 
   76: <pre>
   77: # traceroute -M 204.152.190.12
   78: traceroute to 204.152.190.12 (204.152.190.12), 64 hops max, 40 byte packets
   79:  1  shaitan.girsa.ro (193.28.151.97)  2.892 ms  1.957 ms  1.992 ms [MPLS: Label 25 Exp 0]
   80:  2  b4-vlan811.girsa.ro (193.28.151.82)  1.988 ms  1.961 ms  1.989 ms [MPLS: Label 27 Exp 0]
   81:  3  80.97.219.81 (80.97.219.81)  1.990 ms  1.974 ms  2.009 ms
   82:  4  vlan103.cr3-sw.buch.artelecom.net (80.97.199.1)  2.651 ms  2.280 ms  3.663 ms
   83:  5  10.0.241.189 (10.0.241.189)  33.944 ms  34.011 ms  33.869 ms [MPLS: Label 21669 Exp 0]
   84:  6  10.0.240.22 (10.0.240.22)  33.946 ms  33.689 ms  33.929 ms
   85:  7  20gigabitethernet4-3.core1.fra1.he.net (80.81.192.172)  35.930 ms  35.926 ms  35.917 ms
   86:  8  10gigabitethernet1-2.core1.par1.he.net (72.52.92.89)  43.940 ms  45.900 ms  47.916 ms
   87:  9  10gigabitethernet1-3.core1.lon1.he.net (72.52.92.33)  59.901 ms  51.888 ms  51.913 ms
   88: 10  10gigabitethernet4-4.core1.nyc4.he.net (72.52.92.241)  119.808 ms  119.780 ms  119.800 ms
   89: 11  10gigabitethernet1-2.core1.chi1.he.net (72.52.92.102)  141.755 ms  143.748 ms  149.756 ms
   90: 12  he.ord1.isc.org (209.51.161.18)  143.756 ms  143.757 ms  141.755 ms
   91: 13  iana.r1.ord1.isc.org (199.6.0.1)  145.831 ms  141.747 ms  143.762 ms
   92: 14  int-0-0-1-8.r1.pao1.isc.org (149.20.65.157)  201.653 ms  205.650 ms  201.650 ms [MPLS: Label 16005 Exp 0]
   93: 15  int-0-0-1-0.r2.sql1.isc.org (149.20.65.10)  201.663 ms  201.645 ms  201.664 ms
   94: 16  www.netbsd.org (204.152.190.12)  199.676 ms  201.652 ms  201.673 ms
   95: </pre>
   96: 
   97: See also [[LDP]] wiki page.

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb