Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

避免每次切换网关都输入密码

icymind edited this page Aug 14, 2017 · 1 revision

每次切换网关, 都会执行两条命令:

  • sudo /sbin/route change default ${ip}
  • sudo /usr/sbin/networksetup -setdnsservers "${networkservice}" "${ip}"

如果不想每次都输入密码, 可以配置/etc/sudoers文件, 对这两条命令免密码执行:

  1. sudo visudo
  2. 在文件中添加一行: abcdefg ALL=(ALL) NOPASSWD:SETENV: /usr/sbin/networksetup, /sbin/route, 其中abcdefg改为自己用户名
Clone this wiki locally