Juniper Network Connect VPN client messes around with my hosts file [edit]

Somehow, we got my company’s Cisco Juniper VPN to work on my Mac (we just needed to create an appropriate policy for Macs, not that complicated). [Edit: I got the brand wrong, sorry!]

But while I was able to connect from the company’s internal network (as a test, as it’s obviously not very useful), I didn’t manage to connect from outside. My company Windows machine could, but not my Mac.

I’ve finally tracked down the cause (after a lot of irrelevant debugging attempts, investigating our firewall and doing various DNS lookups): actually, Network Connect writes to /private/etc/hosts and hard-codes there the IP address of the VPN machine, after you successfully connect. And of course, after I’d connected (as a test) to the VPN over the internal network, the IP address it wrote there was the internal IP. This subsequently prevented it from connecting over a public network.

This is a bit of a note to self, in case I run into this problem again and forget the fix. (Of course it would be nice if the Cisco software didn’t do such a dirty thing in the first place, or at least cleaned up after itself, but that might be a lot to ask for.)

This entry was posted in Miscellaneous. Bookmark the permalink.

4 Responses to Juniper Network Connect VPN client messes around with my hosts file [edit]

  1. Lye says:

    So how did you fix it?

    • Raphaël Mazoyer says:

      I didn’t :-(
      I just edit my hosts file manually once in a while. It doesn’t really break anything unless you connect from a network that has an unreachable IP for the VPN machine (for example, internal network then internet).
      It’s just messy…

      • Some Guy says:

        NC backs up /etc/hosts and /etc/resolv.conf to /etc/jnpr-nc-hosts.bak and /etc/jnpr-nc-resolv.conf respectively. It tries restore them once you disconnect, so all you need to do is to edit all four of them when things get nasty and you’re good to go :)

      • Raphaël Mazoyer says:

        Unfortunately, my Network Connect install does not restore the file (although it does create the backup). But thanks for the tip!