Completely lost... Port Forwarding to a VLAN on EdgeRouter X

Got a Grandstream VoIP box and it worked with port forwarding on my AC68U, but as soon as I isolated it in a PVID VLAN on the EdgeRouter X, nothing port forwards to it.

This is critical for our home phone solution because if it doesn’t work, our family can’t use the phone.

I got most everything else down, but I’m stuck at port forwarding, and nothing I’m searching up gives useful advice. It’s all over the place. and the EdgeRouter is throwing new terms at me that I have no idea what they mean… Hairpin NAT? Destination NAT? I’m so lost and confused.

The rest of the network is up and running, EXCEPT the VoIP box.

So far my answer is: You can’t. I literally just tried undoing the PVID on the port and using the switch0 LAN and it then magically worked. Has this EVER worked? Is it a fruitless venture to do this?

Isn’t eth0 on the EDGE devices the upstream port to the modem ?

Then you would connect this VOIP box up to eth1, 2, 3 or 4.

As for port forwarding, you are talking about forwarding this traffic to the VOIP box then.

Does this device grab a DHCP from the EDGE router or are you statically setting it up ?

Also if you statically set it up have you configured the LAN ports on the EDGE devie to match the same subnet as the VOIP device ?

This means to configure the LAN ports on the EDGE to give out or use say a Class C of 182.168.xxx.xxx or Class A like 10.10.xxx.xxx

I gave it a VLAN and DHCP of 10.254.254.0/29. But it appears the Port Forwarding dialogs in the GUI only support a LAN interface that isn’t a VLAN, like switch0.

The VoIP box is DHCP and then I do a manual assignment via DHCP, and it port forwards correctly if the device is on switch0. It does not forward correctly if it’s switch0.40. My limited knowledge only lets me know it’s impossible with a VLAN to port forward.

Why not just move the Voip box to the native vlan and everything else to the other if thats the only thing that needs port forwarded (alternatively probably do able on cli)

Hi Furry,

Not too much time to hang around on forums today, were you following some specific guide or tutorial on how to set things up?

For VLANs

here’s a brief primer:

It’s usually best to test the VLAN port by plugging in your laptop in that port and seeing what works what doesn’t.

Maybe routing / nat is fine in general and grandstream needs UPNP?

Check what works what doesn’t with your laptop.
Is sip/soft-phone an option you can test out?


For NAT:

… and SNAT/DNAT/hairpin/firewall stuff.

When you setup forwarding in a consumer router UI, behind the scenes you’re getting a DNAT rule in the firewall that rewrites the destination IP address within a packet coming from the internet, and you get a firewall hole that allows connections from any internet IP to your internal IP as long as the destination tcp or udp port is e.g. 1234.

UPNP allows software to do the same thing without having to bother a human to go into a webui and click on things.

DNAT == Destination NAT == NAT that overwrites the destination address of the original tcp/udp packet.

SNAT == Source NAT == NAT that overwrites the source address of the original tcp/udp packet.

This rewriting is done in the firewall in the “mangle” phase, which happens before the “filtering” phase. (phase of processing, people call it also “chain” or “table”).

For this rewriting to be practically useful, packets going in the other direction need to be re-written too and also whitelisted in the firewall symmetrically, otherwise you can’t really have connections. This other-direction-rewriting is not something that needs to be set-up manually - these SNAT and DNAT rules will automatically add connection tracking entries when they see the initial packet and will take care of mangling packets going in the other direction accordingly as well.

After the packets are mangled/rewritten, filtering comes along. If doing this manually, you’d need to ensure this original packet (when you want to allow a connection) makes a connection tracking entry, and then you’d need to ensure that future packets belonging to that connection going in either direction are allowed. This is not done automatically by any magical NAT rule. You’ll need at least 2 rules, one to allow any existing connection in a table (sometimes called related/established), and one to pick what to add into that table. e.g. anything originating on your LAN going to the internet, or anything coming from the internet to your LAN webserver onto port 8080. You’ll see this referred to as “statefull firewall” - since connection state is being tracked, or maybe referred to as “ctstate” in some places.


Hairpin Nat == not only redirect connections coming to the router from the internet, but also redirect connections from any other host on the same network. This is probably not useful to you for VoIP. It’s useful if you want to run a webserver at home and access it using the same public IP address and port as you would from the internet. (e.g. you’re using duckdns or similar). Reason this is a special case is because it requires using both DNAT and SNAT to pull off. If you were only using DNAT, browser host would send a packet to the router, router would rewrite dst ip, and send it to the webserver, webserver would look at where packet came from (your browser host) and would send a reply packet back to your browser host directly. Your browser host does not expect that packet since it thinks (or it only knows) that it’s talking to the router ip, so it discards this random looking packet and things don’t work. Additional SNAT fixes this by lying to the webserver - it overwrites the src ip of the packets as well, so that webserver replies to the router, which can then fix the src/dst IPs for your browser host, so that it too thinks it’s only talking to the router.


This NAT mess is why network people were enthusiastic about IPv6 originally. Turns out folks still want statefull firewalls even on IPv6 and having to know both IPv6 and IPv4 inside and out is strictly more complicated than knowing just one of the two.


1 Like

I didn’t assign a PVID to the VoIP port and it worked. If I assign a PVID and VLAN, it doesn’t work, and the only things I’ve found is “It should work.”

The VoIP box I have no clue if it uses UPnP. I prefer UPnP off, but the settings are also uploaded to the box remotely so any local settings changes get changed back on reboot or it detecting a internet connection. Now you see how frustrating this box is.

if you dont assign it will be on the native vlan

Hi,

Let me try to understand where exactly you’re getting stuck.
(might be repetitive, sorry)

So you have one of the ethernet ports that’s only for your phone,
you’ve configured it with pvid=40
and you have a switch0.40 interface,
and your deskphone gets a dhcp address from a dhcp server running on switch0.40
and you can ping your deskphone from a router and from your computer (from a different VLAN).

And you plug your computer/laptop into a pvid=40 port, and you get an IP similar to that your deskphone gets, and you can browse the web.


but, you’re failing try to add a DNAT mangle rule to redirect tcp/udp port 5060 and 5061 from the web to your deskphone,
and/or you’re failing to add a filter rule to accept traffic going to port 5060 from the internet.

… or is the SIP signaling ok and it’s the RTP that has issues.

EdgeOS can be unintuitive if you’re accustomed to something like pfsense. You really need to know NAT, routing, vlans, etc.

Port forwarding is just a short hand for NAT rules. EdgeOS GUI has port forwarding for your convenience but if you need to do something complex, you have to use NAT directly.

Can you dump your whole config (redact where necessary).

I tried DNAT for this and it seems the NAT rules when using the GUI only apply for switch0, not the VLANs. If the VoIP box is on switch0, the basic GUI works without having to resort to DNAT. But even with DNAT, the VLAN doesn’t do anything. I need to port forward 5060 and 8080. I set a static IP via the DHCP settings and that worked on switch0, but not the VLANs to target that IP.

Because of the native VLAN setup for that VoIP box, it’s from my CCP Telco, and therefore the EdgeRouter network switch0 becomes untrusted because it can access the rest of that LAN. I want to put it in a VLAN dropping all other connections except for it’s SIP and Proxy connections and not have it communicate with the rest of the LAN. This is also where it gets tricky on firewall rules, and I’m still a newbie to that stuff… how to ensure only the right traffic flows but it drops everything else in a sandboxed VLAN.

Not sure how much it can help because it’s working as it is right now. But only because the VoIP box is on the same network as the native VLAN. The current config won’t reveal anything as the VLAN specifically for the VoIP box doesn’t exist in this native VLAN setup for it. Putting it on the native VLAN though turns switch0 into an untrusted network.

All I did was made a VLAN ID 40, made eth4 PVID 40, assigned it 10.254.254.0/29, made a DHCP of the same range, assigned the MAC of the VoIP box to a static IP of 10.254.254.2 with it connected to eth4, then I tried both port forwarding with the LAN interface on switch0.40 and DNAT and both didn’t work at all. DHCP got the correct IP to it, but no matter what I tried, 5060 and 8080 both wouldn’t pass over to the VoIP box. All Google results say it “should work.” But it doesn’t.

I smell a missing firewall rule to allow traffic that you’ve DNAT-ed , probably that “Auto Firewall” thing is not doing it’s job somehow, perhaps switch 0.40 is not in the right zone, but I’m not sure how to best explain how to debug this.

Maybe if you can ssh into EdgeOS, and are able to run iptables -t nat -S and iptables -S, perhaps that output is useful.

Given EdgeOS uses iptables underneath, it’s also possible to insert log rules in various places and read the messages in dmesg.

EdgeOS picked up the firewall zones and rulesets organization from Vyatta/VyOS, but ultimately it’s just iptables. EdgeOS is basically the same with a web UI on top of that same ol’ firewall configuration.


Another option I can think of, is that somehow your VoIP phone or modem are already messing with VLANs in some way and nesting VLANs or doing something else that’s causing things to get weirdly dropped. Using a laptop instead of a phone would let you confirm port forwarding is working well.


When it comes to preventing routing between VLANs. Either VyOS wiki or EdgeOS manuals could be useful in helping you figure out how to configure this.

Well, the VoIP box pulls from a remote configuration each time it boots, and saving a local configuration is only temporary. As the ISP has to allow upload of the local config for it to persist between reboots. IP configuration is pretty much stuck as DHCP, and you can’t change the subnet mask or assign a Static IP on the box itself.

The remote configuration is done in China. Another reason I want to VLAN that stuff.

One thing I have noticed is when I made a VLAN of 10 and PVID of 10 using separate DHCP, but allowing it access to switch0, trying to login to the GUI results in reset connections.

I’m also using multiple interfaces per rule for the “drop” rule to do VLAN isolation. Is that an issue that you can’t have multiple interfaces for a drop rule?

Here’s the config file you requested for the setup that currently doesn’t work:

----------------
Configuration File
----------------
 firewall {
     all-ping enable
     broadcast-ping disable
     ipv6-receive-redirects disable
     ipv6-src-route disable
     ip-src-route disable
     log-martians enable
     name Drop {
         default-action drop
         description ""
     }
     name Drop2 {
         default-action drop
         description ""
     }
     name WAN_IN {
         default-action drop
         description "WAN to internal"
         rule 10 {
             action accept
             description "Allow established/related"
             state {
                 established enable
                 related enable
             }
         }
         rule 20 {
             action drop
             description "Drop invalid state"
             state {
                 invalid enable
             }
         }
     }
     name WAN_LOCAL {
         default-action drop
         description "WAN to router"
         rule 10 {
             action accept
             description "Allow established/related"
             state {
                 established enable
                 related enable
             }
         }
         rule 20 {
             action drop
             description "Drop invalid state"
             state {
                 invalid enable
             }
         }
     }
     options {
         mss-clamp {
             mss 1412
         }
     }
     receive-redirects disable
     send-redirects enable
     source-validation disable
     syn-cookies enable
 }
 interfaces {
     ethernet eth0 {
         description "Internet (PPPoE)"
         duplex auto
         pppoe 0 {
             default-route auto
             firewall {
                 in {
                     name WAN_IN
                 }
                 local {
                     name WAN_LOCAL
                 }
             }
             mtu 1492
             name-server auto
             password ****************
             user-id [REDACTED]
         }
         speed auto
     }
     ethernet eth1 {
         description Local
         duplex auto
         speed auto
     }
     ethernet eth2 {
         description Local
         duplex auto
         speed auto
     }
     ethernet eth3 {
         description Local
         duplex auto
         speed auto
     }
     ethernet eth4 {
         description Local
         duplex auto
         speed auto
     }
     loopback lo {
     }
     switch switch0 {
         address 192.168.5.1/24
         description Local
         mtu 1500
         switch-port {
             interface eth1 {
             }
             interface eth2 {
                 vlan {
                     pvid 10
                 }
             }
             interface eth3 {
                 vlan {
                     pvid 20
                 }
             }
             interface eth4 {
                 vlan {
                     pvid 30
                 }
             }
             vlan-aware enable
         }
         vif 10 {
             address 192.168.50.1/24
             firewall {
                 local {
                     name Drop
                 }
             }
             mtu 1500
         }
         vif 20 {
             address 192.168.10.1/28
             firewall {
                 local {
                     name Drop2
                 }
             }
             mtu 1500
         }
         vif 30 {
             address 192.168.20.1/24
             mtu 1500
         }
     }
 }
 port-forward {
     auto-firewall enable
     hairpin-nat enable
     lan-interface switch0.30
     rule 1 {
         description VoIP1
         forward-to {
             address 192.168.20.2
             port 5060
         }
         original-port 5060
         protocol tcp_udp
     }
     rule 2 {
         description VoIP2
         forward-to {
             address 192.168.20.2
             port 8080
         }
         original-port 8080
         protocol tcp_udp
     }
     wan-interface pppoe0
 }
 service {
     dhcp-server {
         disabled false
         hostfile-update disable
         shared-network-name LAN {
             authoritative enable
             subnet 192.168.5.0/24 {
                 default-router 192.168.5.1
                 dns-server 192.168.5.1
                 lease 86400
                 start 192.168.5.101 {
                     stop 192.168.5.243
                 }
                 static-mapping AC86U {
                     ip-address 192.168.5.100
                     mac-address [REDACTED]
                 }
                 static-mapping Grandstream {
                     ip-address 192.168.5.99
                     mac-address [REDACTED]
                 }
             }
         }
         shared-network-name LAN1 {
             authoritative disable
             subnet 192.168.50.0/24 {
                 default-router 192.168.50.1
                 dns-server 192.168.50.1
                 lease 86400
                 start 192.168.50.101 {
                     stop 192.168.50.253
                 }
             }
         }
         shared-network-name LAN2 {
             authoritative disable
             subnet 192.168.10.0/28 {
                 default-router 192.168.10.1
                 dns-server 192.168.10.1
                 lease 86400
                 start 192.168.10.3 {
                     stop 192.168.10.15
                 }
             }
         }
         shared-network-name LAN3 {
             authoritative disable
             subnet 192.168.20.0/24 {
                 default-router 192.168.20.1
                 dns-server 192.168.20.1
                 lease 86400
                 start 192.168.20.2 {
                     stop 192.168.20.254
                 }
                 static-mapping Grandstream {
                     ip-address 192.168.20.2
                     mac-address [REDACTED]
                 }
             }
         }
         static-arp disable
         use-dnsmasq disable
     }
     dns {
         forwarding {
             cache-size 150
             listen-on switch0
         }
     }
     gui {
         http-port 80
         https-port 443
         older-ciphers enable
     }
     nat {
         rule 5010 {
             description "masquerade for WAN"
             outbound-interface pppoe0
             type masquerade
         }
     }
     unms {
         disable
     }
 }
 system {
     host-name [REDACTED]
     login {
         user [REDACTED] {
             authentication {
                 encrypted-password ****************
             }
             level admin
         }
     }
     ntp {
         server 0.ubnt.pool.ntp.org {
         }
         server 1.ubnt.pool.ntp.org {
         }
         server 2.ubnt.pool.ntp.org {
         }
         server 3.ubnt.pool.ntp.org {
         }
     }
     syslog {
         global {
             facility all {
                 level notice
             }
             facility protocols {
                 level debug
             }
         }
     }
     time-zone America/Vancouver
 }
 traffic-control {
     smart-queue [REDACTED] {
         download {
             ecn enable
             flows 1024
             fq-quantum 1514
             limit 10240
             rate 96250kbit
         }
         upload {
             ecn enable
             flows 1024
             fq-quantum 1514
             limit 10240
             rate 50800kbit
         }
         wan-interface pppoe0
     }
 }

----------------
Running configuration
----------------
firewall {
    all-ping enable
    broadcast-ping disable
    ipv6-receive-redirects disable
    ipv6-src-route disable
    ip-src-route disable
    log-martians enable
    name Drop {
        default-action drop
        description ""
    }
    name Drop2 {
        default-action drop
        description ""
    }
    name WAN_IN {
        default-action drop
        description "WAN to internal"
        rule 10 {
            action accept
            description "Allow established/related"
            state {
                established enable
                related enable
            }
        }
        rule 20 {
            action drop
            description "Drop invalid state"
            state {
                invalid enable
            }
        }
    }
    name WAN_LOCAL {
        default-action drop
        description "WAN to router"
        rule 10 {
            action accept
            description "Allow established/related"
            state {
                established enable
                related enable
            }
        }
        rule 20 {
            action drop
            description "Drop invalid state"
            state {
                invalid enable
            }
        }
    }
    options {
        mss-clamp {
            mss 1412
        }
    }
    receive-redirects disable
    send-redirects enable
    source-validation disable
    syn-cookies enable
}
interfaces {
    ethernet eth0 {
        description "Internet (PPPoE)"
        duplex auto
        pppoe 0 {
            default-route auto
            firewall {
                in {
                    name WAN_IN
                }
                local {
                    name WAN_LOCAL
                }
            }
            mtu 1492
            name-server auto
            password ****************
            user-id [REDACTED]
        }
        speed auto
    }
    ethernet eth1 {
        description Local
        duplex auto
        speed auto
    }
    ethernet eth2 {
        description Local
        duplex auto
        speed auto
    }
    ethernet eth3 {
        description Local
        duplex auto
        speed auto
    }
    ethernet eth4 {
        description Local
        duplex auto
        speed auto
    }
    loopback lo {
    }
    switch switch0 {
        address 192.168.5.1/24
        description Local
        mtu 1500
        switch-port {
            interface eth1 {
            }
            interface eth2 {
                vlan {
                    pvid 10
                }
            }
            interface eth3 {
                vlan {
                    pvid 20
                }
            }
            interface eth4 {
                vlan {
                    pvid 30
                }
            }
            vlan-aware enable
        }
        vif 10 {
            address 192.168.50.1/24
            firewall {
                local {
                    name Drop
                }
            }
            mtu 1500
        }
        vif 20 {
            address 192.168.10.1/28
            firewall {
                local {
                    name Drop2
                }
            }
            mtu 1500
        }
        vif 30 {
            address 192.168.20.1/24
            mtu 1500
        }
    }
}
port-forward {
    auto-firewall enable
    hairpin-nat enable
    lan-interface switch0.30
    rule 1 {
        description VoIP1
        forward-to {
            address 192.168.20.2
            port 5060
        }
        original-port 5060
        protocol tcp_udp
    }
    rule 2 {
        description VoIP2
        forward-to {
            address 192.168.20.2
            port 8080
        }
        original-port 8080
        protocol tcp_udp
    }
    wan-interface pppoe0
}
service {
    dhcp-server {
        disabled false
        hostfile-update disable
        shared-network-name LAN {
            authoritative enable
            subnet 192.168.5.0/24 {
                default-router 192.168.5.1
                dns-server 192.168.5.1
                lease 86400
                start 192.168.5.101 {
                    stop 192.168.5.243
                }
                static-mapping AC86U {
                    ip-address 192.168.5.100
                    mac-address [REDACTED]
                }
                static-mapping Grandstream {
                    ip-address 192.168.5.99
                    mac-address [REDACTED]
                }
            }
        }
        shared-network-name LAN1 {
            authoritative disable
            subnet 192.168.50.0/24 {
                default-router 192.168.50.1
                dns-server 192.168.50.1
                lease 86400
                start 192.168.50.101 {
                    stop 192.168.50.253
                }
            }
        }
        shared-network-name LAN2 {
            authoritative disable
            subnet 192.168.10.0/28 {
                default-router 192.168.10.1
                dns-server 192.168.10.1
                lease 86400
                start 192.168.10.3 {
                    stop 192.168.10.15
                }
            }
        }
        shared-network-name LAN3 {
            subnet 192.168.20.0/24 {
                default-router 192.168.20.1
                dns-server 192.168.20.1
                start 192.168.20.2 {
                    stop 192.168.20.254
                }
                static-mapping Grandstream {
                    ip-address 192.168.20.2
                    mac-address [REDACTED]
                }
            }
        }
        static-arp disable
        use-dnsmasq disable
    }
    dns {
        forwarding {
            cache-size 150
            listen-on switch0
        }
    }
    gui {
        http-port 80
        https-port 443
        older-ciphers enable
    }
    nat {
        rule 5010 {
            description "masquerade for WAN"
            outbound-interface pppoe0
            type masquerade
        }
    }
    unms {
        disable
    }
}
system {
    host-name [REDACTED]
    login {
        user [REDACTED] {
            authentication {
                encrypted-password ****************
            }
            level admin
        }
    }
    ntp {
        server 0.ubnt.pool.ntp.org {
        }
        server 1.ubnt.pool.ntp.org {
        }
        server 2.ubnt.pool.ntp.org {
        }
        server 3.ubnt.pool.ntp.org {
        }
    }
    syslog {
        global {
            facility all {
                level notice
            }
            facility protocols {
                level debug
            }
        }
    }
    time-zone America/Vancouver
}
traffic-control {
    smart-queue [REDACTED] {
        download {
            ecn enable
            flows 1024
            fq-quantum 1514
            limit 10240
            rate 96250kbit
        }
        upload {
            ecn enable
            flows 1024
            fq-quantum 1514
            limit 10240
            rate 50800kbit
        }
        wan-interface pppoe0
    }
}

Here’s an iptables dump from the official support file:

----------------
Save Iptables Rule-Set
----------------
# Generated by iptables-save v1.4.21 on Fri Jun 19 13:26:29 2020
*nat
:PREROUTING ACCEPT [331:29381]
:INPUT ACCEPT [29:1761]
:OUTPUT ACCEPT [411:48250]
:POSTROUTING ACCEPT [299:30456]
:MINIUPNPD - [0:0]
:MINIUPNPD-POSTROUTING - [0:0]
:UBNT_PFOR_DNAT_HOOK - [0:0]
:UBNT_PFOR_DNAT_RULES - [0:0]
:UBNT_PFOR_SNAT_HOOK - [0:0]
:UBNT_PFOR_SNAT_RULES - [0:0]
:UBNT_SUSPEND_DNAT_HOOK - [0:0]
:UBNT_VPN_IPSEC_SNAT_HOOK - [0:0]
:VYATTA_DNAT - [0:0]
:VYATTA_PRE_DNAT_HOOK - [0:0]
:VYATTA_PRE_SNAT_HOOK - [0:0]
:VYATTA_SNAT - [0:0]
[17700:2104113] -A PREROUTING -j MINIUPNPD
[17700:2104113] -A PREROUTING -j UBNT_PFOR_DNAT_HOOK
[17700:2104113] -A PREROUTING -j VYATTA_PRE_DNAT_HOOK
[17700:2104113] -A PREROUTING -j UBNT_SUSPEND_DNAT_HOOK
[17700:2104113] -A PREROUTING -j VYATTA_DNAT
[9477:1132927] -A POSTROUTING -j UBNT_VPN_IPSEC_SNAT_HOOK
[9477:1132927] -A POSTROUTING -j MINIUPNPD-POSTROUTING
[9477:1132927] -A POSTROUTING -j UBNT_PFOR_SNAT_HOOK
[9477:1132927] -A POSTROUTING -j VYATTA_PRE_SNAT_HOOK
[9477:1132927] -A POSTROUTING -j VYATTA_SNAT
[0:0] -A UBNT_PFOR_DNAT_HOOK -i pppoe0 -m set --match-set ADDRv4_pppoe0 dst -j UBNT_PFOR_DNAT_RULES
[0:0] -A UBNT_PFOR_DNAT_HOOK -i switch0.30 -m set --match-set ADDRv4_pppoe0 dst -j UBNT_PFOR_DNAT_RULES
[0:0] -A UBNT_PFOR_DNAT_RULES -p tcp -m tcp --dport 5060 -j DNAT --to-destination 192.168.20.2:5060
[0:0] -A UBNT_PFOR_DNAT_RULES -p udp -m udp --dport 5060 -j DNAT --to-destination 192.168.20.2:5060
[0:0] -A UBNT_PFOR_DNAT_RULES -p tcp -m tcp --dport 8080 -j DNAT --to-destination 192.168.20.2:8080
[0:0] -A UBNT_PFOR_DNAT_RULES -p udp -m udp --dport 8080 -j DNAT --to-destination 192.168.20.2:8080
[23:2041] -A UBNT_PFOR_SNAT_HOOK -o switch0.30 -j UBNT_PFOR_SNAT_RULES
[0:0] -A UBNT_PFOR_SNAT_RULES -d 192.168.20.2/32 -o switch0.30 -p tcp -m set --match-set NETv4_switch0.30 src -m tcp --dport 5060 -j MASQUERADE
[0:0] -A UBNT_PFOR_SNAT_RULES -d 192.168.20.2/32 -o switch0.30 -p udp -m set --match-set NETv4_switch0.30 src -m udp --dport 5060 -j MASQUERADE
[0:0] -A UBNT_PFOR_SNAT_RULES -d 192.168.20.2/32 -o switch0.30 -p tcp -m set --match-set NETv4_switch0.30 src -m tcp --dport 8080 -j MASQUERADE
[0:0] -A UBNT_PFOR_SNAT_RULES -d 192.168.20.2/32 -o switch0.30 -p udp -m set --match-set NETv4_switch0.30 src -m udp --dport 8080 -j MASQUERADE
[17700:2104113] -A VYATTA_PRE_DNAT_HOOK -j RETURN
[9477:1132927] -A VYATTA_PRE_SNAT_HOOK -j RETURN
[8230:1012076] -A VYATTA_SNAT -o pppoe0 -m comment --comment NAT-5010 -j MASQUERADE
COMMIT
# Completed on Fri Jun 19 13:26:29 2020
# Generated by iptables-save v1.4.21 on Fri Jun 19 13:26:29 2020
*mangle
:PREROUTING ACCEPT [11472153:10218071803]
:INPUT ACCEPT [23466:2930313]
:FORWARD ACCEPT [11442622:10214316828]
:OUTPUT ACCEPT [16510:22564603]
:POSTROUTING ACCEPT [11460283:10236985509]
:MINIUPNPD - [0:0]
:UBNT_FW_MSS_CLAMP - [0:0]
:UBNT_FW_MSS_CLAMP_I - [0:0]
:UBNT_QOS_FW_IN_HOOK - [0:0]
:UBNT_QOS_FW_OUT_HOOK - [0:0]
:VYATTA_FW_IN_HOOK - [0:0]
:VYATTA_FW_OUT_HOOK - [0:0]
[11472153:10218071803] -A PREROUTING -j MINIUPNPD
[11472153:10218071803] -A PREROUTING -j VYATTA_FW_IN_HOOK
[11472153:10218071803] -A PREROUTING -j UBNT_FW_MSS_CLAMP_I
[11442622:10214316828] -A FORWARD -j UBNT_QOS_FW_IN_HOOK
[11460283:10236985509] -A POSTROUTING -j VYATTA_FW_OUT_HOOK
[11460283:10236985509] -A POSTROUTING -j UBNT_FW_MSS_CLAMP
[11460283:10236985509] -A POSTROUTING -j UBNT_QOS_FW_OUT_HOOK
[4224:266224] -A UBNT_FW_MSS_CLAMP -o pppoe+ -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1412
[0:0] -A UBNT_FW_MSS_CLAMP -o pptp+ -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1412
[0:0] -A UBNT_FW_MSS_CLAMP -o tun+ -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1412
[0:0] -A UBNT_FW_MSS_CLAMP -o vti+ -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1412
[3725:212084] -A UBNT_FW_MSS_CLAMP_I -i pppoe+ -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1412
[0:0] -A UBNT_FW_MSS_CLAMP_I -i pptp+ -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1412
[0:0] -A UBNT_FW_MSS_CLAMP_I -i tun+ -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1412
[0:0] -A UBNT_FW_MSS_CLAMP_I -i vti+ -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1412
COMMIT
# Completed on Fri Jun 19 13:26:29 2020
# Generated by iptables-save v1.4.21 on Fri Jun 19 13:26:29 2020
*raw
:PREROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:FW_CONNTRACK - [0:0]
:NAT_CONNTRACK - [0:0]
:PFOR_CONNTRACK - [0:0]
:QOS_CONNTRACK - [0:0]
:UBNT_CT_BRIDGE - [0:0]
:UBNT_PREROUTING_HOOK - [0:0]
:VYATTA_CT_IGNORE - [0:0]
:VYATTA_CT_OUTPUT_HOOK - [0:0]
:VYATTA_CT_PREROUTING_HOOK - [0:0]
[11472153:10218071803] -A PREROUTING -j UBNT_PREROUTING_HOOK
[11472153:10218071803] -A PREROUTING -j VYATTA_CT_IGNORE
[11472153:10218071803] -A PREROUTING -j UBNT_CT_BRIDGE
[11472153:10218071803] -A PREROUTING -j VYATTA_CT_PREROUTING_HOOK
[11472153:10218071803] -A PREROUTING -j NAT_CONNTRACK
[0:0] -A PREROUTING -j PFOR_CONNTRACK
[0:0] -A PREROUTING -j FW_CONNTRACK
[0:0] -A PREROUTING -j QOS_CONNTRACK
[0:0] -A PREROUTING -j NOTRACK
[16510:22564603] -A OUTPUT -j VYATTA_CT_IGNORE
[16510:22564603] -A OUTPUT -j VYATTA_CT_OUTPUT_HOOK
[16510:22564603] -A OUTPUT -j NAT_CONNTRACK
[0:0] -A OUTPUT -j PFOR_CONNTRACK
[0:0] -A OUTPUT -j FW_CONNTRACK
[0:0] -A OUTPUT -j QOS_CONNTRACK
[0:0] -A OUTPUT -j NOTRACK
[0:0] -A FW_CONNTRACK -j ACCEPT
[11488663:10240636406] -A NAT_CONNTRACK -j ACCEPT
[0:0] -A PFOR_CONNTRACK -j ACCEPT
[0:0] -A QOS_CONNTRACK -j RETURN
[11488663:10240636406] -A VYATTA_CT_IGNORE -j RETURN
[16510:22564603] -A VYATTA_CT_OUTPUT_HOOK -j RETURN
[11472153:10218071803] -A VYATTA_CT_PREROUTING_HOOK -j RETURN
COMMIT
# Completed on Fri Jun 19 13:26:29 2020
# Generated by iptables-save v1.4.21 on Fri Jun 19 13:26:29 2020
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:Drop - [0:0]
:Drop2 - [0:0]
:MINIUPNPD - [0:0]
:UBNT_FW_IN_SUSPEND_HOOK - [0:0]
:UBNT_PFOR_FW_HOOK - [0:0]
:UBNT_PFOR_FW_RULES - [0:0]
:UBNT_VPN_IPSEC_FW_HOOK - [0:0]
:UBNT_VPN_IPSEC_FW_IN_HOOK - [0:0]
:VYATTA_FW_IN_HOOK - [0:0]
:VYATTA_FW_LOCAL_HOOK - [0:0]
:VYATTA_FW_OUT_HOOK - [0:0]
:VYATTA_POST_FW_FWD_HOOK - [0:0]
:VYATTA_POST_FW_IN_HOOK - [0:0]
:VYATTA_POST_FW_OUT_HOOK - [0:0]
:WAN_IN - [0:0]
:WAN_LOCAL - [0:0]
[23466:2930313] -A INPUT -j UBNT_VPN_IPSEC_FW_HOOK
[23466:2930313] -A INPUT -j VYATTA_FW_LOCAL_HOOK
[18883:2509420] -A INPUT -j VYATTA_POST_FW_IN_HOOK
[11442622:10214316828] -A FORWARD -j MINIUPNPD
[11442622:10214316828] -A FORWARD -j UBNT_VPN_IPSEC_FW_IN_HOOK
[11442622:10214316828] -A FORWARD -j UBNT_PFOR_FW_HOOK
[11442622:10214316828] -A FORWARD -j UBNT_FW_IN_SUSPEND_HOOK
[11442622:10214316828] -A FORWARD -j VYATTA_FW_IN_HOOK
[11442622:10214316828] -A FORWARD -j VYATTA_FW_OUT_HOOK
[11442622:10214316828] -A FORWARD -j VYATTA_POST_FW_FWD_HOOK
[16510:22564603] -A OUTPUT -j VYATTA_POST_FW_OUT_HOOK
[3972:342176] -A Drop -m comment --comment "Drop-10000 default-action drop" -j DROP
[33:1457] -A Drop2 -m comment --comment "Drop2-10000 default-action drop" -j DROP
[93117:82205866] -A UBNT_PFOR_FW_HOOK -i pppoe0 -j UBNT_PFOR_FW_RULES
[0:0] -A UBNT_PFOR_FW_RULES -d 192.168.20.2/32 -p tcp -m tcp --dport 5060 -j ACCEPT
[0:0] -A UBNT_PFOR_FW_RULES -d 192.168.20.2/32 -p udp -m udp --dport 5060 -j ACCEPT
[0:0] -A UBNT_PFOR_FW_RULES -d 192.168.20.2/32 -p tcp -m tcp --dport 8080 -j ACCEPT
[0:0] -A UBNT_PFOR_FW_RULES -d 192.168.20.2/32 -p udp -m udp --dport 8080 -j ACCEPT
[7963943:9749624118] -A VYATTA_FW_IN_HOOK -i pppoe0 -j WAN_IN
[1579:912712] -A VYATTA_FW_LOCAL_HOOK -i pppoe0 -j WAN_LOCAL
[3803:318817] -A VYATTA_FW_LOCAL_HOOK -i switch0.10 -j Drop
[33:1457] -A VYATTA_FW_LOCAL_HOOK -i switch0.20 -j Drop2
[11442622:10214316828] -A VYATTA_POST_FW_FWD_HOOK -j ACCEPT
[18883:2509420] -A VYATTA_POST_FW_IN_HOOK -j ACCEPT
[16510:22564603] -A VYATTA_POST_FW_OUT_HOOK -j ACCEPT
[7963943:9749624118] -A WAN_IN -m comment --comment WAN_IN-10 -m state --state RELATED,ESTABLISHED -j RETURN
[0:0] -A WAN_IN -m comment --comment WAN_IN-20 -m state --state INVALID -j DROP
[0:0] -A WAN_IN -m comment --comment "WAN_IN-10000 default-action drop" -j DROP
[1023:836666] -A WAN_LOCAL -m comment --comment WAN_LOCAL-10 -m state --state RELATED,ESTABLISHED -j RETURN
[84:4626] -A WAN_LOCAL -m comment --comment WAN_LOCAL-20 -m state --state INVALID -j DROP
[472:71420] -A WAN_LOCAL -m comment --comment "WAN_LOCAL-10000 default-action drop" -j DROP
COMMIT
# Completed on Fri Jun 19 13:26:29 2020

Looks like vlan 30 not 40?

I have never used an Edgerouter with a builtin switch, so that might be what’s causing issues.

Potentially a dumb question… are all voip protocols udp/tcp?

It’s 30 because I changed VLAN IDs for an alt config where eth1 is on a native VLAN.

Previous working firewall rules had both TCP and UDP set, and it worked.

Looked at iptables on my phone, it seems fishy that SNAT applies irrespective of which interface the packets come in.

Try disabling hairpin nat - it’s not like you’ll have other stuff on that vlan.

DNAT seems setup ok:

-A PREROUTING -j UBNT_PFOR_DNAT_HOOK
...
[0:0] -A UBNT_PFOR_DNAT_HOOK -i pppoe0 -m set --match-set ADDRv4_pppoe0 dst -j UBNT_PFOR_DNAT_RULES
[0:0] -A UBNT_PFOR_DNAT_HOOK -i switch0.30 -m set --match-set ADDRv4_pppoe0 dst -j UBNT_PFOR_DNAT_RULES
[0:0] -A UBNT_PFOR_DNAT_RULES -p tcp -m tcp --dport 5060 -j DNAT --to-destination 192.168.20.2:5060
[0:0] -A UBNT_PFOR_DNAT_RULES -p udp -m udp --dport 5060 -j DNAT --to-destination 192.168.20.2:5060
[0:0] -A UBNT_PFOR_DNAT_RULES -p tcp -m tcp --dport 8080 -j DNAT --to-destination 192.168.20.2:8080
[0:0] -A UBNT_PFOR_DNAT_RULES -p udp -m udp --dport 8080 -j DNAT --to-destination 192.168.20.2:8080

It seems like Auto Firewall is doing it’s job:

-A FORWARD -j UBNT_PFOR_FW_HOOK
...
-A UBNT_PFOR_FW_HOOK -i pppoe0 -j UBNT_PFOR_FW_RULES
[0:0] -A UBNT_PFOR_FW_RULES -d 192.168.20.2/32 -p tcp -m tcp --dport 5060 -j ACCEPT
[0:0] -A UBNT_PFOR_FW_RULES -d 192.168.20.2/32 -p udp -m udp --dport 5060 -j ACCEPT
[0:0] -A UBNT_PFOR_FW_RULES -d 192.168.20.2/32 -p tcp -m tcp --dport 8080 -j ACCEPT
[0:0] -A UBNT_PFOR_FW_RULES -d 192.168.20.2/32 -p udp -m udp --dport 8080 -j ACCEPT

I’ll fire up a text editor and try to remove all the junk from rest of the rules, I just can’t do that on my phone. The only thing I can see here is SNAT looks strange and unnecessary (artifact of hairpin enabled).

I wonder if phone is using UPNP that’s handled before but DNAT rules and port forwarding its own ports it needs over to its old ip address, and when you plug it into eth4 it can’t do stuff anymore. But you said you have UPNP disabled, maybe that’s not a thing then, but there’s definitely counters next to the rules indicating something in there matched but no actual rules in support file.


I see you have smartqueue enabled, and upload set to 50Mbps, how is that working for you? (I’d expect maybe 45-47.5 in case of 50Mbps upload from ISP to be on the safe side)


Edit: why on earth would input from switch 0.30 be going through DNAT, it should only by stuff coming from pppoe0. Are they in the same WAN zone or something

It’s how the auto firewall is setup. And I have disabled hairpin NAT before without any meaningful results. Is it just because it’s unfamilar with a LAN interface as a VLAN? That it only works when the LAN interface is switch0?

The other thing I could try is to put my trusted network requiring one more hop in an isolated VLAN to get to the internet, and make my untrusted network native VLAN on eth4, so my trusted network won’t be able to manage the EdgeRouter by design.