Manjaro Difference between revisions of "Networking"

Difference between revisions of "Networking"

From Manjaro
imported>Dalto
m (Dalto moved page Set DNS or Nameservers to Networking: Generalize)
imported>Dalto
(Generalize and update)
Line 1: Line 1:
= What's this all about? =
__TOC__


Generally, if you are using a different Domain Name Server (DNS) than that provided by your ISP, or you are using the likes of Google's nameservers from your Google account you will find that your DNS or other non-standard nameserver addresses will, after you have set them up, get lost on reboot as '''/etc/resolv.conf''' can be overwritten by NetworkManager or during the boot process. Here we will look at 2 techniques to preserve your settings; resolvconf.conf from openresolv, resolv.conf.head/tail using DHCPD.


= openresolv and /etc/resolvconf.conf =
=Overview=
 
Networking on Manjaro generally works out of the box without and special user intervention.  This article presents some specialized circumstances which some users may encounter and provides advice on how to overcome them.


The resolvconf.conf file is a shell script that is sourced by resolvconf, meaning that resolvconf.conf must contain valid shell commands. Take a look at its [https://jlk.fjfi.cvut.cz/arch/manpages/man/resolvconf.conf.5 man page] for more details and commands.
The file is located at /etc/resolvconf.conf and will require root privelege to edit.
After making any changes simply update and apply your settings with the following command


sudo resolvconf -u


(note - changes will take effect immediately)
=Manually Setting DNS Servers=


== Example ==
Usually, your DNS servers will be provided by your ISP automatically through DHCP.  However, sometimes it nesecary to use different DNS servers than the ones provided by your ISP.  In this situation you may find that your DNS or other non-standard nameserver addresses will get reset on reboot as {{ic|/etc/resolv.conf}} can be overwritten by NetworkManager or during the boot process. Here we will look at some techniques to preserve your settings.


For this example we will prepend OpenDNS nameservers to the top of our resolvconf file whenever called.
We can achieve this by adding the following lines to the bottom of resolvconf.conf and running the update command.


# OpenDNS servers
==NetworkManager==
  name_servers="208.67.222.222 208.67.220.220"
If you are using NetworkManager, this is one solution to the problem. The NetworkManager's config drop folder is placed in <code>/etc/NetworkManager/confg.d</code>. In this folder you can place snippets which controls how NetworkManager works. The files should be named with a number and a description of its purpose and always end with {{ic|.conf}}. The files are then applied in numerical order from the lowest to the highest. A configuration in a file with a higher number will override what could have been configured in a lower numbered file.


= DHCPD and resolv.conf.head/tail =
===Use resolvconf===
To have the resolvconf script handle the resolv.conf file for NetworkManager.  
Create a configuration file in NetworkManager's config drop folder


We can input our settings to the '''/etc/resolv.conf.head''' file. If this file does not exist then create it. The contents of '''/etc/resolv.conf.head''' get sent to the top of '''/etc/resolv.conf''' during the boot process.
/etc/NetworkManager/conf.d/20-rc-manager.conf


== Examples ==
Save the file with this content


To use the Google nameservers associated with your Google account, you would add the following to '''/etc/resolv.conf.head'''
[main]
rc-manager=resolvconf


# Google nameservers
To effectively make DNS handling a manual task create a file named
nameserver 8.8.8.8
nameserver 8.8.4.4


You would add any DNS entries that you had the need to. So those that want to use OpenDNS for example you would add the following:
/etc/NetworkManager/conf.d/99-dont-touch-my-dns.conf


# OpenDNS servers
Save the file with this content
nameserver 208.67.222.222
nameserver 208.67.220.220


The Swiss Privacy Foundation's nameserver addresses:
[main]
dns=none


# Swiss Privacy Foundation's servers
nameserver 77.109.138.45
nameserver 77.109.139.29


== /etc/resolv.conf.tail (for when pacman times out) ==
==/etc/resolvconf.conf==


You can create the '''/etc/resolv.conf.tail''' file & add the following to it, (I'm using the OpenDNS address, you could use any other DNS or nameserver that you have access to):
The resolvconf.conf file is a shell script that is sourced by resolvconf, meaning that resolvconf.conf must contain valid shell commands. Take a look at its [https://jlk.fjfi.cvut.cz/arch/manpages/man/resolvconf.conf.5 man page] for more details and commands. The file is located at {{ic|/etc/resolvconf.conf}} and will require root privelege to edit. For more information on how to edit a configuration file owned by root, please review [[Viewing_and_editing_configuration_files|this article]].


options timeout:1
# OpenDNS servers, used as alternative when default DNS is too slow:
nameserver 208.67.222.222
nameserver 208.67.220.220


After you have saved the edited file you will need to restart your network service. The one reliable way that works for everyone is to warm boot your machine.
As an example, we will prepend OpenDNS nameservers to the top of our resolvconf file whenever called. We can achieve this by adding the following lines to the bottom of resolvconf.conf.
# OpenDNS servers
name_servers="208.67.222.222 208.67.220.220"


= NetworkManager =
If you when you fiddle with your DNS finds that your ''resolv.conf'' is overwritten by NetworkManager there is a few tricks available.
The NetworkManager's config drop folder is placed in <code>/etc/NetworkManager/confg.d</code>. In this folder you can place snippets which controls how NetworkManager works. The files should be named with a number and a description of its purpose and always end with ''.conf''. The files are then applied in numerical order from the lowest to the highest. A configuration in a file with a higher number will override what could have been configured in a lower numbered file.


== Use resolvconf ==
After making any changes simply update and apply your settings with the following command
To have the resolvconf script handle the resolv.conf file for NetworkManager.
sudo resolvconf -u
Create a configuration file in NetworkManager's config drop folder


/etc/NetworkManager/conf.d/20-rc-manager.conf


Save the file with this content
==DHCPD and resolv.conf.head/tail==


[main]
{{note|Most Manjaro installs will not be using dhcpd by default}}
rc-manager=resolvconf


To effectively make DNS handling a manual task create a file named


/etc/NetworkManager/conf.d/99-dont-touch-my-dns.conf
An alternative solution if you are using dhcpd is to input our settings to the {{ic|/etc/resolv.conf.head}} file. If this file does not exist then create it. The contents of {{ic|/etc/resolv.conf.head}} get sent to the top of {{ic|/etc/resolv.conf}} during the boot process.


Save the file with this content


  [main]
Following our previous example, if we want to use the OpenDNS servers with this method, we could place the following in the file:
  dns=none
# OpenDNS servers
  nameserver 208.67.222.222
  nameserver 208.67.220.220


= Support =


Create a thread on the forum if you have any need for further information on this topic: [https://forum.manjaro.org Manjaro Forum]
=See Also=


= Further reading =
* [https://blogs.gnome.org/dcbw/2015/02/16/networkmanager-for-administrators-part-1/ NetworkManager for Administrators]
* [https://wiki.archlinux.org/index.php/NetworkManager#Configure_NetworkManager_resolv.conf_management_mode_to_use_resolvconf Using resolvconf with NetworkManager]


- [https://blogs.gnome.org/dcbw/2015/02/16/networkmanager-for-administrators-part-1/ NetworkManager for Administrators]
- [https://wiki.archlinux.org/index.php/NetworkManager#Configure_NetworkManager_resolv.conf_management_mode_to_use_resolvconf Using resolvconf with NetworkManager]


[[Category:Contents Page]]
[[Category:Contents Page]]

Revision as of 02:02, 27 May 2019


Overview

Networking on Manjaro generally works out of the box without and special user intervention. This article presents some specialized circumstances which some users may encounter and provides advice on how to overcome them.


Manually Setting DNS Servers

Usually, your DNS servers will be provided by your ISP automatically through DHCP. However, sometimes it nesecary to use different DNS servers than the ones provided by your ISP. In this situation you may find that your DNS or other non-standard nameserver addresses will get reset on reboot as /etc/resolv.conf can be overwritten by NetworkManager or during the boot process. Here we will look at some techniques to preserve your settings.


NetworkManager

If you are using NetworkManager, this is one solution to the problem. The NetworkManager's config drop folder is placed in /etc/NetworkManager/confg.d. In this folder you can place snippets which controls how NetworkManager works. The files should be named with a number and a description of its purpose and always end with .conf. The files are then applied in numerical order from the lowest to the highest. A configuration in a file with a higher number will override what could have been configured in a lower numbered file.

Use resolvconf

To have the resolvconf script handle the resolv.conf file for NetworkManager. Create a configuration file in NetworkManager's config drop folder

/etc/NetworkManager/conf.d/20-rc-manager.conf

Save the file with this content

[main]
rc-manager=resolvconf

To effectively make DNS handling a manual task create a file named

/etc/NetworkManager/conf.d/99-dont-touch-my-dns.conf

Save the file with this content

[main]
dns=none


/etc/resolvconf.conf

The resolvconf.conf file is a shell script that is sourced by resolvconf, meaning that resolvconf.conf must contain valid shell commands. Take a look at its man page for more details and commands. The file is located at /etc/resolvconf.conf and will require root privelege to edit. For more information on how to edit a configuration file owned by root, please review this article.


As an example, we will prepend OpenDNS nameservers to the top of our resolvconf file whenever called. We can achieve this by adding the following lines to the bottom of resolvconf.conf.

# OpenDNS servers
name_servers="208.67.222.222 208.67.220.220"


After making any changes simply update and apply your settings with the following command

sudo resolvconf -u


DHCPD and resolv.conf.head/tail

Note
Most Manjaro installs will not be using dhcpd by default


An alternative solution if you are using dhcpd is to input our settings to the /etc/resolv.conf.head file. If this file does not exist then create it. The contents of /etc/resolv.conf.head get sent to the top of /etc/resolv.conf during the boot process.


Following our previous example, if we want to use the OpenDNS servers with this method, we could place the following in the file:

# OpenDNS servers
nameserver 208.67.222.222
nameserver 208.67.220.220


See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.