Difference between revisions of "Networking"
Views
Actions
Namespaces
Variants
Tools
m (corrected two typos) |
m |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> | |||
__TOC__ | __TOC__ | ||
<translate> | |||
=Overview= <!--T:1--> | |||
<!--T:2--> | |||
Networking on Manjaro generally works out of the box without any special user intervention. This article presents some specialized circumstances which some users may encounter and provides advice on how to overcome them. | Networking on Manjaro generally works out of the box without any 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= | =Manually Setting DNS Servers= <!--T:3--> | ||
<!--T:4--> | |||
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. | 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. | ||
==NetworkManager== | ==NetworkManager== <!--T:5--> | ||
If you are using NetworkManager, this is one solution to the problem. The NetworkManager's config drop folder is placed in <code>/etc/NetworkManager/conf.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. | If you are using NetworkManager, this is one solution to the problem. The NetworkManager's config drop folder is placed in <code>/etc/NetworkManager/conf.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. | ||
===Use resolvconf=== | ===Use resolvconf=== <!--T:6--> | ||
To have the resolvconf script handle the resolv.conf file for NetworkManager. | To have the resolvconf script handle the resolv.conf file for NetworkManager. | ||
Create a configuration file in NetworkManager's config drop folder | Create a configuration file in NetworkManager's config drop folder | ||
/etc/NetworkManager/conf.d/20-rc-manager.conf | <!--T:7--> | ||
/etc/NetworkManager/conf.d/20-rc-manager.conf | |||
<!--T:8--> | |||
Save the file with this content | Save the file with this content | ||
[main] | <!--T:9--> | ||
[main] | |||
rc-manager=resolvconf | rc-manager=resolvconf | ||
<!--T:10--> | |||
To effectively make DNS handling a manual task create a file named | To effectively make DNS handling a manual task create a file named | ||
/etc/NetworkManager/conf.d/99-dont-touch-my-dns.conf | <!--T:11--> | ||
/etc/NetworkManager/conf.d/99-dont-touch-my-dns.conf | |||
<!--T:12--> | |||
Save the file with this content | Save the file with this content | ||
[main] | <!--T:13--> | ||
[main] | |||
dns=none | dns=none | ||
==/etc/resolvconf.conf== | ==/etc/resolvconf.conf== <!--T:14--> | ||
<!--T:15--> | |||
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]]. | 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]]. | ||
<!--T:16--> | |||
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. | 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 | # OpenDNS servers | ||
Line 47: | Line 59: | ||
<!--T:17--> | |||
After making any changes simply update and apply your settings with the following command | After making any changes simply update and apply your settings with the following command | ||
{{UserCmd|command=sudo resolvconf -u}} | |||
==dhcpcd and resolv.conf.head/tail== <!--T:18--> | |||
<!--T:19--> | |||
{{note|Most Manjaro installs will not be using dhcpd by default}} | {{note|Most Manjaro installs will not be using dhcpd by default}} | ||
<!--T:20--> | |||
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. | 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. | ||
<!--T:21--> | |||
Following our previous example, if we want to use the OpenDNS servers with this method, we could place the following in the file: | 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 | # OpenDNS servers | ||
Line 65: | Line 80: | ||
=Setting Static IP Address= | =Setting Static IP Address= <!--T:22--> | ||
==Using a GUI Tool== | ==Using a GUI Tool== <!--T:23--> | ||
<!--T:24--> | |||
Most editions of Manjaro come with some type a GUI tool or applet to manage NetworkManager. This is the easiest way to set a static IP. Simply go into the tool, usually in the system tray or menu, and input the required parameters for your network. | Most editions of Manjaro come with some type a GUI tool or applet to manage NetworkManager. This is the easiest way to set a static IP. Simply go into the tool, usually in the system tray or menu, and input the required parameters for your network. | ||
==Using systemd== | ==Using systemd== <!--T:25--> | ||
<!--T:26--> | |||
If you don't want to use NetworkManager the next easiest thing is to configure a static IP in systemd. | If you don't want to use NetworkManager the next easiest thing is to configure a static IP in systemd. | ||
<!--T:27--> | |||
First, make sure you aren't running NetworkManager | First, make sure you aren't running NetworkManager | ||
{{UserCmd|command=sudo systemctl disable --now NetworkManager.service}} | |||
<!--T:28--> | |||
Next you will need to find the name of your network device. To locate the name, use the command {{ic|ip a}} as seen here: | Next you will need to find the name of your network device. To locate the name, use the command {{ic|ip a}} as seen here: | ||
<pre>ip a | <pre>ip a | ||
Line 99: | Line 118: | ||
<!--T:29--> | |||
lo is the loopback device which can be ignored for the purposes of this article. The device we need here is identified above as {{ic|ens33}}. We will need this name in the next step. | lo is the loopback device which can be ignored for the purposes of this article. The device we need here is identified above as {{ic|ens33}}. We will need this name in the next step. | ||
<!--T:30--> | |||
Now create or edit a file to hold the network configuration at {{ic|/etc/systemd/network/devicename.network}}. Using the example above, the file would be called {{ic|/etc/systemd/network/ens33.network}}. This file will need to be created/edited as root. For more information on how to do that please review [[Viewing_and_editing_configuration_files|this article]]. An example of the contents of the file would look like this: | Now create or edit a file to hold the network configuration at {{ic|/etc/systemd/network/devicename.network}}. Using the example above, the file would be called {{ic|/etc/systemd/network/ens33.network}}. This file will need to be created/edited as root. For more information on how to do that please review [[Viewing_and_editing_configuration_files|this article]]. An example of the contents of the file would look like this: | ||
<pre>[Match] | <pre>[Match] | ||
Name=enp0s3 | Name=enp0s3 | ||
<!--T:31--> | |||
[Network] | [Network] | ||
Address=192.168.1.101/24 | Address=192.168.1.101/24 | ||
Line 114: | Line 136: | ||
<!--T:32--> | |||
All that remains is to start and enable the service using: | All that remains is to start and enable the service using: | ||
{{UserCmd|command=sudo systemctl enable --now systemd-networkd.service}} | |||
=Using dhcpcd Instead of NetworkManager= <!--T:33--> | |||
<!--T:34--> | |||
NetworkManager is the default solution for networking on most Manjaro editions. If you would prefer to use dhcpcd, that is also supported. | |||
NetworkManager is the default solution for networking on most | |||
<!--T:35--> | |||
First, ensure NetworkManager is disabled and not running | First, ensure NetworkManager is disabled and not running | ||
{{UserCmd|command=sudo systemctl disable --now NetworkManager.service}} | |||
<!--T:36--> | |||
Next, start and enable the dhcpcd service | Next, start and enable the dhcpcd service | ||
{{UserCmd|command=sudo systemctl start --now dhcpcd.service}} | |||
=See Also= <!--T:37--> | |||
<!--T:38--> | |||
* [https://blogs.gnome.org/dcbw/2015/02/16/networkmanager-for-administrators-part-1/ NetworkManager for Administrators] | * [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://wiki.archlinux.org/index.php/NetworkManager#Configure_NetworkManager_resolv.conf_management_mode_to_use_resolvconf Using resolvconf with NetworkManager] | ||
</translate> | |||
[[Category:Contents Page{{#translation:}}]] | |||
[[Category:Contents Page]] |
Latest revision as of 13:13, 8 December 2022
Overview
Networking on Manjaro generally works out of the box without any 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/conf.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
dhcpcd and resolv.conf.head/tail
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
Setting Static IP Address
Using a GUI Tool
Most editions of Manjaro come with some type a GUI tool or applet to manage NetworkManager. This is the easiest way to set a static IP. Simply go into the tool, usually in the system tray or menu, and input the required parameters for your network.
Using systemd
If you don't want to use NetworkManager the next easiest thing is to configure a static IP in systemd.
First, make sure you aren't running NetworkManager
Next you will need to find the name of your network device. To locate the name, use the command ip a
as seen here:
ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:02:55:c4 brd ff:ff:ff:ff:ff:ff inet 172.16.197.200/24 brd 172.16.197.255 scope global dynamic noprefixroute ens33 valid_lft 1725sec preferred_lft 1725sec inet6 fe80::7116:2769:dac:6314/64 scope link noprefixroute valid_lft forever preferred_lft forever
lo is the loopback device which can be ignored for the purposes of this article. The device we need here is identified above as ens33
. We will need this name in the next step.
Now create or edit a file to hold the network configuration at /etc/systemd/network/devicename.network
. Using the example above, the file would be called /etc/systemd/network/ens33.network
. This file will need to be created/edited as root. For more information on how to do that please review this article. An example of the contents of the file would look like this:
[Match] Name=enp0s3 [Network] Address=192.168.1.101/24 Gateway=192.168.1.1 DNS=208.67.222.222 DNS=208.67.220.220
All that remains is to start and enable the service using:
Using dhcpcd Instead of NetworkManager
NetworkManager is the default solution for networking on most Manjaro editions. If you would prefer to use dhcpcd, that is also supported.
First, ensure NetworkManager is disabled and not running
Next, start and enable the dhcpcd service