Linux VRF.

This commit is contained in:
Miguel Scapolla 2016-05-06 19:26:32 -03:00
parent 66581024f8
commit 26bd339a59
1 changed files with 42 additions and 0 deletions

42
linux-vrf.sh Normal file
View File

@ -0,0 +1,42 @@
#!/bin/bash
#
# http://www.adminarticles.com/vrf-lite-with-iproute2/
#
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
modprobe 8021q
ifconfig eth1 up
ifconfig eth2 up
vconfig add eth1 11
vconfig add eth1 22
vconfig add eth2 11
vconfig add eth2 22
ifconfig eth1.11 10.10.10.1/24
ifconfig eth1.22 10.20.20.1/24
ifconfig eth2.11 10.30.30.1/24
ifconfig eth2.22 10.40.40.1/24
ip route add 10.10.10.0/24 table VPNA dev eth1.11 proto static
ip route add 10.20.20.0/24 table VPNB dev eth1.22 proto static
ip route add 10.30.30.0/24 table VPNA dev eth2.11 proto static
ip route add 10.40.40.0/24 table VPNB dev eth2.22 proto static
ip route add 20.20.20.1/32 table VPNA dev eth1.11 via 10.10.10.2 proto static
ip route add 20.20.20.1/32 table VPNB dev eth1.22 via 10.20.20.2 proto static
ip route add 30.30.30.1/32 table VPNA dev eth2.11 via 10.30.30.2 proto static
ip route add 30.30.30.1/32 table VPNB dev eth2.22 via 10.40.40.2 proto static
ip rule add iif eth1.11 table VPNA prio 1000
ip rule add iif eth1.22 table VPNB prio 1001
ip rule add iif eth2.11 table VPNA prio 1002
ip rule add iif eth2.22 table VPNB prio 1003
#### cat /etc/iproute2/rt_tables
#1 VPNA
#2 VPNB
####