1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
;;
;; Copyright (c) 2021 Intel Corporation
;;
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;;
[lua]
dofile("parameters.lua")
public_start_ip = string.match(dest_ip1,"%d+\.%d+\.%d+\.")..2
public_stop_ip = string.match(dest_ip1,"%d+\.%d+\.%d+\.")..20
cgnat_table = {}
cgnat_table.dynamic = {
{public_ip_range_start = ip(public_start_ip),public_ip_range_stop = ip(public_stop_ip), public_port = val_range(10,20000)},
}
lpm4 = {}
lpm4.next_hops = {
{id = 0, port_id = 0, ip = ip("1.1.1.1"), mac = mac("00:00:00:00:00:01"), mpls = 0x212},
}
lpm4.routes = {};
lpm4.routes[1] = {
cidr = {ip = ip(0), depth = 1},
next_hop_id = 0,
}
[eal options]
-n=4 ; force number of memory channels
no-output=no ; disable DPDK debug output
eal=--proc-type auto ${eal}
[port 0]
name=if0
mac=hardware
vlan=yes
vdev=internal_tap
local ipv4=${local_ip1}
[port 1]
name=if1
mac=hardware
vlan=yes
vdev=external_tap
local ipv4=${local_ip2}
[defaults]
mempool size=8K
[global]
name=${name}
[core $mcore]
mode=master
[core $cores]
name=nat
task=0
mode=cgnat
sub mode=l3
private=yes
nat table=cgnat_table
route table=lpm4
rx port=if0
tx ports from routing table=if1
task=1
mode=cgnat
sub mode=l3
private=no
nat table=cgnat_table
route table=lpm4
rx port=if1
tx ports from routing table=if0
|