2010-10-05 16:55:44 +0000 2010-10-05 16:55:44 +0000
22
22
Advertisement

Linux opdrachtregel om proxy uit te schakelen

Advertisement

Kun je me de opdrachtregel laten zien om proxy uit te schakelen als ik de opdrachtregelterminal in Ubuntu gebruik?

Advertisement
Advertisement

Antwoorden (7)

28
28
28
2011-02-21 07:27:47 +0000

Zoals het andere antwoord zegt zijn er sommige programma’s die helemaal niet naar het systeem kijken, je moet ze misschien individueel instellen. Bijvoorbeeld wget heeft een aantal proxy-opties, die kunnen worden gebruikt om de omgevingsproxy-configuratie tijdens de uitvoering te negeren of aan te passen. Hier zijn een aantal gebieden waarop de systeem proxys kunnen worden ingesteld.

  • Hoe mijn systeem eruit ziet, merk op dat je de gespecificeerde systeemconfiguratie voor je netwerkomgeving zult moeten aanpassen.

Sommige Linux systemen gebruiken /etc/environment

$ cat /etc/environment 
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
http_proxy="http://192.168.1.250:8080/"
ftp_proxy="ftp://192.168.1.250:8080/"
https_proxy="https://192.168.1.250:8080/"

Er is geen uniforme enkele set up andere gebruiken env

$ env | grep -i proxy
NO_PROXY=localhost,127.0.0.0/8,127.0.1.1
http_proxy=http://192.168.1.250:8080/
FTP_PROXY=ftp://192.168.1.250:8080/
ftp_proxy=ftp://192.168.1.250:8080/
all_proxy=socks://192.168.1.250:8080/
ALL_PROXY=socks://192.168.1.250:8080/
HTTPS_PROXY=https://192.168.1.250:8080/
https_proxy=https://192.168.1.250:8080/
no_proxy=localhost,127.0.0.0/8,127.0.1.1
HTTP_PROXY=http://192.168.1.250:8080/

Ik zou de ~/.bashrc bekijken om de instelling automatisch te laten toepassen bij het opstarten van het systeem.

$ man env
$ man set
$ # The file section near the end of the bash manual.
$ man bash 

FILES
       /bin/bash
              The bash executable
       /etc/profile
              The systemwide initialization file, executed for login shells
       /etc/bash.bashrc
              The systemwide per-interactive-shell startup file
       /etc/bash.bash.logout
              The systemwide login shell cleanup file, executed when a login
              shell exits
       ~/.bash_profile
              The personal initialization file, executed for login shells
       ~/.bashrc
              The individual per-interactive-shell startup file
       ~/.bash_logout
              The individual login shell cleanup file, executed when a login
              shell exits
       ~/.inputrc
              Individual readline initialization file
6
6
6
2016-05-03 16:49:09 +0000

Je kunt alle variabelen in bash in één keer instellen of uitschakelen:

$ export {http,https,ftp}_proxy="http://proxy-server:port"
$ unset {http,https,ftp}_proxy

$ export {HTTP,HTTPS,FTP}_PROXY="http://proxy-server:port"
$ unset {HTTP,HTTPS,FTP}_PROXY

Je kunt ook een snelkoppeling toevoegen aan je ~/.bashrc:

# Set Proxy
function setproxy() {
    export {http,https,ftp}_proxy="http://proxy-server:port"
    export {HTTP,HTTPS,FTP}_PROXY="http://proxy-server:port"
}

# Unset Proxy
function unsetproxy() {
    unset {http,https,ftp}_proxy
    unset {HTTP,HTTPS,FTP}_PROXY
}

Vergeet niet om .bashrc te herladen:

$ . ~/.bashrc

of

$ source ~/.bashrc

Meer details op [S]hell Hacks.

3
Advertisement
3
3
2013-05-10 13:12:55 +0000
Advertisement
export http_proxy=

Je kunt controleren of ze weg zijn door

echo $http_proxy

te draaien Het zou een lege regel moeten opleveren

3
3
3
2011-08-05 06:23:06 +0000

Als u de proxy voor GUI programma’s wilt wijzigen, heeft u misschien enig succes als ze de “systeem” proxy instellingen van Gnome gebruiken. Dit zijn de proxy instellingen die vanuit het configuratiescherm ingesteld kunnen worden.

Je kunt de huidige instellingen bekijken en dan wijzigen met gconftool:

$ gconftool-2 -a /system/http_proxy
  ignore_hosts = [localhost,127.0.0.0/8,*.local]
  authentication_user =
  authentication_password =
  use_authentication = false
  use_http_proxy = true
  port = 8080
  host = http://myproxy.mydomain.org/

Om de proxy uit te schakelen - stel use_http_proxy in op false:

$ gconftool-2 -t bool -s /system/http_proxy/use_http_proxy false

Je kunt de resultaten controleren met de -a regel van hierboven. Als alternatief om een nieuwe proxy in te stellen:

$ gconftool-2 -t string -s /system/http_proxy/host "http://newproxy.mydomain.org/"
$ gconftool-2 -t int -s /system/http_proxy/port 8088
1
Advertisement
1
1
2016-05-27 07:18:15 +0000
Advertisement

Als al het bovenstaande niet werkt:

  1. Ga naar Systeem Instellingen.
  2. Ga naar Netwerk.
  3. Ga naar netwerk-proxy en zelfs als de geselecteerde keuze “geen” is, ga naar “handmatig” en verwijder alle opgeslagen proxies.
  4. Systeembreed toepassen.

Dit werkte voor mij!

1
1
1
2018-05-03 22:41:11 +0000

Om alle proxy-variabelen in één regel uit te schakelen voor je huidige sessie:

unset `env | grep proxy | cut -d= -f1`
0
Advertisement
0
0
2019-02-07 05:00:29 +0000
Advertisement

U kunt alle {httpproxy, httpsproxy} etc verwijderen uit /etc/environment. gewoon sudo gedit /etc/environment en dan handmatig al deze proxies verwijderen en opslaan.

Advertisement

Gerelateerde vragen

11
6
11
9
3
Advertisement
Advertisement