To verify if IP forwarding and NAT (Network Address Translation) are enabled on your OVH Debian 13 VPS, you can follow these steps:
IP forwarding allows your VPS to act as a router, forwarding packets between networks.
Run the following command to check if IP forwarding is enabled:
bashcat /proc/sys/net/ipv4/ip_forward
1: IP forwarding is enabled.0: IP forwarding is disabled.To temporarily enable IP forwarding:
bashecho 1 | sudo tee /proc/sys/net/ipv4/ip_forward
To make the change persistent after reboot, edit /etc/sysctl.conf:
bashsudo nano /etc/sysctl.conf
Add or uncomment the following line:
ininet.ipv4.ip_forward=1
Apply the changes:
bashsudo sysctl -p
NAT allows your VPS to share its public IP with private network devices.
Run the following command to list your NAT (masquerading) rules:
bashsudo iptables -t nat -L POSTROUTING -v
NAT is enabled.plaintextMASQUERADE all -- anywhere anywhere
To set up NAT (masquerade) for a private network (e.g., 192.168.1.0/24), run:
bashsudo iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE
Replace eth0 with your public-facing network interface (check with ip a).
To make the NAT rules persistent, install and configure iptables-persistent:
bashsudo apt install iptables-persistent -y sudo netfilter-persistent save
OVH provides a hardware firewall (VAC). If you're using it, ensure it doesn't block forwarding or NAT:
To test if forwarding and NAT work:
cat /proc/sys/net/ipv4/ip_forwardsudo iptables -t nat -L POSTROUTING -vsudo iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADEVibe can make mistakes. Check answers. Learn more