-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Firewall - Examples fix and doc enhancement (#296)
* Fixed typo in Tutorial4 * [FIX] Firewall examples and doc improvement This commit aims to fix all the firewall examples which, unfortunately, were referring to an older version of the service. An additional script to clear the environment has been created and linked into the doc. Signed-off-by: Simone Magnani <simonemagnani.96@gmail.com>
- Loading branch information
Showing
14 changed files
with
162 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
#Deleting firewall | ||
polycubectl firewall del fw | ||
|
||
#Deleting standard cube | ||
polycubectl simplebridge del br | ||
|
||
#Deleting namespaces | ||
for i in `seq 1 2`;do | ||
sudo ip link del veth${i} | ||
sudo ip netns del ns${i} | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,44 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
#Argument 1 is the physical interface name | ||
if [ $# -ne 1 ];then | ||
echo "No arguments <physical_interface_name> supplied" | ||
exit 1 | ||
fi | ||
|
||
# assume polycubed is already running | ||
# sudo polycubed -d | ||
|
||
# assume veth1 and veth2 already created and configured | ||
# ./setup_veth.sh | ||
# There is no need to run setup_env.sh | ||
# since this example attaches the firewall directly to the physical interface | ||
|
||
function fwcleanup { | ||
set +e | ||
polycubectl firewall del fw | ||
polycubectl firewall del fw1 | ||
} | ||
trap fwcleanup EXIT | ||
|
||
echo -e '\nExample using the host mode \n' | ||
echo -e '\n+++ ONLY the ingress chain is supported at the moment! \n' | ||
echo 'Example using the host mode' | ||
|
||
set -e | ||
set -x | ||
|
||
polycubectl firewall add fw | ||
polycubectl firewall add fw1 | ||
|
||
# Attaching the firewall to the physical interface | ||
polycubectl attach fw1 $1 | ||
|
||
polycubectl firewall fw1 chain INGRESS rule add 0 l4proto=UDP action=FORWARD | ||
polycubectl firewall fw1 chain INGRESS rule add 1 l4proto=ICMP action=FORWARD | ||
|
||
# Connecting the host | ||
polycubectl firewall fw ports add to_host | ||
polycubectl firewall fw ports to_host set peer=:host | ||
polycubectl firewall fw1 chain EGRESS rule add 0 l4proto=UDP action=FORWARD | ||
polycubectl firewall fw1 chain EGRESS rule add 1 l4proto=ICMP action=FORWARD | ||
|
||
# ++ Replace <physicalInterface> with the physical interface name | ||
polycubectl firewall fw ports add to_ens | ||
polycubectl firewall fw ports to_ens set peer=<physicalInterface> | ||
echo "Press any key to test applied rules" | ||
read | ||
|
||
polycubectl firewall fw chain INGRESS rule add 0 l4proto=UDP action=FORWARD | ||
polycubectl firewall fw chain INGRESS rule add 1 l4proto=ICMP action=FORWARD | ||
#Ping allowed | ||
ping -c 2 google.com | ||
|
||
#ping | ||
ping www.google.it | ||
#TCP not allowed (no response) | ||
nping -c 2 google.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
polycubectl fw del | ||
|
||
polycubectl firewall add fw | ||
|
||
polycubectl attach fw br:port1 | ||
|
||
echo "Firewall reconfigured" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#! /bin/bash | ||
|
||
set -x | ||
|
||
# Setup veths. Useful for testing service with linux namespaces. | ||
|
||
echo "Configuring network namespaces" | ||
|
||
for i in `seq 1 2`; | ||
do | ||
sudo ip netns del ns${i} > /dev/null 2>&1 # remove ns if already existed | ||
sudo ip link del veth${i} > /dev/null 2>&1 | ||
|
||
sudo ip netns add ns${i} | ||
sudo ip link add veth${i}_ type veth peer name veth${i} | ||
sudo ip link set veth${i}_ netns ns${i} | ||
sudo ip netns exec ns${i} ip link set dev veth${i}_ up | ||
sudo ip link set dev veth${i} up | ||
sudo ip netns exec ns${i} ifconfig veth${i}_ 10.0.0.${i}/24 | ||
done | ||
|
||
# Setup standard cube (Simplebridge) | ||
|
||
echo "Configuring standard cube" | ||
|
||
polycubectl br del | ||
|
||
polycubectl simplebridge add br | ||
|
||
polycubectl simplebridge br ports add port1 | ||
polycubectl simplebridge br ports add port2 | ||
|
||
polycubectl connect br:port1 veth1 | ||
polycubectl connect br:port2 veth2 | ||
|
||
# Creating and attaching Firewall to Simplebridge | ||
|
||
echo "Configuring Firewall" | ||
|
||
polycubectl fw del | ||
|
||
polycubectl firewall add fw | ||
|
||
polycubectl attach fw br:port1 | ||
|
||
# EGRESS_CHAIN and INGRESS_CHAIN are now considered independently | ||
|
||
# br:port1 <---- EGRESS ----< br:port2 | ||
# br:port1 >----INGRESS ----> br:port2 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
# test ping between veth1 and veth2 | ||
# test ping between br:port1 and br:port2 | ||
|
||
sudo ip netns exec ns1 ping 10.0.0.2 -c 2 | ||
sudo ip netns exec ns2 ping 10.0.0.1 -c 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.