特殊:Badtitle/NS100:StaticDnsWithDhcp
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/StaticDnsWithDhcp }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/af | • {{#if: UbuntuHelp:StaticDnsWithDhcp|Afrikaans| [[::StaticDnsWithDhcp/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/ar | • {{#if: UbuntuHelp:StaticDnsWithDhcp|العربية| [[::StaticDnsWithDhcp/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/az | • {{#if: UbuntuHelp:StaticDnsWithDhcp|azərbaycanca| [[::StaticDnsWithDhcp/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/bcc | • {{#if: UbuntuHelp:StaticDnsWithDhcp|جهلسری بلوچی| [[::StaticDnsWithDhcp/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/bg | • {{#if: UbuntuHelp:StaticDnsWithDhcp|български| [[::StaticDnsWithDhcp/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/br | • {{#if: UbuntuHelp:StaticDnsWithDhcp|brezhoneg| [[::StaticDnsWithDhcp/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/ca | • {{#if: UbuntuHelp:StaticDnsWithDhcp|català| [[::StaticDnsWithDhcp/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/cs | • {{#if: UbuntuHelp:StaticDnsWithDhcp|čeština| [[::StaticDnsWithDhcp/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/de | • {{#if: UbuntuHelp:StaticDnsWithDhcp|Deutsch| [[::StaticDnsWithDhcp/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/el | • {{#if: UbuntuHelp:StaticDnsWithDhcp|Ελληνικά| [[::StaticDnsWithDhcp/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/es | • {{#if: UbuntuHelp:StaticDnsWithDhcp|español| [[::StaticDnsWithDhcp/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/fa | • {{#if: UbuntuHelp:StaticDnsWithDhcp|فارسی| [[::StaticDnsWithDhcp/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/fi | • {{#if: UbuntuHelp:StaticDnsWithDhcp|suomi| [[::StaticDnsWithDhcp/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/fr | • {{#if: UbuntuHelp:StaticDnsWithDhcp|français| [[::StaticDnsWithDhcp/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/gu | • {{#if: UbuntuHelp:StaticDnsWithDhcp|ગુજરાતી| [[::StaticDnsWithDhcp/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/he | • {{#if: UbuntuHelp:StaticDnsWithDhcp|עברית| [[::StaticDnsWithDhcp/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/hu | • {{#if: UbuntuHelp:StaticDnsWithDhcp|magyar| [[::StaticDnsWithDhcp/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/id | • {{#if: UbuntuHelp:StaticDnsWithDhcp|Bahasa Indonesia| [[::StaticDnsWithDhcp/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/it | • {{#if: UbuntuHelp:StaticDnsWithDhcp|italiano| [[::StaticDnsWithDhcp/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/ja | • {{#if: UbuntuHelp:StaticDnsWithDhcp|日本語| [[::StaticDnsWithDhcp/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/ko | • {{#if: UbuntuHelp:StaticDnsWithDhcp|한국어| [[::StaticDnsWithDhcp/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/ksh | • {{#if: UbuntuHelp:StaticDnsWithDhcp|Ripoarisch| [[::StaticDnsWithDhcp/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/mr | • {{#if: UbuntuHelp:StaticDnsWithDhcp|मराठी| [[::StaticDnsWithDhcp/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/ms | • {{#if: UbuntuHelp:StaticDnsWithDhcp|Bahasa Melayu| [[::StaticDnsWithDhcp/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/nl | • {{#if: UbuntuHelp:StaticDnsWithDhcp|Nederlands| [[::StaticDnsWithDhcp/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/no | • {{#if: UbuntuHelp:StaticDnsWithDhcp|norsk| [[::StaticDnsWithDhcp/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/oc | • {{#if: UbuntuHelp:StaticDnsWithDhcp|occitan| [[::StaticDnsWithDhcp/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/pl | • {{#if: UbuntuHelp:StaticDnsWithDhcp|polski| [[::StaticDnsWithDhcp/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/pt | • {{#if: UbuntuHelp:StaticDnsWithDhcp|português| [[::StaticDnsWithDhcp/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/ro | • {{#if: UbuntuHelp:StaticDnsWithDhcp|română| [[::StaticDnsWithDhcp/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/ru | • {{#if: UbuntuHelp:StaticDnsWithDhcp|русский| [[::StaticDnsWithDhcp/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/si | • {{#if: UbuntuHelp:StaticDnsWithDhcp|සිංහල| [[::StaticDnsWithDhcp/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/sq | • {{#if: UbuntuHelp:StaticDnsWithDhcp|shqip| [[::StaticDnsWithDhcp/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/sr | • {{#if: UbuntuHelp:StaticDnsWithDhcp|српски / srpski| [[::StaticDnsWithDhcp/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/sv | • {{#if: UbuntuHelp:StaticDnsWithDhcp|svenska| [[::StaticDnsWithDhcp/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/th | • {{#if: UbuntuHelp:StaticDnsWithDhcp|ไทย| [[::StaticDnsWithDhcp/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/tr | • {{#if: UbuntuHelp:StaticDnsWithDhcp|Türkçe| [[::StaticDnsWithDhcp/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/vi | • {{#if: UbuntuHelp:StaticDnsWithDhcp|Tiếng Việt| [[::StaticDnsWithDhcp/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/yue | • {{#if: UbuntuHelp:StaticDnsWithDhcp|粵語| [[::StaticDnsWithDhcp/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/zh | • {{#if: UbuntuHelp:StaticDnsWithDhcp|中文| [[::StaticDnsWithDhcp/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/zh-hans | • {{#if: UbuntuHelp:StaticDnsWithDhcp|中文(简体)| [[::StaticDnsWithDhcp/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:StaticDnsWithDhcp | UbuntuHelp:StaticDnsWithDhcp | {{#if: | :}}StaticDnsWithDhcp}}/zh-hant | • {{#if: UbuntuHelp:StaticDnsWithDhcp|中文(繁體)| [[::StaticDnsWithDhcp/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:StaticDnsWithDhcp|:StaticDnsWithDhcp|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :StaticDnsWithDhcp/zh | | {{#ifexist: StaticDnsWithDhcp/zh | | {{#ifeq: {{#titleparts:StaticDnsWithDhcp|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:StaticDnsWithDhcp|1|-1|}} | zh | | }}
Parent: Internet and Networking
The default setup of Ubuntu does not make it easy to use static DNS servers while using DHCP.
If you use the standard ubuntu way of networking (ifupdown), you can edit /etc/network/interfaces
In that file you find the entry for your interface. If your interface is eth0, then look for the following lines:
auto eth0 iface eth0 inet dhcp
Add one line, so it looks like:
auto eth0 iface eth0 inet dhcp dns-nameservers ip.address.of.nameserver
Run
sudo invoke-rc.d networking restart
To make the changes effective
If you do not use ifupdown, you need to edit /etc/dhcp3/dhclient.conf
Find the lines
#prepend domain-name-servers 127.0.0.1; request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, host-name, netbios-name-servers, netbios-scope;
And change them to
prepend domain-name-servers 1.2.3.4, 1.2.3.5; request subnet-mask, broadcast-address, time-offset, routers, domain-name, host-name, netbios-name-servers, netbios-scope;
Replace 1.2.3.4 and 1.2.3.5 with the addresses of your DNS servers.
Run
sudo invoke-rc.d networking restart
To make the changes effective: