# Need VPN iproute help

**URL:** https://dietpi.com/forum/t/need-vpn-iproute-help/19089
**Category:** Troubleshooting
**Created:** [27 January 2024 15:31 UTC](https://dietpi.com/forum/t/need-vpn-iproute-help/19089 "2024-01-27T15:31:44Z")
**Posts on this page:** 7
**Page:** 2

<div class="post-metadata">

### Author: ![temp](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/t/f04885/32.png) [@temp](https://dietpi.com/forum/u/temp)
#### Post date: [30 January 2024 09:53 UTC](https://dietpi.com/forum/t/need-vpn-iproute-help/19089/21 "2024-01-30T09:53:51Z")

</div>

> [@trendy](#):
>
> systemctl

This is my command

```auto
sudo openvpn --daemon --log /var/log/openvpn.log --config /home/dietpi/vpn/config.ovpn

```

---

<div class="post-metadata">

### Author: ![trendy](https://dietpi.com/forum/user_avatar/dietpi.com/trendy/32/61_2.png) [@trendy](https://dietpi.com/forum/u/trendy)
#### Post date: [30 January 2024 10:51 UTC](https://dietpi.com/forum/t/need-vpn-iproute-help/19089/22 "2024-01-30T10:51:18Z")

</div>

> <https://askubuntu.com/questions/28733/how-do-i-run-a-script-after-openvpn-has-connected-successfully>

---

<div class="post-metadata">

### Author: ![temp](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/t/f04885/32.png) [@temp](https://dietpi.com/forum/u/temp)
#### Post date: [31 January 2024 06:34 UTC](https://dietpi.com/forum/t/need-vpn-iproute-help/19089/23 "2024-01-31T06:34:32Z")

</div>

Last question for this topic how do i delete these settings after closing my openvpn connection?

```auto
ip rule add from 192.168.42.0/24 lookup 42
ip route add default dev tun1 table 42
iptables -t nat -A POSTROUTING -s 192.168.42.0/24 -o tun1 -j MASQUERADE
iptables -t filter -A FORWARD -i wlan0 -o tun1 -j ACCEPT

```

Deleted via

```auto
ip rule delete from 192.168.42.0/24 lookup 42
ip route delete default dev tun1 table 42
iptables -t nat -D POSTROUTING -s 192.168.42.0/24 -o tun1 -j MASQUERADE
iptables -t filter -D FORWARD -i wlan0 -o tun1 -j ACCEPT

```

is this syntax correct?

---

<div class="post-metadata">

### Author: ![trendy](https://dietpi.com/forum/user_avatar/dietpi.com/trendy/32/61_2.png) [@trendy](https://dietpi.com/forum/u/trendy)
#### Post date: [31 January 2024 08:32 UTC](https://dietpi.com/forum/t/need-vpn-iproute-help/19089/24 "2024-01-31T08:32:36Z")

</div>

`del` instead of `delete` in `ip` commands.  
It also depends if you want to allow leaks from the wifi when the VPN is not connected.

---

<div class="post-metadata">

### Author: ![temp](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/t/f04885/32.png) [@temp](https://dietpi.com/forum/u/temp)
#### Post date: [31 January 2024 09:37 UTC](https://dietpi.com/forum/t/need-vpn-iproute-help/19089/25 "2024-01-31T09:37:24Z")

</div>

Hello like this?

```auto
ip rule del from 192.168.42.0/24 lookup 42
ip route del default dev tun1 table 42
iptables -t nat -D POSTROUTING -s 192.168.42.0/24 -o tun1 -j MASQUERADE
iptables -t filter -D FORWARD -i wlan0 -o tun1 -j ACCEPT

```

---

<div class="post-metadata">

### Author: ![trendy](https://dietpi.com/forum/user_avatar/dietpi.com/trendy/32/61_2.png) [@trendy](https://dietpi.com/forum/u/trendy)
#### Post date: [1 February 2024 10:45 UTC](https://dietpi.com/forum/t/need-vpn-iproute-help/19089/26 "2024-02-01T10:45:23Z")

</div>

Looks ok to me. Is there any error if you run it manually?

---

<div class="post-metadata">

### Author: ![system](https://dietpi.com/forum/uploads/default/original/1X/7e1021de2213860bce185915ce2c1786e56490ec.png) [@system](https://dietpi.com/forum/u/system)
#### Post date: [1 May 2024 10:45 UTC](https://dietpi.com/forum/t/need-vpn-iproute-help/19089/27 "2024-05-01T10:45:26Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

[Previous page](https://dietpi.com/forum/t/need-vpn-iproute-help/19089.md?page=1)
