blob: 1b869d0a002e8085a64d78bd55c222bc3d7f512b (
plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
|
# iifname "eth0" tcp dport 80-90 dnat to 192.168.3.2
ip test-ip4 prerouting
[ meta load iifname => reg 1 ]
[ cmp eq reg 1 0x30687465 0x00000000 0x00000000 0x00000000 ]
[ meta load l4proto => reg 1 ]
[ cmp eq reg 1 0x00000006 ]
[ payload load 2b @ transport header + 2 => reg 1 ]
[ cmp gte reg 1 0x00005000 ]
[ cmp lte reg 1 0x00005a00 ]
[ immediate reg 1 0x0203a8c0 ]
[ nat dnat ip addr_min reg 1 addr_max reg 0 ]
# iifname "eth0" tcp dport != 80-90 dnat to 192.168.3.2
ip test-ip4 prerouting
[ meta load iifname => reg 1 ]
[ cmp eq reg 1 0x30687465 0x00000000 0x00000000 0x00000000 ]
[ meta load l4proto => reg 1 ]
[ cmp eq reg 1 0x00000006 ]
[ payload load 2b @ transport header + 2 => reg 1 ]
[ range neq reg 1 0x00005000 0x00005a00 ]
[ immediate reg 1 0x0203a8c0 ]
[ nat dnat ip addr_min reg 1 addr_max reg 0 ]
# iifname "eth0" tcp dport {80, 90, 23} dnat to 192.168.3.2
__set%d test-ip4 3
__set%d test-ip4 0
element 00005000 : 0 [end] element 00005a00 : 0 [end] element 00001700 : 0 [end]
ip test-ip4 prerouting
[ meta load iifname => reg 1 ]
[ cmp eq reg 1 0x30687465 0x00000000 0x00000000 0x00000000 ]
[ meta load l4proto => reg 1 ]
[ cmp eq reg 1 0x00000006 ]
[ payload load 2b @ transport header + 2 => reg 1 ]
[ lookup reg 1 set __set%d ]
[ immediate reg 1 0x0203a8c0 ]
[ nat dnat ip addr_min reg 1 addr_max reg 0 ]
# iifname "eth0" tcp dport != {80, 90, 23} dnat to 192.168.3.2
__set%d test-ip4 3
__set%d test-ip4 0
element 00005000 : 0 [end] element 00005a00 : 0 [end] element 00001700 : 0 [end]
ip test-ip4 prerouting
[ meta load iifname => reg 1 ]
[ cmp eq reg 1 0x30687465 0x00000000 0x00000000 0x00000000 ]
[ meta load l4proto => reg 1 ]
[ cmp eq reg 1 0x00000006 ]
[ payload load 2b @ transport header + 2 => reg 1 ]
[ lookup reg 1 set __set%d 0x1 ]
[ immediate reg 1 0x0203a8c0 ]
[ nat dnat ip addr_min reg 1 addr_max reg 0 ]
# iifname "eth0" tcp dport != 23-34 dnat to 192.168.3.2
ip test-ip4 prerouting
[ meta load iifname => reg 1 ]
[ cmp eq reg 1 0x30687465 0x00000000 0x00000000 0x00000000 ]
[ meta load l4proto => reg 1 ]
[ cmp eq reg 1 0x00000006 ]
[ payload load 2b @ transport header + 2 => reg 1 ]
[ range neq reg 1 0x00001700 0x00002200 ]
[ immediate reg 1 0x0203a8c0 ]
[ nat dnat ip addr_min reg 1 addr_max reg 0 ]
# iifname "eth0" tcp dport 81 dnat to 192.168.3.2:8080
ip test-ip4 prerouting
[ meta load iifname => reg 1 ]
[ cmp eq reg 1 0x30687465 0x00000000 0x00000000 0x00000000 ]
[ meta load l4proto => reg 1 ]
[ cmp eq reg 1 0x00000006 ]
[ payload load 2b @ transport header + 2 => reg 1 ]
[ cmp eq reg 1 0x00005100 ]
[ immediate reg 1 0x0203a8c0 ]
[ immediate reg 2 0x0000901f ]
[ nat dnat ip addr_min reg 1 addr_max reg 0 proto_min reg 2 proto_max reg 0 ]
# dnat to ct mark map { 0x00000014 : 1.2.3.4}
__map%d test-ip4 b
__map%d test-ip4 0
element 00000014 : 04030201 0 [end]
ip test-ip4 prerouting
[ ct load mark => reg 1 ]
[ lookup reg 1 set __map%d dreg 1 ]
[ nat dnat ip addr_min reg 1 addr_max reg 0 ]
# dnat to ct mark . ip daddr map { 0x00000014 . 1.1.1.1 : 1.2.3.4}
__map%d test-ip4 b
__map%d test-ip4 0
element 00000014 01010101 : 04030201 0 [end]
ip test-ip4 output
[ ct load mark => reg 1 ]
[ payload load 4b @ network header + 16 => reg 9 ]
[ lookup reg 1 set __map%d dreg 1 ]
[ nat dnat ip addr_min reg 1 addr_max reg 0 ]
|