How to verify that I allow forwarding and/or NAT on my OVH Debian 13 VPS?
May 19, 8:12pm

To verify if IP forwarding and NAT (Network Address Translation) are enabled on your OVH Debian 13 VPS, you can follow these steps:


1. Check IP Forwarding

IP forwarding allows your VPS to act as a router, forwarding packets between networks.

Check Current Status

Run the following command to check if IP forwarding is enabled:

bash
cat /proc/sys/net/ipv4/ip_forward
  • Output 1: IP forwarding is enabled.
  • Output 0: IP forwarding is disabled.

Enable IP Forwarding (if needed)

To temporarily enable IP forwarding:

bash
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward

To make the change persistent after reboot, edit /etc/sysctl.conf:

bash
sudo nano /etc/sysctl.conf

Add or uncomment the following line:

ini
net.ipv4.ip_forward=1

Apply the changes:

bash
sudo sysctl -p

2. Check NAT (Masquerading) Rules

NAT allows your VPS to share its public IP with private network devices.

Check NAT Rules

Run the following command to list your NAT (masquerading) rules:

bash
sudo iptables -t nat -L POSTROUTING -v
  • If you see rules like:
    plaintext
    MASQUERADE  all  --  anywhere             anywhere
    NAT is enabled.

Enable NAT (if needed)

To set up NAT (masquerade) for a private network (e.g., 192.168.1.0/24), run:

bash
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).

To make the NAT rules persistent, install and configure iptables-persistent:

bash
sudo apt install iptables-persistent -y
sudo netfilter-persistent save

3. Verify OVH Firewall Settings

OVH provides a hardware firewall (VAC). If you're using it, ensure it doesn't block forwarding or NAT:

  1. Log in to the OVH Control Panel.
  2. Go to VPS > Your VPS > Firewall (VAC).
  3. Ensure the firewall rules allow traffic forwarding and NAT.

4. Test Connectivity

To test if forwarding and NAT work:

  • Set up a device (e.g., another computer) on the same private network.
  • Configure it to use your VPS as its gateway.
  • Check if the device can access the internet through your VPS.

Summary Table

IP Forwarding
cat /proc/sys/net/ipv4/ip_forward
`echo 1
NAT (Masquerade)
sudo iptables -t nat -L POSTROUTING -v
sudo iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE

May 19, 8:12pm

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