1

(cross-posting from ServerFault, as this forum seems more appropriate for this question)

I have a scenario where we will be using a Mac to stream video content to an RTMP server. This RMTP service provides 2 ingest URLs so that you can upload the same video content twice and have redundancy in case your connection has a problem. However, both RTMP ingest URLs are the same, the only difference is their TCP port number, for example:

{
    "rtmp1": "rtmp://xxx.xxx.com:1935/id1",
    "rtmp2": "rtmp://xxx.xxx.com:1936/id1"
}

What I want to do is the following:

  • Have two network interfaces on the Mac (each using different network providers, for redundancy).
  • Have the OS X use 1 of those network interfaces to stream content to the first URL, and use the second network interface to stream to the second URL

I don't know how to split traffic to the same host (but different port) through different network interfaces in OS X. I have found these links (here, and here), but they solve different problems.

Does anyone know how to use iptables, nat, hosts, or any combination of services within OS X to achieve this split I am looking for?

UPDATE

After some research, I am convinced this should be achievable with PF. I have created the following rule set and enabled pf with this rule loaded. However, all traffic is blocked and the actual rtmp traffic that should be allowed outbound and properly routed is also blocked. Seems like I have a syntax problem in having PF match the RTMP traffic with the rule I configured:

ext_if1 = "en0"
ext_if1_gwt = "192.168.1.1"
ext_if2 = "en5"
ext_if2_gwt = "172.168.1.1"

rtmp_ip = "104.46.55.96"
rtmp_port1 = "1935"
rtmp_port2 = "1936"

pass in on $ext-if1 route-to ($ext_if1 $ext_if1_gwt) proto tcp from any to $rtmp_ip port $rtmp_port1
pass in on $ext-if1 route-to ($ext_if2 $ext_if2_gwt) proto tcp from any to $rtmp_ip port $rtmp_port2

pass in on $ext-if2 route-to ($ext_if1 $ext_if1_gwt) proto tcp from any to $rtmp_ip port $rtmp_port1
pass in on $ext-if2 route-to ($ext_if2 $ext_if2_gwt) proto tcp from any to $rtmp_ip port $rtmp_port2

block out
9
  • You do not say the only thing that really matters: is at least one of the machines you want to connect to on your LAN? If so, it can be done, otherwise it cannot. Jul 7, 2015 at 10:20
  • @MariusMatutiae: $rtmp_ip is an internet-facing server. I am trying to use the route-to configuration to instruct the mac to route traffic to that host through either one of the 2 interfaces the mac has, based on the destination port. AFAIK, route-to should support routing to external hosts. Thanks. Jul 7, 2015 at 10:25
  • It certainly does. What it does not support is to have two default gateways simultaneously. If you have several default routes with the same metric, the kernel will simply pick the first one in the list, that's all. Jul 7, 2015 at 10:28
  • @MariusMatutiae, yes, that's clear. The rule that I want to set is simple: all outbound TCP traffic for host1 on port 1935, use interface 1 (gateway 1). all outbound TCP traffic for host1 on port 1936, use interface 2 (gateway). All other outbound traffic, use the default gateway (in the questions above, I am blocking all out, but that is just to test whether pf is kicking into effect or not, that default deny rule is not required). Do you have a suggestion on how to write such rule(s)? Thanks. Jul 7, 2015 at 10:33
  • things will not work correctly if you have two gateways pointing to the same set of addresses. that means that generally speaking, all traffic traveling to a specific IP address will use the same gateway, and thus will come out the same NIC. thats just the way the IP stack handles routing decisions. I suppose you could put both NICs in differant networks, and use two routers, and bind instances of your program to one or the other NIC, but that seems like a lot of work and additional cost, that doesn't seem to gain you much. Jul 7, 2015 at 11:45

0

You must log in to answer this question.

Browse other questions tagged .