Commit e1c10b6a authored by Matous Holinka's avatar Matous Holinka

Netlab: new funcionality with bridge

parent a334a3d7
......@@ -59,9 +59,9 @@ protocol ospf v3 ospf4 {
area 0 {
interface "ve0" { stub; };
interface "ve1" { hello 5; type ptp; };
interface "ve2" { hello 5; type bcast; ttl security; };
interface "ve3" { hello 5; type bcast; ttl security; };
interface "ve1" { hello 5; type bcast; };
# interface "ve2" { hello 5; type bcast; ttl security; };
# interface "ve3" { hello 5; type bcast; ttl security; };
};
}
......@@ -76,8 +76,8 @@ protocol ospf v3 ospf6 {
area 0 {
interface "ve0" { stub; };
interface "ve1" { hello 5; type ptp; };
interface "ve2" { hello 5; type bcast; };
interface "ve1" { hello 5; type bcast; };
# interface "ve2" { hello 5; type bcast; };
};
}
......@@ -66,9 +66,9 @@ protocol ospf v3 ospf4 {
stubnet 192.168.220.0/32 { cost 100; };
interface "ve0" { stub; };
interface "ve1" { hello 5; type bcast; ttl security; };
interface "ve1" { hello 5; type bcast; };
# interface "ve1" { hello 5; type bcast; authentication simple; password "pass"; };
interface "ve2" { hello 5; type ptp; };
# interface "ve2" { hello 5; type bcast; };
};
}
......@@ -82,7 +82,7 @@ protocol ospf v3 ospf6 {
area 0 {
interface "ve0" { stub; };
interface "ve1" { hello 5; type bcast; ttl security; };
interface "ve2" { hello 5; type ptp; };
interface "ve1" { hello 5; type bcast; };
#interface "ve2" { hello 5; type bcast; };
};
}
......@@ -59,10 +59,10 @@ protocol ospf v3 ospf4 {
stubnet 192.168.220.0/32 { cost 10; };
interface "ve0" { stub; };
interface "ve1" { hello 5; type ptp; };
interface "ve2" { hello 5; type bcast; ttl security; };
interface "ve1" { hello 5; type bcast; };
# interface "ve2" { hello 5; type bcast; ttl security; };
# interface "ve3" { hello 5; type bcast; ttl security; };
# interface "ve1" { hello 5; type ptp; authentication cryptographic; password "qwerty"; };
# interface "ve1" { hello 5; type bcast; authentication cryptographic; password "qwerty"; };
# interface "ve2" { hello 5; type bcast; authentication simple; password "pass"; };
};
}
......@@ -77,8 +77,8 @@ protocol ospf v3 ospf6 {
area 0 {
interface "ve0" { stub; };
interface "ve1" { hello 5; type ptp; ttl security; };
interface "ve2" { hello 5; type bcast; ttl security; };
interface "ve1" { hello 5; type bcast; };
# interface "ve2" { hello 5; type bcast; ttl security; };
};
}
......@@ -73,9 +73,9 @@ protocol ospf v3 ospf4 {
stubnet 192.168.220.0/32 { cost 400; };
interface "ve0" { stub; };
interface "ve1" { hello 5; type bcast; ttl security; };
interface "ve2" { hello 5; type ptp; };
# interface "ve2" { hello 5; type ptp; authentication cryptographic; password "qwerty"; };
interface "ve1" { hello 5; type bcast; };
# interface "ve2" { hello 5; type bcast; };
# interface "ve2" { hello 5; type bcast; authentication cryptographic; password "qwerty"; };
};
}
......@@ -90,6 +90,6 @@ protocol ospf v3 ospf6 {
area 0 {
interface "ve0" { stub; };
interface "ve1" { hello 5; type bcast; };
interface "ve2" { hello 5; type ptp; ttl security; };
# interface "ve2" { hello 5; type bcast; ttl security; };
};
}
NETLAB_NODES="m1 m2 m3 m4"
netlab_init
if_net n1
if_dummy m1 ve0 192.168.1 2001:db8:01:1
if_dummy m2 ve0 192.168.2 2001:db8:02:1
if_dummy m3 ve0 192.168.3 2001:db8:03:1
if_dummy m4 ve0 192.168.4 2001:db8:04:1
if_veth m1 ve1 m2 ve2 192.168.11
if_veth m2 ve1 m3 ve2 192.168.12
if_veth m3 ve1 m4 ve2 192.168.13
if_veth m4 ve1 m1 ve2 192.168.14
if_link m1 ve1 n1 192.168.11.1
if_link m2 ve1 n1 192.168.11.2
if_link m3 ve1 n1 192.168.11.3
if_link m4 ve1 n1 192.168.11.4
netlab_start
......@@ -4,6 +4,8 @@ shopt -s nullglob
export COMMON="../common"
export CONFIG="../config"
BNS="Bridge_namespace"
function netlab_init_node()
{
N=$1
......@@ -20,6 +22,8 @@ function netlab_init_node()
function netlab_init()
{
ip netns add $BNS
for N in $NETLAB_NODES
do netlab_init_node $N
done
......@@ -47,6 +51,7 @@ function netlab_start_node()
echo
}
function netlab_stop_node()
{
N=$1
......@@ -75,6 +80,7 @@ function netlab_start()
done
}
function netlab_stop()
{
for N in */netns
......@@ -82,6 +88,17 @@ function netlab_stop()
netlab_stop_node ${N%/netns}
ip netns del ${N%/netns}
done
ip netns del $BNS
}
function if_net()
{
IF=$1
ip link add name $IF netns $BNS type bridge
ip netns exec $BNS ip link set $IF up
}
......@@ -130,6 +147,32 @@ function if_veth()
fi
}
function if_link()
{
NS1=${1%%/*}
IF1=$2
NS2=$BNS
IF2=${NS1}_${IF1}
NET=$3
ip link add name $IF1 netns $NS1 type veth peer name $IF2 netns $NS2
if [[ $1 == */* ]]; then ip netns exec $NS1 ip link set $IF1 vrf ${1##*/} ; fi
ip netns exec $NS2 ip link set $IF2 master $NET
ip netns exec $NS1 ip link set $IF1 up
ip netns exec $NS2 ip link set $IF2 up
ip netns exec $NS1 ip addr add ${4}/24 dev $IF1
if [ -n "$5" ]
then
ip netns exec $NS1 ip addr add ${5}/64 dev $IF1
fi
}
function vrf()
{
NS=$1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment