Linux 下 NetworkManager 自定义 DNS | wget: unable to resolve host address

本文介绍了在Fedora系统中通过NetworkManager进行DNS配置的方法。包括两种配置方式:常规方法及改进方法,确保DNS设置的持久性和稳定性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

OS: fedora
Kernel: 2.6.30
Package: NetworManager 0.8


一、第一种方法(常规方法)

在 Linux (笔者用fedora) 下当使用 NetworkManager时,更改 DNS 的一般方式:

  1. 修改 /etc/resolv.conf 文件, 添加 "nameserver ip" 行.
  2. 修改 /etc/sysconfig/network-scripts/ifcfg-eth0, 添加 "DNS1=ip", "DNS2=IP"...行。
  3. 修改 /etc/sysconfig/networking/....目录下的 ifcfg-eth0 或者 default. 方式同上。

修改完文件后需要运行 "service NetworkManager restart" 重启网络以使设置生效。

另说明linux 服务的管理方法:

service NetworkManager restart | start | stop | status

上面的 NetworkManager 可被其他服务名替换。"|" 隔开的命令可任选其一。

注意:以上修改在 关机再次启动 电脑后会被 NetworkManager重置为默认 isp 的 dns. 即 "generated by NetworkManager".

二、第二种方法(改进)

用 NetworkManager 管理网络设置,并永久自定义 DNS. 可以如下设置:

  1. 修改 /etc/resolv.conf , 添加 "nameserver ip".
  2. 运行 "sudo chattr +i /etc/resolv.conf", 该命令修改文件属性为 只有 root 用户才能修改该文件。去掉可将参数改为 "-i".
  3. 以 root 身份运行 "service NetworkManager restart".

注意:此时 会产生 /etc/resolv.conf.tmp 文件,不必理会。

三、推荐DNS

Google Public DNS: 8.8.8.8; 8.8.4.4.
Norton DNS: 198.153.192.1; 198.153.194.1.
OpenDNS: 208.67.222.222; 208.67.220.220.

四、笔者的 /etc/resolv.conf 文件

#此行注释

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 198.153.192.1
nameserver 198.153.194.1
nameserver 208.67.222.222
nameserver 208.67.220.220



Edited by DC Morgan on 2010-06-03
带着崇敬与赞美,献给活在计算机里的神灵


 

++++++++++++++++++++++++++++++++++++++++++++

 

 

今天下载kloxo,可是下载不了,提示:
     wget http://download.lxlabs.com/download/kloxo/production/kloxo-install-master.sh
--2010-07-30 22:22:39--   http://download.lxlabs.com/download/kloxo/production/kloxo-install-master.sh
Resolving download.lxlabs.com... failed: Temporary failure in name resolution.
wget: unable to resolve host address `download.lxlabs.com'

发现在DNS没有配置,所以在 /etc/resolv.conf 这个文件中添加DNS就行了

#   [root@li120-145 tmp]# vi /etc/resolv.conf
    nameserver 10.0.80.11
    nameserver 10.0.80.12

重启服务
service NetworkManager restart

 

添加上上面的DNS就可以了!

 

 


 

 

 

 

 

 

转载于:https://www.cnblogs.com/52linux/archive/2012/03/27/2418956.html

[14:10:59.703] Log Level: 2 [14:10:59.709] SSH Resolver called for "ssh-remote+192.168.124.6", attempt 1 [14:10:59.710] "remote.SSH.useLocalServer": false [14:10:59.710] "remote.SSH.useExecServer": false [14:10:59.710] "remote.SSH.showLoginTerminal": false [14:10:59.710] "remote.SSH.remotePlatform": {} [14:10:59.710] "remote.SSH.path": undefined [14:10:59.710] "remote.SSH.configFile": undefined [14:10:59.710] "remote.SSH.useFlock": true [14:10:59.710] "remote.SSH.lockfilesInTmp": false [14:10:59.710] "remote.SSH.localServerDownload": auto [14:10:59.710] "remote.SSH.remoteServerListenOnSocket": false [14:10:59.710] "remote.SSH.showLoginTerminal": false [14:10:59.710] "remote.SSH.defaultExtensions": [] [14:10:59.710] "remote.SSH.loglevel": 2 [14:10:59.710] "remote.SSH.enableDynamicForwarding": true [14:10:59.710] "remote.SSH.enableRemoteCommand": false [14:10:59.711] "remote.SSH.serverPickPortsFromRange": {} [14:10:59.711] "remote.SSH.serverInstallPath": {} [14:10:59.712] VS Code version: 1.85.2 [14:10:59.712] Remote-SSH version: remote-ssh@0.108.2023112915 [14:10:59.712] win32 x64 [14:10:59.713] SSH Resolver called for host: 192.168.124.6 [14:10:59.713] Setting up SSH remote "192.168.124.6" [14:10:59.716] Using commit id "8b3775030ed1a69b13e4f4c628c612102e30a681" and quality "stable" for server [14:10:59.719] Install and start server if needed [14:11:00.628] Checking ssh with "C:\Program Files (x86)\Common Files\Oracle\Java\java8path\ssh.exe -V" [14:11:00.630] Got error from ssh: spawn C:\Program Files (x86)\Common Files\Oracle\Java\java8path\ssh.exe ENOENT [14:11:00.630] Checking ssh with "C:\Program Files (x86)\Common Files\Oracle\Java\javapath\ssh.exe -V" [14:11:00.631] Got error from ssh: spawn C:\Program Files (x86)\Common Files\Oracle\Java\javapath\ssh.exe ENOENT [14:11:00.631] Checking ssh with "C:\Windows\system32\ssh.exe -V" [14:11:00.632] Got error from ssh: spawn C:\Windows\system32\ssh.exe ENOENT [14:11:00.632] Checking ssh with "C:\Windows\ssh.exe -V" [14:11:00.632] Got error from ssh: spawn C:\Windows\ssh.exe ENOENT [14:11:00.632] Checking ssh with "C:\Windows\System32\Wbem\ssh.exe -V" [14:11:00.633] Got error from ssh: spawn C:\Windows\System32\Wbem\ssh.exe ENOENT [14:11:00.633] Checking ssh with "C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe -V" [14:11:00.634] Got error from ssh: spawn C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT [14:11:00.634] Checking ssh with "C:\Windows\System32\OpenSSH\ssh.exe -V" [14:11:00.654] > OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2 [14:11:00.657] Running script with connection command: "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 58191 "192.168.124.6" bash [14:11:00.658] Terminal shell path: C:\Windows\System32\cmd.exe [14:11:01.076] > root@192.168.124.6's password:]0;C:\Windows\System32\cmd.exe [14:11:01.076] Got some output, clearing connection timeout [14:11:01.077] Showing password prompt [14:11:03.383] Got password response [14:11:03.383] "install" wrote data to terminal: "******" [14:11:03.428] > [14:11:03.987] > 43b74eacbca4: running [14:11:04.112] > Acquiring lock on /root/.vscode-server/bin/8b3775030ed1a69b13e4f4c628c612102e30a681/vscode-remote-lock.root.8b3775030ed1a69b13e4f4c628c612102e30a681 [14:11:04.127] > Installing to /root/.vscode-server/bin/8b3775030ed1a69b13e4f4c628c612102e30a681... [14:11:04.143] > 43b74eacbca4%%1%% [14:11:04.160] > Downloading with wget [14:11:11.206] > wget download failed > wget: unable to resolve host address ‘update.code.visualstudio.com’ > printenv: > SSH_CONNECTION=192.168.124.33 58192 192.168.124.6 22 > LANG=en_US.UTF-8 > XDG_SESSION_ID=1 > USER=root > PWD=/root/.vscode-server/bin/8b3775030ed1a69b13e4f4c628c612102e30a681 > HOME=/root > SSH_CLIENT=192.168.124.33 58192 22 > MAIL=/var/mail/root > SHELL=/bin/bash > SHLVL=2 > VSCODE_AGENT_FOLDER=/root/.vscode-server > LOGNAME=root > DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus > XDG_RUNTIME_DIR=/run/user/0 > PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin > _=/usr/bin/printenv > OLDPWD=/root > Trigger local server download > 43b74eacbca4:trigger_server_download > artifact==server-linux-arm64== > destFolder==/root/.vscode-server/bin/== > destFolder2==/8b3775030ed1a69b13e4f4c628c612102e30a681/vscode-server.tar.gz== > 43b74eacbca4:trigger_server_download_end > Waiting for client to transfer server archive... > Waiting for /root/.vscode-server/bin/8b3775030ed1a69b13e4f4c628c612102e30a681/vs > scode-server.tar.gz.done and vscode-server.tar.gz to exist [14:11:11.206] Got request to download on client for {"artifact":"server-linux-arm64","destPath":"/root/.vscode-server/bin//8b3775030ed1a69b13e4f4c628c612102e30a681/vscode-server.tar.gz"} [14:11:11.206] Downloading VS Code server locally... [14:11:11.221] > > [14:11:11.456] Resolver error: Error: XHR failed at k.onerror (vscode-file://vscode-app/d:/VSC/resources/app/out/vs/workbench/workbench.desktop.main.js:95:2027) [14:11:11.462] ------
最新发布
06-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值