WgServerforWindows icon indicating copy to clipboard operation
WgServerforWindows copied to clipboard

NAT routing not enabled on restart

Open Poonming opened this issue 2 years ago • 11 comments

Whenever I restart PC, WGserver autamatically starts but NAT is not enabled. I RDP with openvpn, enable NAT routing on WGserver and everything back to working order till next restart. Any suggestions please?

Poonming avatar Apr 12 '23 23:04 Poonming

Hi @Poonming, NAT Routing is supposed to be started automatically on boot by a task.

First, verify that the task is enabled in WS4W. It will say "Disable" if it's enabled.

image

Then open Task Scheduler and look for this task.

image

Verify that it's not Disabled there either. Look at the Last Run Time and Last Run Result. See if it's actually running on boot. See if it completed successfully.

If you have a network adapter that's slow to load on boot, for example, you can try playing around with the task delay in WS4W. Note that you have to disable/re-enable any tasks after changing this.

image

You can also set a delay manually in the Task Scheduler.

image

Hopefully that helps!

micahmo avatar Apr 13 '23 11:04 micahmo

通过UI操作 setting - set boot task delay 配置延迟1min启动无效,观察关联的计划任务并未同步启用和修改Trigger的Delay task for的数值。但是通过手动修改计划任务后,一切都正常工作了。🎉

shigella520 avatar May 05 '23 03:05 shigella520

[Google Translate] Setting - set boot task delay through the UI to configure a delay of 1 minute to start is invalid. Observe that the associated scheduled tasks are not enabled and modified simultaneously and the value of the Trigger's Delay task for is not changed.

@shigella520 Remember that you must disable and re-enable the tasks in order for the boot delay to take effect.

I'm glad changing it manually worked for you though!

micahmo avatar May 05 '23 16:05 micahmo

Over the course of the last ~2 months i encountered it twice that probably after a windows update / reboot, clients could still connect to the server, but not ping the server / server network anymore. It turned out the problem was WS4W UI showed "NAT Routing" disabled, after manually enabling it all worked fine.

I took a look at the planned tasks and i saw that "WS4W Set NetIPAddress" was disabled, activating it and running it manually enabled NAT Routing in the UI. Any idea what could be disabling the task?

igpit avatar Jul 10 '23 20:07 igpit

Any idea what could be disabling the task?

That's weird! I haven't seen Windows Tasks get disabled on their own. Out of curiosity, did WS4W also detect that they were disabled? This button would say "Enable".

image

micahmo avatar Jul 11 '23 02:07 micahmo

Hi All,

No luck. I have played with it for a few months and in the end, I gave up. I connect to PC via open VPN, then start up the wireguard server these days.

From: Micah Morrison @.> Sent: Tuesday, 11 July 2023 12:34 PM To: micahmo/WgServerforWindows @.> Cc: Poonming @.>; Mention @. @.***> Subject: Re: [micahmo/WgServerforWindows] NAT routing not enabled on restart (Issue #108)

Any idea what could be disabling the task?

That's weird! I haven't seen Windows Tasks get disabled on their own. Out of curiosity, did WS4W also detect that they were disabled? This button would say "Enable".

https://user-images.githubusercontent.com/7417301/252534863-4493a48b-e203-4978-8311-4fdc624ac3a1.png

— Reply to this email directly, view it on GitHub https://github.com/micahmo/WgServerforWindows/issues/108#issuecomment-1630011684 , or unsubscribe https://github.com/notifications/unsubscribe-auth/A7EQP6BHGTEZANBYBVVT25DXPS3RHANCNFSM6AAAAAAW4KKWRM . You are receiving this because you were mentioned. https://github.com/notifications/beacon/A7EQP6GPFMIDYJOEI2CFB3LXPS3RHA5CNFSM6AAAAAAW4KKWROWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTBFAASI.gif Message ID: @.*** @.***> >

-- This email has been checked for viruses by Avast antivirus software. www.avast.com

Poonming avatar Jul 11 '23 03:07 Poonming

That's weird! I haven't seen Windows Tasks get disabled on their own. Out of curiosity, did WS4W also detect that they were disabled? This button would say "Enable".

No idea, i suppose i have to wait for it to magically happen again.

I suppose you could run a "watchdog", check once per hour if the task is enabled, state of "NAT Routing", because in the UI the correct state is always shown. But if you run the task manually in the background, the already loaded UI does not pick up the change, you need to restart the UI. maybe add a check button for the current state.

igpit avatar Jul 11 '23 11:07 igpit

I suppose you could run a "watchdog"

I have kind of resisted running any kind of Windows service. I always liked the idea that WS4W was completely stateless. But that would eliminate the need for Windows Tasks and help to make sure things are always right. We'll see.

the already loaded UI does not pick up the change, you need to restart the UI

I will say you can press F5 to reload the UI. 😊

micahmo avatar Jul 11 '23 12:07 micahmo

Greetings, I had the above mentioned problem on Windows Server 2022 as well, I solved it by creating a custom task, I write it so that others can also solve the problem, in order: New-NetIPAddress -InterfaceIndex (x) -IPAddress x.x.x.x -PrefixLength 24 New-NetNat -Name wg_server_nat -InternalIPInterfaceAddressPrefix x.x.x.x/24

beke87 avatar Sep 04 '23 16:09 beke87

Hi @beke87, thanks for the suggestion! That is what the built-in Windows Task is supposed to do, but others had issues with it getting randomly disabled and/or occurring too soon (which is why the boot task delay option was added).

micahmo avatar Sep 05 '23 14:09 micahmo

It looks like the "WS4W Set NetIPAddress" task should be executed only after the "WS4W Private Network" has been finished. As soon as the task settings are managed by the WgServerforWindows itself, I creaded the copy of "WS4W Set NetIPAddress" task at set the startup time 15 seconds later the "WS4W Private Network" task and now the NAT routing is always green after sysrtem restart.

alexkmbk avatar Jul 26 '24 04:07 alexkmbk