Commit 88ea9fb3 authored by Binh Nguyen's avatar Binh Nguyen

Get interfaces info automatically

parent 97aed358
......@@ -5,7 +5,8 @@ This folder includes scripts to set up a basic topology and do Segment Routing b
https://www.phantomnet.org/show-profile.php?uuid=1a298a72-22fc-11e7-91c5-90e2ba22fee4
2. How to run:
- Change the file net_info.sh manually to include the correct IPV6, MAC address, and device name for all of the nodes in the topology. This information is used to install routes on the node for SR.
- Get the interfaces IP, MAC, dev name on each node by running: ./get_all_info.sh on NODE1.
OR do it manually - change the file net_info.sh manually to include the correct IPV6, MAC address, and device name for all of the nodes in the topology. This information is used to install routes on the node for SR.
- Install globally routable IPV6 addresses for interfaces on the nodes: ./add_global_ipv6.sh
- Install the "uplink" path (from node1 to node4's netd): ./install_uplink_path.sh
- Install the "downlink" returning path (from node4's netc directly to node1's netc): ./install_downlink_path.sh
......
#!/bin/bash
#deploy and run myself
echo "#!/bin/bash" > net_info.sh
hn=$(hostname)
echo "Get info of node $hn ..."
./get_info.sh >> net_info.sh
for i in 2 3 4
do
echo "Get info of node $i ..."
scp get_info.sh node$i:~/ > /dev/null
ssh node$i "./get_info.sh" >> net_info.sh
done
echo "DONE. See net_info.sh"
#!/bin/bash
INF="/proj/PhantomNet/binh/simeca_scripts/get_interface_map.pl"
#NODE1
hn=$(hostname | awk -F'.' '{print $1}')
if [ "$hn" == "node1" ]; then
echo "#Node $hn..."
n1_a_dev=$($INF | grep neta | awk '{print $3}')
n1_a_mac=$(ifconfig | grep $n1_a_dev | awk '{print $5}')
n1_a=$(ifconfig | grep -A3 $n1_a_dev | grep inet6 | awk '{print $3}' | awk -F'/' '{print $1}')
n1_c_dev=$($INF | grep netc | awk '{print $3}')
n1_c_mac=$(ifconfig | grep $n1_c_dev | awk '{print $5}')
n1_c=$(ifconfig | grep -A3 $n1_c_dev | grep inet6 | awk '{print $3}' | awk -F'/' '{print $1}')
echo "n1_a=\"$n1_a\""
echo "n1_a_mac=\"$n1_a_mac\""
echo "n1_a_dev=\"$n1_a_dev\""
echo "n1_c=\"$n1_c\""
echo "n1_c_mac=\"$n1_c_mac\""
echo "n1_c_dev=\"$n1_c_dev\""
fi
#NODE2
hn=$(hostname | awk -F'.' '{print $1}')
if [ "$hn" == "node2" ]; then
echo "#Node $hn..."
n2_a_dev=$($INF | grep neta | awk '{print $3}')
n2_a_mac=$(ifconfig | grep $n2_a_dev | awk '{print $5}')
n2_a=$(ifconfig | grep -A3 $n2_a_dev | grep inet6 | awk '{print $3}' | awk -F'/' '{print $1}')
n2_b_dev=$($INF | grep netb | awk '{print $3}')
n2_b_mac=$(ifconfig | grep $n2_b_dev | awk '{print $5}')
n2_b=$(ifconfig | grep -A3 $n2_b_dev | grep inet6 | awk '{print $3}' | awk -F'/' '{print $1}')
echo "n2_a=\"$n2_a\""
echo "n2_a_mac=\"$n2_a_mac\""
echo "n2_a_dev=\"$n2_a_dev\""
echo "n2_b=\"$n2_b\""
echo "n2_b_mac=\"$n2_b_mac\""
echo "n2_b_dev=\"$n2_b_dev\""
fi
#NODE3
hn=$(hostname | awk -F'.' '{print $1}')
if [ "$hn" == "node3" ]; then
echo "#Node $hn..."
n3_b_dev=$($INF | grep netb | awk '{print $3}')
n3_b_mac=$(ifconfig | grep $n3_b_dev | awk '{print $5}')
n3_b=$(ifconfig | grep -A3 $n3_b_dev | grep inet6 | awk '{print $3}' | awk -F'/' '{print $1}')
n3_d_dev=$($INF | grep netd | awk '{print $3}')
n3_d_mac=$(ifconfig | grep $n3_d_dev | awk '{print $5}')
n3_d=$(ifconfig | grep -A3 $n3_d_dev | grep inet6 | awk '{print $3}' | awk -F'/' '{print $1}')
echo "n3_b=\"$n3_b\""
echo "n3_b_mac=\"$n3_b_mac\""
echo "n3_b_dev=\"$n3_b_dev\""
echo "n3_d=\"$n3_d\""
echo "n3_d_mac=\"$n3_d_mac\""
echo "n3_d_dev=\"$n3_d_dev\""
fi
#NODE4
hn=$(hostname | awk -F'.' '{print $1}')
if [ "$hn" == "node4" ]; then
echo "#Node $hn..."
n4=$($INF)
n4_c_dev=$($INF | grep netc | awk '{print $3}')
n4_c_mac=$(ifconfig | grep $n4_c_dev | awk '{print $5}')
n4_c=$(ifconfig | grep -A3 $n4_c_dev | grep inet6 | awk '{print $3}' | awk -F'/' '{print $1}')
n4_d_dev=$($INF | grep netd | awk '{print $3}')
n4_d_mac=$(ifconfig | grep $n4_d_dev | awk '{print $5}')
n4_d=$(ifconfig | grep -A3 $n4_d_dev | grep inet6 | awk '{print $3}' | awk -F'/' '{print $1}')
echo "n4_c=\"$n4_c\""
echo "n4_c_mac=\"$n4_c_mac\""
echo "n4_c_dev=\"$n4_c_dev\""
echo "n4_d=\"$n4_d\""
echo "n4_d_mac=\"$n4_d_mac\""
echo "n4_d_dev=\"$n4_d_dev\""
fi
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