Sunday, January 15, 2017

configure L2TP ethernet pseudowire between linux host

*** host1
1- execute the following command to enable ip forward,  setup l2tp tunnel and set the ip address on newly created interface
$ sudo sysctl -w net.ipv4.ip_forward=1
$ sudo modprobe l2tp_eth
$ sudo ip l2tp add tunnel tunnel_id 1000 peer_tunnel_id 2000 encap udp local 192.168.56.13 remote 192.168.56.1 udp_sport 10000 udp_dport 20000
$ sudo ip l2tp add session tunnel_id 1000 session_id 10000 peer_session_id 20000
$ sudo ifconfig l2tpeth0 1.1.1.2/24 up




*** host2 on the other end
1- execute the following command to enable ip forward,  setup l2tp tunnel and set the ip address on newly created interface
$ sudo sysctl -w net.ipv4.ip_forward=1
$ sudo modprobe l2tp_eth
$ sudo ip l2tp add tunnel tunnel_id 1000 peer_tunnel_id 2000 encap udp local 192.168.56.1 remote 192.168.56.13 udp_sport 20000 udp_dport 10000
$ sudo ip l2tp add session tunnel_id 1000 session_id 20000 peer_session_id 10000
$ sudo ifconfig l2tpeth0 1.1.1.1/24 up


*** testing and verifing

use the following command to get information about the tunnel and confirming whether it works
$ ip l2tp show tunnel
Tunnel 1000, encap UDP
  From 192.168.56.13 to 192.168.56.1
  Peer tunnel 2000
  UDP source / dest ports: 10000/20000


$ ip l2tp show session
Session 10000 in tunnel 1000
  Peer session 20000, tunnel 2000
  interface name: l2tpeth0
  offset 0, peer offset 0


$ ifconfig l2tpeth0
l2tpeth0  Link encap:Ethernet  HWaddr d2:4f:99:04:23:d6 
          inet addr:1.1.1.2  Bcast:1.1.1.255  Mask:255.255.255.0
          inet6 addr: fe80::d04f:99ff:fe04:23d6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1488  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1072 (1.0 KB)  TX bytes:928 (928.0 B)

No comments:

Post a Comment