![如何在 ubuntu 18.04 上自动配置代理?](https://linux22.com/image/905324/%E5%A6%82%E4%BD%95%E5%9C%A8%20ubuntu%2018.04%20%E4%B8%8A%E8%87%AA%E5%8A%A8%E9%85%8D%E7%BD%AE%E4%BB%A3%E7%90%86%EF%BC%9F.png)
在我的工作场所,我使用代理,并手动设置它,如下图所示:
我在家里也使用同一台笔记本电脑,不需要代理配置。
问题:
我每天需要在办公室将代理设置为手动,并在回家时将其禁用。
已经尝试过:
我已经看过另一个了邮政然后教程并设置 /etc/proxy.pac
如下:
function FindProxyForURL(url, host)
{
if (isInNet(myIpAddress(), "172.16.15.121", "255.255.255.0"))
{
if (isInNet(host, "192.168.0.109", "255.255.255.0"))
return "DIRECT";
if (shExpMatch(url, "http:*"))
return "PROXY 172.16.1.101:8080" ;
if (shExpMatch(url, "https:*"))
return "PROXY 172.16.1.101:8080" ;
if (shExpMatch(url, "ftp:*"))
return "PROXY 172.16.1.101:8080" ;
return "DIRECT";
}
else
{
return "DIRECT";
}
}
将代理设置为自动并提供配置网址后,我无法在工作场所访问互联网file:///etc/proxy.pac
。
一些可能有帮助的命令的输出:
ifconfig
enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.15.121 netmask 255.255.255.0 broadcast 172.16.15.255
inet6 fe80::9ad7:34ce:f3c3:29bf prefixlen 64 scopeid 0x20<link>
ether 60:eb:69:e5:b8:7d txqueuelen 1000 (Ethernet)
RX packets 18232 bytes 16794351 (16.7 MB)
RX errors 0 dropped 47 overruns 0 frame 0
TX packets 14989 bytes 1918912 (1.9 MB)
TX errors 0 dropped 0 overruns 0 carrier 3 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 9195 bytes 664533 (664.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 9195 bytes 664533 (664.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
hostname -i
127.0.1.1