📜  禁用公共互联网访问 linux - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:50:50.206000             🧑  作者: Mango

代码示例1
GW="$(sudo /sbin/route -n | awk '$1=="0.0.0.0" {print $2; exit}')"
sudo /sbin/route del default gw "$GW"
echo "$GW" >~/my_tmp_file

The last line saves the value in a file for later use when you want to restart the network:
sudo /sbin/route add default gw "$(cat ~/my_tmp_file)"