Last active
July 17, 2019 12:52
-
-
Save stoyanovgeorge/13b0c170279e7e01d10198f99b32c151 to your computer and use it in GitHub Desktop.
Creates a multicast routing after the user inputs a valid network interface and then it lists the routing table.
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
#!/bin/bash | |
# Creating an array containing all network interfaces which are up | |
net_array=() | |
for iface in $(ifconfig | cut -d ' ' -f1| tr ':' '\n' | awk NF) | |
do | |
net_array+=("$iface") | |
done | |
unset "net_array[${#net_array[@]}-1]" | |
printf "\nPlease select the network interface you want to use:\n" | |
read -r net_iface | |
while ! [[ "${net_array[*]}" =~ (^| )"$net_iface"( |$) ]]; do # check if the user input is valid | |
echo "Please enter a valid network interface:" | |
read -r net_iface | |
done | |
sudo ip r a 224.0.0.0/3 dev "$net_iface" | |
ip r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment