mirror of
https://bitbucket.org/mangelo/snippets.git
synced 2024-11-24 11:50:59 +02:00
43 lines
1.2 KiB
Bash
43 lines
1.2 KiB
Bash
|
#!/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
|
||
|
####
|