GRE over IPsec with VyOS and RouterOS
As part of my network learning process, I switched one of my router from RouterOS to VyOS.
Although RouterOS is really more convenient and friendly to use, I think in order to really learn how to use network equipment, using a command-line only equipment is a must. I got some experience with Cisco switch before (2960/3750), so setting up VyOS and get it running isn’t really that hard.
The goal here is to set GRE tunnel between my RouterOS and VyOS, and run the tunnel on IPsec. To create a GRE tunnel between VyOS and RouterOS is pretty simple, just a few click in RouterOS, and commands below in VyOS can get you up and running.
1 | set interfaces tunnel tun100 address '10.0.0.1/30' |
But setting up IPsec between VyOS and RouterOS is rather complicated. You’ll need to configure IPsec and GRE separately in RouterOS, and there are some settings in VyOS that needed to be set, and not one document I found online mentioned them, until now.
Let’s assume we got a network environment below.
1 | RouterOS: |
For VyOS part, refer to command below
1 | set interfaces tunnel tun0 encapsulation gre |
That’s the command we need in VyOS, it will create a tunnel interface, create ESP and IKE group, then configure site-to-site peer and set up authentication.
Now we can move to RouterOS.
For RouterOS, refer to steps below
- IP > IPsec > Proposals
- New Proposal
- Name:
- Auth. Algo.: sha256
- Enc. Algo.: aes256cbc
- Lifetime: 00:30:00
- PFS Group: modp1024
- Name:
- New Proposal
- IP > IPsec > Profiles
- New Profile
- Name:
- Hash Algo.: sha256
- PRF Algo.: auto
- Enc. Algo.: aes256
- DH Group: modp1024
- Don’t edit other options
- Name:
- New Profile
- IP > IPsec > Peers
- New Peer
- Name:
- Address: 2.2.2.2
- Local Address: 1.1.1.1
- Profile:
- Don’t edit other options
- Name:
- New Peer
- IP > IPsec > Identities
- New Identity
- Peer:
- Auth. Method: pre shared key
- Secret: myipsecpresharedsecret
- My ID Type: address
- My ID: 10.0.0.1
- Remote ID Type: fqdn
- Remote ID: 10.0.0.2
- Match By: remote id
- Don’t edit other options
- Peer:
- New Identity
- IP > IPsec > Policies
- New Policy
- Peer:
- Tunnel: yes
- Src. Address: 10.0.0.1
- Dst. Address: 10.0.0.2
- Protocol: 255
- Action
- Proposal:
- Proposal:
- Don’t edit other options
- Peer:
- New Policy
After configuration, check IPsec status by checking Status
in the policy you just created.
If PH2 State
is established
, then IPsec worked.
Now you can create a new GRE tunnel in RouterOS, and create a new address in IP, like
1 | Address: 10.0.0.1/30, Network: 10.0.0.0, Interface: <GRE_INTERFACE> |
You should got a GRE over IPsec tunnel between VyOS and RouterOS now, if not, try enable ipsec process logging in RouterOS, it can show some useful information for debugging.