Skip to content

Instantly share code, notes, and snippets.

@thotypous
Created December 7, 2018 12:13
Show Gist options
  • Save thotypous/2e671f5307214ac68743dcad58b45820 to your computer and use it in GitHub Desktop.
Save thotypous/2e671f5307214ac68743dcad58b45820 to your computer and use it in GitHub Desktop.
Contorna o isolamento entre diferentes computadores na rede eduroam da UFSCar
#!/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