If you have Vagrant installed, you can run the above example with the following commands.
-
In a terminal (terminal 1), bring up the Vagrant box:
$ vagrant up
This will take a few minutes to download and provision the box.
-
Connect to the Vagrant box:
$ vagrant ssh
-
Build
pwru
:$ cd /pwru $ make
-
Run
pwru
:$ sudo ./pwru --filter-dst-ip=1.1.1.1 --filter-dst-port=80 --filter-proto=tcp --output-tuple
-
In a new terminal (terminal 2), connect to the Vagrant box:
$ vagrant ssh
-
In terminal 2, run
curl
to generate some traffic to 1.1.1.1:$ curl 1.1.1.1
Observe the output of
pwru
in terminal 1. -
In terminal 2, add an
iptables
rule to block traffic to 1.1.1.1:$ sudo iptables -t filter -I OUTPUT 1 -m tcp --proto tcp --dst 1.1.1.1/32 -j DROP
-
In terminal 2, run
curl
to generate some traffic to 1.1.1.1:$ curl 1.1.1.1
Observe the output of
pwru
in terminal 1. -
To clean up, press
Ctrl+C
to terminatepwru
in terminal 1, exit both shells, and run:$ vagrant destroy