1# $FreeBSD$ 2 3. $(atf_get_srcdir)/utils.subr 4 5atf_test_case "basic" "cleanup" 6basic_head() 7{ 8 atf_set descr 'Basic rdr test' 9 atf_set require.user root 10} 11 12basic_body() 13{ 14 pft_init 15 16 epair=$(pft_mkepair) 17 18 pft_mkjail alcatraz ${epair}b 19 20 ifconfig ${epair}a 192.0.2.2/24 up 21 route add -net 198.51.100.0/24 192.0.2.1 22 23 jexec alcatraz ifconfig ${epair}b 192.0.2.1/24 up 24 jexec alcatraz sysctl net.inet.ip.forwarding=1 25 26 # Enable pf! 27 jexec alcatraz pfctl -e 28 pft_set_rules alcatraz \ 29 "rdr pass on ${epair}b proto tcp from any to 198.51.100.0/24 port 1234 -> 192.0.2.1 port 4321" 30 31 echo "foo" | jexec alcatraz nc -N -l 4321 & 32 sleep 1 33 34 result=$(nc -N -w 3 198.51.100.2 1234) 35 if [ "$result" != "foo" ]; then 36 atf_fail "Redirect failed" 37 fi 38} 39 40basic_cleanup() 41{ 42 pft_cleanup 43} 44 45atf_init_test_cases() 46{ 47 atf_add_test_case "basic" 48} 49