How to setup a static IP address on Manjaro Linux

If you’re running Manjaro Linux and need to setup a static IP address, this is the guide for you. In this tutorial, we’ll be showing you how to configure a static IP address on your system, both from a GUI and command line interface.

In this tutorial you will learn:

  • How to setup a static IP via GUI (XFCE)
  • How to setup a static IP via command line

Setting a static IP in Manjaro Linux

Setting a static IP in Manjaro Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Manjaro Linux
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Static IP using a GUI tool



The Manjaro download page lists quite a few GUI options, and the distro supports many more. Depending on which GUI you’re using (XFCE, KDE, GNOME, etc), the instructions for setting a static IP via GUI are going to vary a little. Since Manjaro’s first recommendation is XFCE, we’ll cover the instructions for setting up a static IP in XFCE on Manjaro. The instructions for other desktop environments should be similar.

  1. First, right click on the network icon in the right side of the taskbar.
    Right click the network icon in taskbar to access configuration menus

    Right click the network icon in taskbar to access configuration menus
  2. Then, click on ‘Edit Connections’.
    Click on Edit Connections

    Click on Edit Connections


  3. In the menu that opens up, you may see just one connection or multiple if your system has more than one network interface. On the interface you’d like to configure a static IP address for, left click to highlight it and then click the cogwheel to edit.
    Highlight your connection and click the cogwheel

    Highlight your connection and click the cogwheel
  4. A new menu will open up with a few different tabs to choose from. Click on either the ‘IPv4 Settings’ tab or ‘IPv6 Settings’ tab, depending on the type of static IP address you’d like to configure.
    Click on IPv4 Settings or IPv6 Settings

    Click on IPv4 Settings or IPv6 Settings
  5. By default, Manjaro will be configured to obtain an IP address through DHCP. We’ll need to change this option by selecting ‘Manual’ under the ‘Method’ configuration.
    Select the manual method to configure a static IP

    Select the manual method to configure a static IP


  6. Now click on ‘Add’ to add a new static IP address to the interface. This will allow you to type a static IP, subnet mask, and default gateway.
    Click Add and then fill out your IP address information

    Click Add and then fill out your IP address information
  7. Once you’re happy with the changes, just click ‘Save’ and close the network interfaces menu. For the changes to take effect, you may need to disconnect from your current network and reconnect. Left click on the network icon in the taskbar and click disconnect.
    Disconnect from the network you just configured

    Disconnect from the network you just configured
  8. Finally, to use your newly configured static IP address, reconnect to the network by enabling your network interface once again. Left click the network icon and select the name of your network interface.
    Reconnect to the network for the new changes to take effect

    Reconnect to the network for the new changes to take effect


That’s all there is to it. If you’d like to verify the changes you’ve made, you can right click on the network icon in your taskbar and select ‘Connection information’.

The Connection Information screen shows our newly configured static IP address

The Connection Information screen shows our newly configured static IP address

Static IP using command line

If you don’t shy away from cracking open a terminal, setting up a static IP from the command line is even more of a breeze and can be done in just a few steps.

  1. First, open a terminal and type the following command to see how your network interface is currently configured. As you can see in the screenshot below, the name of our network interface is enp0s3. We’ll need to know that for the next step, and yours may be different, so be sure to get the right name for yours.
    $ ip a
    
    Check your current IP address and the name of the network interface

    Check your current IP address and the name of the network interface
  2. Since we’re configuring a static IP, we need to temporarily disable Manjaro’s NetworkManager service in systemd so the changes will take effect when we’re done. Type this command:


    $ sudo systemctl disable --now NetworkManager.service
    
  3. Now, we need to create a new file (as root) that contains our network configuration for the enp0s3 interface. Again, the name of your network interface may be different, so be sure to check. You can use nano or whichever text editor you prefer to create the following file (just be sure to put the correct interface name in your file name):
    $ sudo nano /etc/systemd/network/enp0s3.network
    
  4. Paste the following template into your text file, making changes as needed. This particular example will configure the interface to use IP address 192.168.1.10 with subnet mask 255.255.255.0 (or /24 in slash notation), and default gateway 192.168.1.1. We’ve also configured it to use Google’s DNS servers. You can just remove these values and put your own.
    [Match]
    Name=enp0s3
    
    [Network]
    Address=192.168.1.10/24
    Gateway=192.168.1.1
    DNS=8.8.8.8
    DNS=8.8.4.4
  5. Exit the file and be sure to save your changes when doing so. In order for these new changes to take effect, just start the NetworkManager service back up with this command:
    $ sudo systemctl enable --now systemd-networkd.service
    


If you receive an error when restarting the network service, be sure to check your configuration file for typos. Otherwise, the static IP address should now be configured. You can check by typing the following command:

$ ip a
The static IP address has been configured successfully

The static IP address has been configured successfully

Conclusion

In this guide, we saw how to setup a static IP address in Manjaro Linux. The process is pretty painless whether you choose to do it from a GUI or the command line interface. We used the XFCE desktop environment in our screenshots, but you should find the process very similar even if you’re using GNOME, KDE, or some other desktop interface on your Manjaro installation.



Comments and Discussions
Linux Forum