File: set_lookups

package info (click to toggle)
nftables 1.1.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,384 kB
  • sloc: ansic: 50,901; sh: 20,277; yacc: 5,861; python: 1,746; lex: 1,367; makefile: 392
file content (66 lines) | stat: -rwxr-xr-x 1,360 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

# NFT_TEST_REQUIRES(NFT_TEST_HAVE_pipapo)

set -e

$NFT -f /dev/stdin <<"EOF"
table ip t {
	set s {
		type ipv4_addr . iface_index
		flags interval
		elements = { 127.0.0.1 . 1 }
	}

	set s2 {
		typeof ip saddr . meta iif
		elements = { 127.0.0.1 . 1 }
	}

	set s3 {
		type iface_index
		elements = { "lo" }
	}

	set s4 {
		type iface_index
		flags interval
		elements = { "lo" }
	}

	set nomatch {
		typeof ip saddr . meta iif
		elements = { 127.0.0.3 . 1 }
	}

	set nomatch2 {
		type ipv4_addr . iface_index
		elements = { 127.0.0.2 . 90000 }
	}

	chain c {
		type filter hook input priority filter;
		icmp type echo-request ip saddr . meta iif @s counter
		icmp type echo-request ip saddr . 1 @s counter
		icmp type echo-request ip saddr . "lo" @s counter
		icmp type echo-request ip saddr . meta iif @s2 counter
		icmp type echo-request ip saddr . 1 @s2 counter
		icmp type echo-request ip saddr . "lo" @s2 counter

		icmp type echo-request ip daddr . "lo" @s counter
		icmp type echo-request ip daddr . "lo" @s2 counter

		icmp type echo-request meta iif @s3 counter
		icmp type echo-request meta iif @s4 counter

		ip daddr . 1 @nomatch counter drop
		ip daddr . meta iif @nomatch2 counter drop
	}
}
EOF

$NFT add element t s { 127.0.0.2 . 1 }
$NFT add element t s2 { 127.0.0.2 . "lo" }

ip link set lo up
ping -q -c 1 127.0.0.2 > /dev/null