summaryrefslogtreecommitdiffstats
path: root/tests/shell/testcases/import/vm_json_import_0
blob: dc367f646140ee087f6d658b7e2aef7ef1733da0 (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
#!/bin/bash

tmpfile=$(mktemp)

if [ ! -w $tmpfile ] ; then
	echo "Failed to create tmp file" >&2
	exit 0
fi

trap "rm -rf $tmpfile" EXIT # cleanup if aborted

RULESET="table ip mangle {
	set blackhole {
		type ipv4_addr
		elements = { 192.168.1.4, 192.168.1.5 }
	}

	chain prerouting {
		type filter hook prerouting priority 0; policy accept;
		tcp dport { ssh, http } accept
		ip saddr @blackhole drop
		icmp type echo-request accept
		iifname \"lo\" accept
		icmp type echo-request counter packets 0 bytes 0
		ct state established,related accept
		tcp flags != syn counter packets 7 bytes 841
		ip saddr 192.168.1.100 ip daddr 192.168.1.1 counter packets 0 bytes 0
	}
}
table arp x {
	chain y {
		arp htype 22
		arp ptype ip
		arp operation != rrequest
		arp operation { request, reply, rrequest, rreply, inrequest, inreply, nak }
		arp hlen 33-45
	}
}
table bridge x {
	chain y {
		type filter hook input priority 0; policy accept;
		vlan id 4094
		vlan id 4094 vlan cfi 0
		vlan id 1 ip saddr 10.0.0.0/23 udp dport domain
	}
}
table ip6 x {
	chain y {
		type nat hook postrouting priority 0; policy accept;
		icmpv6 id 33-45
		ip6 daddr fe00::1-fe00::200 udp dport domain counter packets 0 bytes 0
		meta l4proto tcp masquerade to :1024
		iifname \"wlan0\" ct state established,new tcp dport vmap { ssh : drop, 222 : drop } masquerade
		tcp dport ssh ip6 daddr 1::2 ether saddr 00:0f:54:0c:11:04 accept
		ip6 daddr fe00::1-fe00::200 udp dport domain counter packets 0 bytes 0 masquerade
	}
}"

echo "$RULESET" > $tmpfile
$NFT -f $tmpfile
$NFT export vm json > $tmpfile
$NFT flush ruleset
cat $tmpfile | $NFT import vm json

RESULT="$($NFT list ruleset)"


if [ "$RULESET" != "$RESULT" ] ; then
	DIFF="$(which diff)"
	[ -x $DIFF ] && $DIFF -u <(echo "$RULESET") <(echo "$RESULT")
fi