Here, the network card name is ens3; after netmask is the netmask; after inet is the IPv4 address; and after inet6 are the IPv6 addresses.
View gateway information
To check the IPv4 gateway, use:
ip route show dev ens3
1 2
default via 132.98.174.193 onlink 132.98.174.192/26 proto kernel scope link src 132.98.174.248
To check the IPv6 gateway, use:
ip -6 route show dev ens3
1 2 3
1200:7e45::/48 proto kernel metric 256 pref medium 80e3::/64 proto kernel metric 256 pref medium default via 1200:7e45:0:f6::1 metric 1024 onlink pref medium
The gateway address appears after default via.
Debian Configuration File
Once you have these IP details, you can write the network card configuration. Here’s the Debian network card configuration:
Alternatively, you can write the subnet mask and add an extra IPv6 address in this format:
1 2 3 4 5 6 7 8 9 10 11 12
auto lo iface lo inet loopback
auto ens3 iface ens3 inet static address 132.98.174.248/26 # IPv4 address and netmask gateway 132.98.174.193
iface ens3 inet6 static address 1200:7e45:0:f6::1e4a:3705/48 # IPv6 address and netmask gateway 1200:7e45:0:f6::1 up ip addr add 1200:7e45:0:f6::235e:3b7e/48 dev ens3 # Add extra IPv6 address
Once everything is configured, restart the network service, or reboot the server:
systemctl restart networking.service
Ubuntu Configuration File
The above configuration is for Debian. Below is the Ubuntu system configuration file. In Ubuntu, network configuration files are located in the netplan folder, typically named something like 10-ens3.yaml. Here’s an example:
Save and reboot the system. Finally, test whether IPv6 is working by pinging Google or an IPv6 address from the server:
ping6 google.com
Multi IPv4 Configuration
Here’s an example of Debian multi-IP configuration for a single network card, just for reference. This is written from memory, so it hasn’t been tested!
iface ens3 inet6 static address 1200:7e45:0:f6::1e4a:3705/48 gateway 1200:7e45:0:f6::1 up ip addr add 1200:7e45:0:f6::235e:3b7e/48 dev ens3 # Adding another IPv4 address below, note that you should not specify a gateway here auto ens3:0 iface ens3:0 inet static address 132.98.174.249/26
Once saved, restart the network or reboot the server.