97 lines
2.2 KiB
Markdown
97 lines
2.2 KiB
Markdown
|
---
|
||
|
title: Static IP Configuration
|
||
|
tags: article guide software linux config
|
||
|
created: 2023-07-02T21:43:42Z
|
||
|
published: true
|
||
|
---
|
||
|
|
||
|
When installing Arch Linux on a VPS, you usually need to enable VNC and configure the networking by yourself before you can SSH into your machine.
|
||
|
This post serves as a guide to connect your server to the internet.
|
||
|
|
||
|
## Connectivity check
|
||
|
|
||
|
First of all, confirm that networking hasn't been set up yet:
|
||
|
|
||
|
```bash
|
||
|
ping google.com
|
||
|
```
|
||
|
|
||
|
There should be no response from the ping.
|
||
|
|
||
|
## Network interface
|
||
|
|
||
|
Now let's find out the name of the network interface:
|
||
|
|
||
|
```bash
|
||
|
networkctl list
|
||
|
```
|
||
|
|
||
|
You should see an ethernet device named like `eth0` or `ens0`.
|
||
|
The number at the end will differ.
|
||
|
This is the name of the network interface we'll configure in the following steps.
|
||
|
|
||
|
## Network manager
|
||
|
|
||
|
Arch Linux uses `systemd` which includes the `systemd-networkd` network manager by default.
|
||
|
To configure the network manager, edit the following file:
|
||
|
|
||
|
```bash
|
||
|
sudo vim /etc/systemd/network/20-wired.network
|
||
|
```
|
||
|
|
||
|
Start by specifying the network interface name:
|
||
|
|
||
|
```ini
|
||
|
[Match]
|
||
|
Name=ens0
|
||
|
```
|
||
|
|
||
|
Now you need to enter your IP address, subnet mask and the gateway.
|
||
|
Ideally your VPS provider should include that data in your dashboard.
|
||
|
You can enter the addresses in the network section:
|
||
|
|
||
|
```ini
|
||
|
[Network]
|
||
|
Address=2.1.1.2/32
|
||
|
Gateway=2.1.1.1
|
||
|
DNS=1.1.1.1
|
||
|
```
|
||
|
|
||
|
The DNS shown here is the Cloudflare DNS because it's reliable and easy to remember,
|
||
|
but feel free to use a different DNS.
|
||
|
|
||
|
If your VPS has an IPv6 address you can add more of the same lines to the network section:
|
||
|
|
||
|
```ini
|
||
|
Address=1111:1111:1111::2345
|
||
|
Gateway=1111:1111:1111::1111
|
||
|
DNS=2606:4700:4700::1111
|
||
|
```
|
||
|
|
||
|
## Service installation
|
||
|
|
||
|
Try to start the DNS resolver and the network manager:
|
||
|
|
||
|
```bash
|
||
|
sudo systemctl start systemd-resolved
|
||
|
sudo systemctl start systemd-networkd
|
||
|
```
|
||
|
|
||
|
Check if we're online on both IPv4 and IPv6:
|
||
|
|
||
|
```bash
|
||
|
ping -4 google.com
|
||
|
ping -6 google.com
|
||
|
```
|
||
|
|
||
|
If everything went smooth, make the DNS resolver and the network manager start automatically on boot:
|
||
|
|
||
|
```bash
|
||
|
sudo systemctl enable systemd-resolved
|
||
|
sudo systemctl enable systemd-networkd
|
||
|
```
|
||
|
|
||
|
## DNS records
|
||
|
|
||
|
To finalize the setup, add an `A` record for IPv4 and an `AAAA` record for IPv6 to your DNS and your server should be fully configured.
|