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:
cat /proc/sys/net/ipv4/ip_forward
1
0
To temporarily enable IP forwarding:
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
To make the change persistent after reboot, edit /etc/sysctl.conf:
/etc/sysctl.conf
sudo nano /etc/sysctl.conf
Add or uncomment the following line:
net.ipv4.ip_forward=1
Apply the changes:
sudo 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:
sudo iptables -t nat -L POSTROUTING -v
MASQUERADE all -- anywhere anywhere
To set up NAT (masquerade) for a private network (e.g., 192.168.1.0/24), run:
192.168.1.0/24
sudo 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).
eth0
ip a
To make the NAT rules persistent, install and configure iptables-persistent:
iptables-persistent
sudo 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:
This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.
Vibe can make mistakes. Check answers. Learn more