1:1Nat, two public IPs for one server with one nic
-
@viragomann they are actually not routed correctly.
post-up iptables -t nat -A PREROUTING -i enp0s31f6 -p tcp -d 94.x.x.A -m multiport ! --dport 22,8006,179 -j DNAT --to 10.10.10.2 post-up iptables -t nat -A PREROUTING -i enp0s31f6 -p udp -d 94.x.x.A -m multiport ! --dport 5405:5412,4789 -j DNAT --to 10.10.10.2 post-up iptables -t nat -A PREROUTING -i enp0s31f6 -d 94.x.x.B -j DNAT --to 10.10.10.3
The prerouting here is not able to distinct between
-d 94.x.x.A
and-d 94.x.x.B
and I don't know why. It always uses the rule with-d 94.x.x.A
and routes to--to 10.10.10.2
. Even if I manually typehttps://94.x.x.B
into the browser, I end up at the traefik proxy which means the first rule of these three was used.But for me the overview looks fine. Do you see anything, am I missing anything iptables specific?
iptables -t nat -L -n
Chain PREROUTING (policy ACCEPT) target prot opt source destination DNAT tcp -- 0.0.0.0/0 94.x.x.A multiport dports !22,8006,179 to:10.10.10.2 DNAT udp -- 0.0.0.0/0 94.x.x.A multiport dports !5405:5412,4789 to:10.10.10.2 DNAT all -- 0.0.0.0/0 94.x.x.B to:10.10.10.3 Chain INPUT (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination Chain POSTROUTING (policy ACCEPT) target prot opt source destination SNAT all -- 10.10.10.2 0.0.0.0/0 to:94.x.x.A SNAT all -- 10.10.10.3 0.0.0.0/0 to:94.x.x.B
-
@leonidas-o said in 1:1Nat, two public IPs for one server with one nic:
Even if I manually type https://94.x.x.A into the browser
You mean https://94.x.x.B, I guess.
Did you investigate this with packet capture on pfSense, or is this your assumption of what you see?
-
@viragomann oh yes, I meant Ip address B. Corrected that typo.
No haven't checked that with packet capture as I ended Up at a "This connection is not private" site and when clicked on "view certificate" it shows "TRAEFIK DEFAULT CERT - self signed cert". Therefore it's pretty clear that it's traefik. If it would work either the 1:1 Nat works and the bbb service should be shown or simply timing out as firewall rules are maybe missing or whatever, but not traefik self signed cert.
I can still do a packet capture, maybe it reveals something helpful.
-
@leonidas-o said in 1:1Nat, two public IPs for one server with one nic:
Therefore it's pretty clear that it's traefik
Agree, you see that traefik is responding. But you don't determine, why the packets go to traefik.
So is it on Proxmox or on pfSense?? -
@viragomann I got the pfsense virtualised, so the entry point is proxmox (the Proxmox/Debian network/interfaces file controls to redirect "almost" everything to pfsense). Therefore I have to solve that iptables prerouting issue first. Right now, it doesn't make any sense to me, why it is ignoring the destination IPs.
-
@leonidas-o said in 1:1Nat, two public IPs for one server with one nic:
Therefore I have to solve that iptables prerouting issue first.
Both of your public IPs go to the same pfSense interface, even each to a specific private IP, assumed it works properly.
But how did you determine, that Proxmox does the forwarding wrong without knowing which IP pfSense is seeing?You can sniff the traffic either on pfSense WAN or on the Proxmox bridge, but without doing this you're standing in the dark at all.
-
@viragomann I have a port forwarding for traefik:
Interface: WAN Proto: TCP/UDP Source addr: * Source ports: * Dest address: WAN address Dest ports: 443 (HTTPS) NAT IP: 10.1.1.32 NAT ports: 4430
Is uses "WAN address" (10.10.10.2) for destination address. I Don't have any port forwardings for the virtual IP (10.10.10.3), only the 1:1 Nat setting.
So, I would expect, that it forwards only the 10.10.10.2 traefik and would distinguish between the real Wan interface and the virtual IP. If it can't do that, how would you ever be able to achieve what I want?
-
@leonidas-o
I know this rule, but I don't know your others.
I's better assure of something than do some assumptions of it. But this seems to feckless here. -
@viragomann yes sure, I agree with the assumptions point.
Do I actually need port forwardings even though when having a 1:1 NAT entry setup or should it be doing something like that?I'm asking because I think I have something here. Your statement actually made me think:
"Both of your public IPs go to the same pfSense interface..."
I was wondering If I maybe need a port forwarding rule which is in front of the that mentioned traefik port forwarding. My thoughts were like, what if dest address as "WAN address" catches everything, so like all virtual IPs which belong to that WAN address. Would actually make sense, kind of.
And if you want to distinguish, you have to place a port forwarding for each of the VIPs (it is even available via a dropdown) in front of it like:Interface: WAN Proto: * Source addr: * Source ports: * Dest address: 10.10.10.3 Dest ports: * NAT IP: 10.1.1.57 NAT ports: *
I refreshed the page with
https://94.x.x.B
and was not seeing the traefik self signed cert, but the BBB services self signed cert. I think that's it, it could be that you are a true hero good sir.But what is the 1:1 Nat in the end doing If still need port forwardings and firewall rules?
-
@leonidas-o
No, the NAT 1:1 rule does the port forwarding, it doesn't need an additional rule for this if set properly.An 1:1 rule on WAN forward packets destined to, say 10.10.10.3, to 10.1.1.57 and translates the source IP in upstream packets from 10.1.1.57 to 10.10.10.3.
If your rule doesn't work recheck the settings.
-
@leonidas-o said in 1:1Nat, two public IPs for one server with one nic:
still need port forwardings and firewall rules
https://docs.netgate.com/pfsense/en/latest/nat/1-1.html
"All traffic initiated on the Internet destined for the specified public IP address on the mapping will be translated to the private IP address, then evaluated against the firewall ruleset on the inbound WAN interface. If matching traffic is permitted by the firewall rules to a target of the private IP address, it will be passed to the internal host." -
@viragomann @steveits thanks guys, yeah I'm starting to get a feeling for its behaviour. The most important part for me actually is: https://docs.netgate.com/pfsense/en/latest/nat/port-forwards.html#port-forwarding-and-1-1-nat
"Port forwards also take precedence over 1:1 NAT. If a port forward is defined on one external IP address forwarding a port to a host, and a 1:1 NAT entry is also defined on the same external IP address forwarding everything into a different host, then the port forward remains active and continues forwarding to the original host."
"Port forwards take precedence over 1:1 NAT", so as we found out that "WAN Address" matches the VIPS as well, I will have to change my port forward rules to just use the original WAN address 10.10.10.2 and ignore VIP (10.10.10.3).
I have to work on the BBB docker deployment atm, it is horrible to be honest, before I can test everything out. Will report back asap, but I think that's the key actually to get all working.
-
Couldn't make BigBlueButton work behind pfsense/opnsense with 1:1 NAT + Reflection etc., so I gave up on that approach. I still found a solution assigning the second public IP directly to the BBB VM, which I documented here: https://serverfault.com/questions/1121061/assigned-second-public-ip-to-vm-from-outside-not-reachable/1121266#1121266