MacOS – Making a program use a specific network interface

macbook promacoswifi

I would like my IRC client to only use a WiFi connection and all other programs to use WiFi or wired connections. This is because every time I plug in my Ethernet cable my IRC client automatically reconnects over wired, and then when I disconnect the cable it reconnects me on wireless.

So now I have multiple users logged into IRC.

Can I force an app to use a certain connection over the others? I like having the wired connection as the primary connection over wireless, because I do a lot of uploading and downloading and the NIC card gets hot sometimes. I guess I should of stated I'm using a MacBook Pro.

Best Answer

Add a static route for your irc server. For example I have 2 interfaces: wired (en0) and WiFi (en1) of which the wired one is the default. So if I get a route to a server, it will go through the default interface (see interface line in output) :

MacMini:~ root# netstat -rn | grep -i default
default            10.0.0.1           UGSc          198       10     en0
default            172.20.10.1        UGScI           0        0     en1

MacMini:~ root# route get tyr.be
   route to: squarespace.com
destination: squarespace.com
    gateway: 10.0.0.1
  interface: en0
      flags: <UP,GATEWAY,HOST,DONE,WASCLONED,IFSCOPE,IFREF>
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
       0         0         0         0         0         0      1500         0

But if I add a static route through the WiFi interface en1 however :

MacMini:~ root# route add 65.39.205.54/32 172.20.10.1
add net 65.39.205.54: gateway 172.20.10.1

MacMini:~ root# netstat -rn | grep -i 65.39.205.54
65.39.205.54/32    172.20.10.1        UGSc            1        0     en1

MacMini:~ root# route get tyr.be
   route to: squarespace.com
destination: squarespace.com
  interface: en1
      flags: <UP,HOST,DONE,LLINFO,STATIC>
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
       0         0         0         0         0         0      1500         0

The route will disappear every time you reboot. To make it permanent you would have to create a script launched as a startup item or a custom launchd script.