Blog is moving

My blog is moving to http://victormendonca.com/blog/. If you are looking for a specific or older post you are in the right place Otherwise check out my new page for more up to date content.

Wednesday, January 9, 2008

How to change Gnome Proxy Settings on a Terminal window


This document will show how to change proxy settings for Gnome from a terminal window (not from gnome-network-preferences).

The configuration information is saved under .gconf (front end GconfEdior), which is a system for storing application preference in Gnome (think Registry for Windows PC).

Keys can be accessed in terminal under “/home/user/.gconf/*”. The command below will display current proxy configuration loaded by gconf:

$ cat .gconf/system/http_proxy/%gconf.xml


This will be the same as:


The proxy configuration can be divided into two parts:
. /system/proxy/ - Configures SOCKS Proxy
. /system/http_proxy/ - Configures HTTP proxy

We can use gconftool -R to view the options within the subkeys. For the screenshot above we would get something similar to this:

$ gconftool -R /system/proxy
old_ftp_port = 0
socks_host = 127.0.0.1
mode = manual
old_socks_port = 0
secure_host = 127.0.0.1
ftp_host = 127.0.0.1
socks_port = 80
old_secure_host =
secure_port = 80
ftp_port = 80
old_ftp_host =
autoconfig_url =
old_secure_port = 0
old_socks_host =

$ gconftool -R /system/http_proxy
use_http_proxy = true
use_authentication = false
host = 127.0.0.1
authentication_user =
ignore_hosts = [localhost,127.0.0.0/8,*.local]
use_same_proxy = true
authentication_password =
port = 80


So, to edit the proxy to the same settings as the one shown on the screenshot, we would do the following:

$ gconftool -s /system/http_proxy/use_http_proxy -t bool true
$ gconftool -s /system/http_proxy/host -t int 127.0.0.1
$ gconftool -s /system/http_proxy/port -t int 80
$ gconftool -s /system/http_proxy/use_same_proxy -t bool true

$ gconf -s /system/proxy/mode -t string manual



Vic.

13 comments:

Anonymous said...

Great blog. Was looking for this for a proxy switch script for my school

--script--
#!/bin/bash
gconftool -s /system/proxy/mode -t string manual
ssh -D 9999 user@server && gconftool -s /system/proxy/mode -t string none
--/script--

Anonymous said...

Thanks.

Victor Okinda said...

Nice work, had a problem though i've checkd n found that the proxy settings for my network are ok and infact firefox just works well but all the other applicastions cant connect to the net.

Victor said...

Hey Victor,

I think it will depend on the program that you are using, and if it uses Gnome's proxy settings.

For shell you might need to use a program called corkscrew.

http://www.agroman.net/corkscrew/


Vic.

Anonymous said...

Thanks for the info! it worked just fine on intrepid. However, it doesn't work anymore on jaunty. I'm just wondering why. The xml file changes correctly but it seems that the proxy configuration applet doesn't recognize that.

richard_bw said...

should've figured this out myself... but thanks for the clear pointers

SIFE said...

does this mean my runing program will use this proxy ?

Mutuelle sante said...

Thank you it was a very good guide, now to change gnome proxy settings on a terminal window is without a doubt easy by using your tips. Kudos

Alex said...

@Gato
Have a look here:
https://bugs.launchpad.net/ubuntu/+source/gconf/+bug/290647

That worked for me.

Anonymous said...

Thanks a lot

Anonymous said...

Thank You, this is exactly what i'am looking for !
You made my day !
I know this is old, but there has changed some syntax in newer Ubuntu-Versions ;-)

Worked nice under Ubuntu 11.04

--script--
#!bin/sh
gconftool -s /system/proxy/mode -t string manual
gconftool -s /system/http_proxy/use_http_proxy -t bool true
gconftool -s /system/http_proxy/host -t string 127.0.0.1
gconftool -s /system/http_proxy/port -t int 3128
gconftool -s /system/http_proxy/use_same_proxy -t bool true
--/script--

If you want to change to default settings
--script--
#!bin/sh
gconftool -s /system/proxy/mode -t string direct
gconftool -s /system/http_proxy/use_http_proxy -t bool false
--/script--

Have a lot of fun !

Anonymous said...

Thanks a lot!

Worked just fine with gconftool-2 on Fedora.

Linux and Shell Scripting Learning. said...

Thanks alot. Very useful post.