Setting Up Networking on Kali in an OVH Server VM
Similar to my posts on Ubuntu guest VM networking on OVH Hosting and the same networking issues on Kali, networking for guest VM’s can be a little complex on OVH hosting. The physical network infrastructure isn’t reflected in the way IPv4 addresses are used, and the gateway address you need must be specified as an ‘onlink’ host.
IPv4 addresses rented from OVH hosting are ‘Failover IPs’ with virtual MAC addresses. The gateway is outside your IP’s subnet. While modern cloud-init images handle this okay, a blank Debian 13 (Trixie) or 12 (Bookworm) “netinst” ISO installation will essentially install offline, leaving you with no connectivity on first boot.
Temporary Fix
To fix the situation temporarily, until reboot, try the below.
You may need to adjust the interface name (e.g. ens18), and you should replace the IP addresses with your rented IP
and the corresponding ‘onlink’ gateway, which will not be in your CIDR block.
# Flush any existing junk
ip addr flush dev ens18
# Add your IP
ip addr add C.C.C.C/32 dev ens18
# Set the interface up
ip link set ens18 up
# Add the route to the gateway explicitly
ip route add D.D.D.D/32 dev ens18
# Add the default gateway via that route
ip route add default via D.D.D.D dev ens18 onlink
By this time, you should have working networking (ping 8.8.8.8), but no DNS. You may very well not have a
/etc/resolv.conf file at this point, so create one and include the line nameserver 1.1.1.1 or something similar.
Pause to Secure
At this point, you should be able to use apt, install firewalls, get SSH working etc. Secure the infrastructure, then fix the networking in a way that will persist after reboot.
Persistent Networking Fix
Install ifupdown, then edit the interfaces file:
/etc/network/interfaces
You will need to replicate the manual commands we ran earlier. The key is using up commands to force the routing rules every time the interface comes up. Again, you will need to use your own IP addresses, and correct the network interface name if necessary.
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto ens18
iface ens18 inet static
address C.C.C.C/32
# OVH Specific: Route to gateway explicitly because it is "on-link"
up ip route add D.D.D.D/32 dev ens18
up ip route add default via D.D.D.D dev ens18 onlink
dns-nameservers 1.1.1.1 8.8.8.8
Applying the Changes
If you still have your manual ip commands active, ifupdown might complain that the address is already assigned. You can flush the interface again or simply reboot.