Translation notice
Parts of this article were translated with assistance from DeepSeek . The translation may contain inaccuracies, and some terms or cultural references may be difficult to understand because of differences in language and cultural context. For precise wording, please read the original version. If you have questions about the cultural context or meaning, please contact me through the sidebar; I will be happy to help clarify them.
Many beginners encounter this issue when using a VPS: the provider’s control panel assigns an IPv4 address and a full /64 IPv6 range, but the system only has IPv4 or IPv6, or the panel shows “No IP”. Below, I’ll share step by step the process of getting a Debian 12 VPS from “no network info” to successfully enabling IPv4 + IPv6, hoping to provide some reference for newcomers.
Prerequisites: Obtain the Information from Your Provider
Before starting, you need to check the network information assigned to you from the provider’s control panel:
- IPv4 address and subnet mask (e.g.,
xxx.xxx.xxx.xxx/24), as well as the corresponding default gateway. - IPv6 range, typically a
/64, such as2a00:abcd:1234:5678::/64. Please note that this is an entire subnet, not a directly usable address.
Our goal is to choose any address from this IPv6 range (e.g., 2a00:abcd:1234:5678::1/64) and assign it to the VPS. Do not use the /64 range itself as an address—this is a common mistake for beginners.
Step 1: Connect to the VPS and Identify the Network Interface
Log into the VPS via SSH or similar tools. First, identify the server’s network interface name:
ip -o link
The output looks like:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether aa:bb:cc:dd:ee:ff brd ff:ff:ff:ff:ff:ff
Here, eth0 is the network interface name. If you see enp1s0, ens3, or another name, replace accordingly in the following configuration.
Step 2: View and Back Up the Original netplan Configuration
Debian 12 uses netplan as the network configuration tool, and the default configuration file is usually located at /etc/netplan/50-cloud-init.yaml. First, view its contents:
cat /etc/netplan/50-cloud-init.yaml
If the file contains something like
network:
ethernets:
eth0:
dhcp4: true
version: 2
it means the system obtains an IPv4 address automatically via DHCP. This is not suitable for a VPS that needs a static IP. You can back up the original file using the cp command:
sudo cp /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.bak
Step 3: Disable cloud-init’s Network Configuration
Many cloud images automatically generate netplan configurations via cloud-init. If not disabled, it may overwrite your custom configuration after a reboot. You can create a configuration file under /etc/cloud/cloud.cfg.d/ to disable network management:
sudo mkdir -p /etc/cloud/cloud.cfg.d
sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg > /dev/null <<'EOF'
network: {config: disabled}
EOF
This file tells cloud-init to stop automatically generating network configurations.
Step 4: Write a Unified IPv4 + IPv6 Configuration
Delete the previously created /etc/netplan/90-ipv6.yaml (if any) for IPv6:
sudo rm -f /etc/netplan/90-ipv6.yaml
Then create or overwrite /etc/netplan/50-cloud-init.yaml, placing both IPv4 and IPv6 under the same interface. In this example, we assume your IPv4 address is 192.0.2.10/24, gateway is 192.0.2.1, and the chosen IPv6 is 2001:db8:abcd:1234::1/64 with gateway fe80::1.
sudo tee /etc/netplan/50-cloud-init.yaml > /dev/null <<'EOF'
network:
version: 2
ethernets:
eth0:
match:
macaddress: aa:bb:cc:dd:ee:ff
set-name: eth0
addresses:
- 192.0.2.10/24
- 2001:db8:abcd:1234::1/64
nameservers:
addresses:
- 1.1.1.1
- 8.8.8.8
- 2606:4700:4700::1111
- 2001:4860:4860::8888
routes:
- to: default
via: 192.0.2.1
- to: default
via: fe80::1
on-link: true
EOF
Some notes:
- The
match.macaddresscan use the interface’s MAC address, or you can omit it and just keepset-name: eth0. addressesincludes both the IPv4 and IPv6 lines.nameservers.addressessets DNS. You can list both IPv4 and IPv6 DNS servers.- The IPv6 default gateway
fe80::1is a link-local address, so you need to addon-link: truefor it to work.
The process of changing from DHCP to a static configuration is similar, and this is often mentioned in many online tutorials.
Step 5: Fix File Permissions and Apply the Configuration
Netplan requires strict file permissions. Run the following command to fix them:
sudo chmod 600 /etc/netplan/*.yaml
Then generate and apply the configuration:
sudo netplan generate
sudo netplan apply
When running netplan apply, you might see something like
Cannot call openvswitch: ovsdb-server.service is not running.
This is because the system has Open vSwitch related packages installed, but the service is not running. For a normal VPS, you can ignore this warning—it won’t affect the IP configuration.
Step 6: Verify Addresses and Routes
After configuration, use the following commands to confirm that IPv4 and IPv6 are loaded:
ip addr show eth0
ip route
ip -6 route
You should see that both IPv4 and IPv6 addresses are assigned, along with default routes. For example:
inet 192.0.2.10/24
inet6 2001:db8:abcd:1234::1/64
...
default via 192.0.2.1 dev eth0
...
default via fe80::1 dev eth0 onlink
Step 7: Fix DNS Resolution Issues
Sometimes after configuring IP addresses, ping works but domain name resolution fails, for example:
curl -4 example.com
curl: (6) Could not resolve host: example.com
This could be because /etc/resolv.conf is missing or points to a non-existent file. You can fix it manually:
sudo rm -f /etc/resolv.conf
sudo tee /etc/resolv.conf > /dev/null <<'EOF'
nameserver 1.1.1.1
nameserver 8.8.8.8
nameserver 2606:4700:4700::1111
nameserver 2001:4860:4860::8888
EOF
After the change, test again:
curl -4 ip.sb
curl -6 ip.sb
If it returns your IPv4 and IPv6 addresses, DNS is working correctly.
Step 8: Restart Panel/Service and Summary
If you are using a management panel (such as x-ui), after the network configuration and DNS are correct, you can restart the panel service:
sudo systemctl restart x-ui
Then refresh the panel; it should normally display the IPv4 and IPv6 addresses correctly. If the panel relies on external services for location information, make sure DNS can resolve external domains.
Summary
Through the above steps, we achieved the following goals:
- Obtained IPv4 and IPv6 configuration info from the provider’s interface, and understood that the IPv6
/64is a subnet from which you need to pick an address. - Used
ip linkto identify the interface name and accordingly modified the netplan configuration. - Disabled cloud-init’s network configuration to prevent it from being overwritten on reboot.
- Added both IPv4 and IPv6 addresses, gateways, and DNS in netplan, and set appropriate permissions.
- After applying the configuration, verified addresses, routes, and connectivity, while ignoring certain non-critical system warnings.
- Fixed missing DNS file issues causing domain resolution failures to ensure normal external network access.
The whole process is not complicated, but each step requires attention to detail. For example, when selecting an IPv6 address, do not use the /64 network itself; after modifying netplan, run generate before apply; and when encountering permission or Open vSwitch warnings, understand the root cause. I hope this record helps you smoothly enable IPv4 and IPv6 on your VPS.
