2
$ curl http://google.de # DNS resolution works fine
...
$ sudo curl http://google.de
curl: (6) Couldn't resolve host 'google.de'
$ echo $http_proxy
http://proxy:8080
$ cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
127.0.1.1 debian
# ip6-stuff below
$ hostname
debian
I am using Debian squeeze (LXDE) inside VirtualBox and can do admin stuff via a real root console or via su root
. I added my user to the sudoers group and can do stuff like editing via sudo, e.g., sudo vim /etc/hosts
. I'd like to use sudo
instead of su root
.
Why are curl
(and other tools like aptitude
) not able to resolve the hostnames, but when using them as normal user or plain root everything works fine?
Edit: Here is the solution (Thx to Paul):
$ sudo visudo
# add this line
Defaults env_keep = "http_proxy https_proxy ftp_proxy"
# above this line
Defaults env_reset
I would first try either setting http_variable in root's environment or using curl's -x option to use proxy while using sudo.
-x, --proxy <[protocol://][user@password]proxyhost[:port]>
– Sachin Divekar – 2011-11-25T13:12:47.210I added the
http_*
var in/etc/bash.bashrc
, but Pauls solution also worked. Do I also have to set such var in/etc/environment
? – Juve – 2011-11-25T13:44:09.737