Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- After much Effort and some help from Claude i managed to get the L2Tp Traffic Working
- Here are the instructions.
- =Step 1: Modify L2TP Client Configuration
- First, modify your L2TP client settings:
- Go to Interfaces and double-click your L2TP client interface
- Uncheck "Add Default Route" - this is crucial to prevent all traffic from using the VPN
- Click OK to save
- Step 2: Create a Routing Table for VPN Traffic
- Go to Routing → Tables
- Click + to add a new table
- Set:
- Name: vpn-table
- FIB: Check this box
- Click OK
- Step 3: Add Policy-Based Routing
- Go to IP → Routes
- Click + to add a new route
- Configure:
- Dst. Address: 0.0.0.0/0 (default route for VPN traffic)
- Gateway: [This will be the gateway IP you receive from the L2TP connection - check your L2TP interface for the remote address]
- Routing Table: vpn-table
- Distance: 1
- Click OK
- Step 4: Create Routing Rules
- Go to Routing → Rules
- Click + to add a new rule
- Configure:
- Src. Address: x.x.x.x/29
- Action: lookup-only-in-table
- Table: vpn-table
- Click OK
- Step 5: Add Mangle Rules for Traffic Marking (Alternative Method)
- If the routing rules don't work as expected, use mangle rules:
- Go to IP → Firewall → Mangle
- Click + to add a new rule
- General tab:
- Chain: prerouting
- Src. Address: x.x.x.x/29
- Action tab:
- Action: mark-routing
- New Routing Mark: vpn-traffic
- Passthrough: Check this
- Click OK
- Step 6: Create Route for Marked Traffic
- Go to IP → Routes
- Click + to add a new route
- Configure:
- Dst. Address: 0.0.0.0/0
- Gateway: [L2TP interface name, e.g., "Work-VPN"]
- Routing Mark: vpn-traffic
- Distance: 1
- Click OK
- Step 7: Configure NAT (if needed)
- If devices in the 10.0.40.0/29 subnet need internet access through the VPN:
- Go to IP → Firewall → NAT
- Click + to add a new rule
- General tab:
- Chain: srcnat
- Src. Address: x.x.x.x/29
- Out. Interface: [Your L2TP interface name]
- Action tab:
- Action: masquerade
- Click OK
- Step 8: Verify Configuration
- Check IP → Routes to ensure your VPN route is present
- From a device in the x.x.x.x/29 subnet, test connectivity
- From a device outside this subnet, verify it uses the regular internet connection
- Use Tools → Traceroute to verify the path traffic takes
- Important Notes:
- Replace [Your L2TP interface name] with the actual name you gave your L2TP client (e.g., "Work-VPN")
- The gateway IP in the routes should be either the L2TP interface name or the remote gateway IP you receive from the connection
- You can check the L2TP interface details to see what remote address/gateway is assigned
- This configuration ensures that only traffic from the x.x.x.x/29 subnet will use the L2TP VPN, while all other traffic continues to use your regular internet connection.
- I'm going to try with just one ip from the x.x.x.x/29 instead of the Whole /29 subnet
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement