Skip to content

Incorrect iptable rules for SNAT #5365

Description

@ravening
ISSUE TYPE
  • Bug Report
COMPONENT NAME
VPC, VR
CLOUDSTACK VERSION
4.14
CONFIGURATION

Advanced network

OS / ENVIRONMENT
SUMMARY

I have created vpc with several networks in it. I asociated snat to a vm in one of the network. when i try to access the vm with snat from a vm in different network in the same vpc, the source ip is changed. The source ip should be in the same subnet of the vm which has the snat

Basically source address is pointing to different subnet address rather than the same subnet address of that network

STEPS TO REPRODUCE
  1. create a vpc
  2. create multiple networks in it with range 10.250.10., 10.250.20., 10.250.40.* and so on
  3. create a vm in the network with range 10.250.20* and 10.250.40.. The VR has 10.250.20.253 ip for 10.250.20. network and 10.250.40.253 ip for 10.250.40.* network
  4. Add snat to the vm in 10.250.20* network
  5. If i try to access public snat ip from the same vm, the source ip is showing fine as 10.250.20.253 but if i try to access it from 10.250.40.* network, im seeing different source ip. its showing as 10.250.40.253

EXPECTED RESULTS

Below are the expected iptables rules

iptables -t nat -L -n

target     prot opt source               destination
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            mark match 0x525

SNAT       all  --  10.250.120.0/24      10.250.120.147       to:10.250.120.253 <<<<<<<<<<<<<<<<<<<<

SNAT       all  --  10.250.120.0/24      10.250.120.139       to:10.250.120.253

SNAT       all  --  10.250.90.0/24       10.250.90.239        to:10.250.90.253

SNAT       all  --  10.250.80.0/24       10.250.80.124        to:10.250.80.253

SNAT       all  --  10.250.50.0/24       10.250.50.113        to:10.250.50.253

SNAT       all  --  10.250.10.0/24       10.250.10.89         to:10.250.10.253

SNAT       all  --  10.250.10.0/24       10.250.10.237        to:10.250.10.253

SNAT       all  --  10.250.20.0/24       10.250.20.151        to:10.250.20.253

SNAT       all  --  10.250.20.0/24       10.250.20.159        to:10.250.20.253

SNAT       all  --  10.250.40.0/24       10.250.40.85         to:10.250.40.253 <<<<<<<<<<<<<<<<<<<<<<<<

SNAT       all  --  10.250.30.0/24       10.250.30.73         to:10.250.30.253
ACTUAL RESULTS

Below are the new iptable rules

target     prot opt source               destination
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            mark match 0x525

SNAT       all  --  10.250.120.0/24      10.250.120.147       to:10.250.40.253 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

SNAT       all  --  10.250.120.0/24      10.250.120.139       to:10.250.40.253 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

SNAT       all  --  10.250.90.0/24       10.250.90.239        to:10.250.40.253 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

SNAT       all  --  10.250.80.0/24       10.250.80.124        to:10.250.40.253

SNAT       all  --  10.250.50.0/24       10.250.50.113        to:10.250.40.253

SNAT       all  --  10.250.10.0/24       10.250.10.89         to:10.250.40.253

SNAT       all  --  10.250.10.0/24       10.250.10.237        to:10.250.40.253

SNAT       all  --  10.250.20.0/24       10.250.20.151        to:10.250.40.253 <<<<<<<<<<<<<<<<<<<<<<

SNAT       all  --  10.250.20.0/24       10.250.20.159        to:10.250.40.253

SNAT       all  --  10.250.40.0/24       10.250.40.85         to:10.250.40.253

SNAT       all  --  10.250.30.0/24       10.250.30.73         to:10.250.40.253

This is how the inet address in vr is configured

inet 10.250.20.253/24 brd 10.250.20.255 scope global eth5
    inet 10.250.20.1/24 brd 10.250.20.255 scope global secondary eth5

but the iptable rules show

SNAT       all  --  10.250.20.0/24       10.250.20.151        to:10.250.40.253

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions