Различия
Здесь показаны различия между двумя версиями данной страницы.
Следующая версия | Предыдущая версия | ||
wiki:руководство_по_ubuntu_server:сеть:сетевые_настройки [2012/05/17 21:13] создано |
wiki:руководство_по_ubuntu_server:сеть:сетевые_настройки [2012/05/18 15:45] (текущий) |
||
---|---|---|---|
Строка 1: | Строка 1: | ||
<style float-left> | <style float-left> | ||
- | [[wiki:руководство_по_ubuntu_server|Руководство по Ubuntu Server]]</style> | + | [[wiki:руководство_по_ubuntu_server|Руководство по Ubuntu Server]] >> |
+ | [[wiki:руководство_по_ubuntu_server:сеть|Сеть]]</style> | ||
<style float-right> | <style float-right> | ||
- | [[wiki:руководство_по_ubuntu_server:управление_пакетами:references|<-назад]] | [[wiki:руководство_по_ubuntu_server:множественное_связывание_устройств|далее->]]</style> | + | [[wiki:руководство_по_ubuntu_server:сеть|<-назад]] | |
+ | [[wiki:руководство_по_ubuntu_server:сеть:tcp_ip|далее->]]</style> | ||
=====Сетевые настройки===== | =====Сетевые настройки===== | ||
Строка 172: | Строка 174: | ||
<code>/etc/resolv.conf -> ../run/resolvconf/resolv.conf</code> | <code>/etc/resolv.conf -> ../run/resolvconf/resolv.conf</code> | ||
- | To configure the resolver, add the IP addresses of the nameservers that are appropriate for your network in the file /etc/network/interfaces. You can also add an optional DNS suffix search-lists to match your network domain names. For each other valid resolv.conf configuration option, you can include, in the stanza, one line beginning with that option name with a dns- prefix. The resulting file might look like the following: | + | Для настройки разрешений добавьте IP адреса серверов имен, соответствующие вашей сети, в файл /etc/network/interfaces. Вы также можете добавить необязательный список подбора DNS суффиксов для получения доменных имен. Для каждой другой разрешенной опции настройки resolv.conf вы можете добавить внутри абзаца по отдельной строке с этой опцией с префиксом имени dns-. Результирующий файл может выглядеть так: |
- | + | <code>iface eth0 inet static | |
- | iface eth0 inet static | + | |
address 192.168.3.3 | address 192.168.3.3 | ||
netmask 255.255.255.0 | netmask 255.255.255.0 | ||
gateway 192.168.3.1 | gateway 192.168.3.1 | ||
dns-search example.com | dns-search example.com | ||
- | dns-nameservers 192.168.3.45 192.168.8.10 | + | dns-nameservers 192.168.3.45 192.168.8.10</code> |
- | The search option can also be used with multiple domain names so that DNS queries will be appended in the order in which they are entered. For example, your network may have multiple sub-domains to search; a parent domain of example.com, and two sub-domains, sales.example.com and dev.example.com. | + | Опции поиска также могут использоваться разные доменные имена, таким образом DNS запросы будут дополняться ими в том порядке, как они вводились. Например, ваша сеть может иметь несколько поддоменов для поиска; родительский домен example.com и два поддомена sales.example.com и dev.example.com. |
- | If you have multiple domains you wish to search, your configuration might look like the following: | + | Если у вас несколько доменов, в которых вы собираетесь искать, ваша конфигурация может выглядеть так: |
- | + | <code>iface eth0 inet static | |
- | iface eth0 inet static | + | |
address 192.168.3.3 | address 192.168.3.3 | ||
netmask 255.255.255.0 | netmask 255.255.255.0 | ||
gateway 192.168.3.1 | gateway 192.168.3.1 | ||
dns-search example.com sales.example.com dev.example.com | dns-search example.com sales.example.com dev.example.com | ||
- | dns-nameservers 192.168.3.45 192.168.8.10 | + | dns-nameservers 192.168.3.45 192.168.8.10</code> |
- | If you try to ping a host with the name of server1, your system will automatically query DNS for its Fully Qualified Domain Name (FQDN) in the following order: | + | Если вы попытаетесь проверить хост с именем server1, ваша система автоматически запросит DNS по их полным доменным именам (FQDN) в следующем порядке: |
- | server1.example.com | + | -- server1**.example.com** |
+ | -- server1**.sales.example.com** | ||
+ | -- server1**.dev.example.com** | ||
- | server1.sales.example.com | + | Если совпадений не будет, DNS сервер предоставит результат notfound и запрос DNS потерпит неудачу. |
- | server1.dev.example.com | + | ===Статические имена хостов=== |
- | If no matches are found, the DNS server will provide a result of notfound and the DNS query will fail. | + | Статические имена хостов - это локально определенные соотношения "имя хоста-IP", находящиеся в файле /etc/hosts. Значения, определенные в файле hosts, по умолчанию превалируют над DNS. Это означает, что если система пытается разрешить имя и находит его в /etc/hosts, она не будет пытаться смотреть записи в DNS. В некоторых конфигурациях, особенно когда доступ в интернет не требуется, сервера, соединенные с ограниченным количеством ресурсов, могут просто использовать статический список имен вместо DNS. |
- | Static Hostnames | + | |
- | Static hostnames are locally defined hostname-to-IP mappings located in the file /etc/hosts. Entries in the hosts file will have precedence over DNS by default. This means that if your system tries to resolve a hostname and it matches an entry in /etc/hosts, it will not attempt to look up the record in DNS. In some configurations, especially when Internet access is not required, servers that communicate with a limited number of resources can be conveniently set to use static hostnames instead of DNS. | + | Далее приведен пример файла hosts, где ряд локальных серверов определены обычными именами хостов, алиасами и их эквивалентами полных имен (FQDN). |
- | The following is an example of a hosts file where a number of local servers have been identified by simple hostnames, aliases and their equivalent Fully Qualified Domain Names (FQDN's). | + | <code>127.0.0.1 localhost |
- | + | ||
- | 127.0.0.1 localhost | + | |
127.0.1.1 ubuntu-server | 127.0.1.1 ubuntu-server | ||
10.0.0.11 server1 vpn server1.example.com | 10.0.0.11 server1 vpn server1.example.com | ||
10.0.0.12 server2 mail server2.example.com | 10.0.0.12 server2 mail server2.example.com | ||
10.0.0.13 server3 www server3.example.com | 10.0.0.13 server3 www server3.example.com | ||
- | 10.0.0.14 server4 file server4.example.com | + | 10.0.0.14 server4 file server4.example.com</code> |
- | In the above example, notice that each of the servers have been given aliases in addition to their proper names and FQDN's. Server1 has been mapped to the name vpn, server2 is referred to as mail, server3 as www, and server4 as file. | + | <note>В примере выше обратите внимание, что каждый сервер имеет алиас в добавок к их правильным коротким и полным именам. server1 соотносится с именем vpn, server2 определен как mail, server3 как www и server4 как file.</note> |
- | Name Service Switch Configuration | + | |
- | The order in which your system selects a method of resolving hostnames to IP addresses is controlled by the Name Service Switch (NSS) configuration file /etc/nsswitch.conf. As mentioned in the previous section, typically static hostnames defined in the systems /etc/hosts file have precedence over names resolved from DNS. The following is an example of the line responsible for this order of hostname lookups in the file /etc/nsswitch.conf. | + | ===Настройка переключения сервиса имен=== |
- | hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 | + | Последовательность, в которой ваша система выбирает метод разрешения имен по IP адресам управляется настроечным файлом переключателя сервиса имен (NSS) /etc/nsswitch.conf. Как отмечено в предыдущей секции, обычно статические имена хостов, определенные в системном файле /etc/hosts, имеют приоритет перед разрешением имен через DNS. Далее пример строки, отвечающей за этот порядок перебора имен хостов в файле /etc/nsswitch.conf. |
+ | <code>hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4</code> | ||
- | files first tries to resolve static hostnames located in /etc/hosts. | + | -- **files** сперва пытается разрешить статическое имя хоста в /etc/hosts. |
+ | -- **mdns4_minimal** пытается разрешить имя с использованием параллельного (multicast) DNS. | ||
+ | -- **[NOTFOUND=return]** означает, что любой ответ notfound, предшествующий процессу mdns4_minimal, должен считаться значимым (авторитетным) и что система не будет пытаться продолжать искать ответ. | ||
+ | -- **dns** представляет собой наследуемый последовательный (legacy unicast) DNS запрос. | ||
+ | -- **mdns4** представляет параллельный (multicast) DNS запрос. | ||
- | mdns4_minimal attempts to resolve the name using Multicast DNS. | + | Для изменения последовательности вышеупомянутых методов разрешения имен вы можете просто заменить строку hosts: на значение по вашему выбору. Например, если вы предпочитаете использовать последовательный DNS до параллельного DNS, вы можете изменить строку в /etc/nsswitch.conf как показано ниже: |
+ | <code>hosts: files dns [NOTFOUND=return] mdns4_minimal mdns4</code> | ||
- | [NOTFOUND=return] means that any response of notfound by the preceding mdns4_minimal process should be treated as authoritative and that the system should not try to continue hunting for an answer. | + | ====Строительство мостов :)==== |
- | dns represents a legacy unicast DNS query. | + | Соединение нескольких интерфейсов - наиболее продвинутая настройка, но очень полезная во множестве сценариев. Один вариант - установка взаимодействия между несколькими сетевыми интерфейсами и затем использование защитного экрана (firewall) для фильтрования трафика между двумя сегментами сети. Другой сценарий - использование связывания на системе с одним интерфейсом для разрешения виртуальным машинам иметь прямой доступ во внешнюю сеть. Следующий пример раскрывает последний сценарий. |
- | mdns4 represents a Multicast DNS query. | + | Перед настойкой взаимодействия вам потребуется установить пакет bridge-utils. Для установки пакета введите в терминале: |
+ | <code>sudo apt-get install bridge-utils</code> | ||
- | To modify the order of the above mentioned name resolution methods, you can simply change the hosts: string to the value of your choosing. For example, if you prefer to use legacy Unicast DNS versus Multicast DNS, you can change the string in /etc/nsswitch.conf as shown below. | + | Далее настройте взаимодействие, отредактировав /etc/network/interfaces: |
- | + | <code>auto lo | |
- | hosts: files dns [NOTFOUND=return] mdns4_minimal mdns4 | + | |
- | + | ||
- | ====Bridging==== | + | |
- | + | ||
- | Bridging multiple interfaces is a more advanced configuration, but is very useful in multiple scenarios. One scenario is setting up a bridge with multiple network interfaces, then using a firewall to filter traffic between two network segments. Another scenario is using bridge on a system with one interface to allow virtual machines direct access to the outside network. The following example covers the latter scenario. | + | |
- | + | ||
- | Before configuring a bridge you will need to install the bridge-utils package. To install the package, in a terminal enter: | + | |
- | + | ||
- | sudo apt-get install bridge-utils | + | |
- | + | ||
- | Next, configure the bridge by editing /etc/network/interfaces: | + | |
- | + | ||
- | auto lo | + | |
iface lo inet loopback | iface lo inet loopback | ||
Строка 259: | Строка 251: | ||
bridge_hello 2 | bridge_hello 2 | ||
bridge_maxage 12 | bridge_maxage 12 | ||
- | bridge_stp off | + | bridge_stp off</code> |
- | + | <note>Введите значения соответствующие вашим физическому интерфейсу и сети.</note> | |
- | Enter the appropriate values for your physical interface and network. | + | |
- | + | ||
- | Now restart networking to enable the bridge interface: | + | |
- | + | ||
- | sudo /etc/init.d/networking restart | + | |
- | + | ||
- | The new bridge interface should now be up and running. The brctl provides useful information about the state of the bridge, controls which interfaces are part of the bridge, etc. See man brctl for more information. | + | |
- | + | ||
- | ====Resources==== | + | |
- | + | ||
- | The Ubuntu Wiki Network page has links to articles covering more advanced network configuration. | + | |
- | + | ||
- | The resolvconf man page has more information on resolvconf. | + | |
- | The interfaces man page has details on more options for /etc/network/interfaces. | + | Теперь перезапустите сеть для разрешения взаимодействия интерфейсов: |
+ | <code>sudo /etc/init.d/networking restart</code> | ||
- | The dhclient man page has details on more options for configuring DHCP client settings. | + | Теперь новый мост между интерфейсами поднят и работает. Утилита brctl предоставит полезную информацию о статусе моста, определяет какие интерфейсы участвуют во взаимодействии и т.д. Смотрите man brctl для дополнительной информации. |
- | For more information on DNS client configuration see the resolver man page. Also, Chapter 6 of O'Reilly's Linux Network Administrator's Guide is a good source of resolver and name service configuration information. | + | ====Ссылки==== |
- | For more information on bridging see the brctl man page and the Linux Foundation's Net:Bridge page. | + | -- Страница [[https://help.ubuntu.com/community/Network|Ubuntu Wiki Network]] содержит ссылки на заметки по более продвинутым настройкам сети. |
+ | -- Страница [[http://manpages.ubuntu.com/manpages/man8/resolvconf.8.html|resolvconf man]] содержит больше информации по resolvconf. | ||
+ | -- Страница [[http://manpages.ubuntu.com/manpages/man5/interfaces.5.html|interfaces man]] содержит детали по дополнительным опциям для /etc/network/interfaces. | ||
+ | -- Страница [[http://manpages.ubuntu.com/manpages/man8/dhclient.8.html|dhclient man]] содержит детали по большему количеству опций для настройки DHCP клиента. | ||
+ | -- Для дополнительной информации по настройке DNS клиента смотрите страницу [[http://manpages.ubuntu.com/manpages/man5/resolver.5.html|resolver man]]. Также 6 глава руководства O'Reilly [[http://oreilly.com/catalog/linag2/book/ch06.html|Администрирования сетей Linux]] является хорошим источником по разрешению имен и настройке сервиса имен. | ||
+ | -- Для дополнительной информации по сетевому связыванию смотрите страницу [[http://manpages.ubuntu.com/manpages/man8/brctl.8.html|brctl man]] и страницу [[http://www.linuxfoundation.org/en/Net:Bridge|Net:Bridge]] от Linux Foundation. | ||
---- | ---- | ||
<style float-right> | <style float-right> | ||
- | [[wiki:руководство_по_ubuntu_server:управление_пакетами:references|<-назад]] | [[wiki:руководство_по_ubuntu_server:множественное_связывание_устройств|далее->]]</style> | + | [[wiki:руководство_по_ubuntu_server:сеть|<-назад]] | |
+ | [[wiki:руководство_по_ubuntu_server:сеть:tcp_ip|далее->]]</style> | ||