Skip to content

Instantly share code, notes, and snippets.

@mistermocha
Created March 18, 2025 17:07
Show Gist options
  • Save mistermocha/5eb6f7258714d8d344a73069ea37b6be to your computer and use it in GitHub Desktop.
Save mistermocha/5eb6f7258714d8d344a73069ea37b6be to your computer and use it in GitHub Desktop.
Does your VPN share a CIDR with your LAN and not use the right gateway? This ansible playbook works to resolve on OSX.
---
- name: Add a network route
hosts: localhost
become: yes
tasks:
- name: Drop any existing network route
shell: route -n delete -net 10 {{ ansible_default_ipv4.network }}
- name: Add a network route
shell: route -n add -net 10 {{ ansible_default_ipv4.network }}
- name: Capture the route to inspect for the new gateway
shell: route -n get -net 10 | grep gateway
register: route
- name: Check that the route was added
debug:
msg: "Route was added: {{ route.stdout }}"
when:
- route.stdout.find( ansible_default_ipv4.gateway )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment