Created
December 7, 2018 12:13
-
-
Save thotypous/2e671f5307214ac68743dcad58b45820 to your computer and use it in GitHub Desktop.
Contorna o isolamento entre diferentes computadores na rede eduroam da UFSCar
This file contains hidden or 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 | |
gw="$(ip route | grep -Po '^default via \K\d+\.\d+\.\d+\.\d+')" | |
iface="$(ip route | grep -Po '^default via \d+\.\d+\.\d+\.\d+ dev \K[^ ]+')" | |
local_subnet_forwarding_rule="$(ip route | grep -P "^\d+\.\d+\.\d+\.\d+/\d+ dev $iface .*? link src")" | |
gw_forwarding_rule="$gw $(echo "$local_subnet_forwarding_rule" | grep -Po '^\d+\.\d+\.\d+\.\d+/\d+ \K.+')" | |
if [[ ! -z "$local_subnet_forwarding_rule" ]]; then | |
set -xe | |
sudo ip route del $local_subnet_forwarding_rule | |
sudo ip route add $gw_forwarding_rule | |
set +xe | |
else | |
echo "Não achamos a regra de encaminhamento para a subrede local." | |
echo "Você já executou este script antes? Então já deve estar tudo pronto." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment