TV connected to vpn, connected but no ping. Because?

Good afternoon everyone. Comment that I am not one of the people who contacts the forums for anything, but I have spent more than 30 hours reading and searching for information, and I cannot understand the reason for this problem. I tell you:

I'll give you my configuration first:

I have a main router connected by cable to the wan of an openwrt repeater (TP-Link Archer C50 v4)
The openwrt data is as follows:

Interface ap:
IP: 192.168.0.2
GW: 192.168.0.3
DNS: 1.1.1.1
DHCP: Disabled since the main router gives it to me

LAN interface:
IP: 192.168.1.1
GW: No need.
DNS: No need
DHCP: Activated, since I want openwrt to give me the IPs

WGO: With my personal VPN data.

On the main router I have this configuration in the routing section so that there is a connection between the different subnets:

Name: AP
Destination: 192.168.1.0/24
GW: 192.168.0.2

Wi-Fi signals:

A Home call with ap interface. This does not go through the VPN. Excellent connection.
A so-called TV with LAN interface. This does go through the VPN. Excellent connection.

1 Case:

I have a Samsung TV, which when I connect it to the home WiFi signal, both off and on, it receives a signal, can do ping and tracerouter, and I can turn it on with the Samsung app.

2 Case (Problem):

When I connect the TV to the TV signal, when the TV is on, it works fine, I can ping and tracerouter it, and the TV is connected to the VPN, because I browse the internet perfectly, and when I search for my IP it happens perfectly for the vpn.

But, when I turn off the TV, the TV is still connected to openwrt, because I see it, I also used other programs to make sure that it is connected, and if it is connected, but when I do a ping, tracerouter or use the Samsung app it is disconnected .

How is that possible? The openwrt and other app shows that it is connected, but when I try to turn it on with the app, or do a ping, it doesn't work. Is that logical?

The configuration of the firewall, ap, lan, wg0 must all be correct, because everything works well for me, both the interfaces that the VPN passes through and those that it does not pass through. I don't have any connection problems of any kind with either the main router or the openwrt, the only problem is when I turn off the TV and it is connected to the VPN signal.

Not even chatgpt knows why, hehe. Any ideas?

Thank you so much!

Can you be specific how you "see it" on the OpenWrt network? What specific status methods are you using herE?

What other programs are you using, and from where (what apps, what device, what network is that device on)?

Does the samsung app have the ability to turn on the tv when the tv is off? Do you know how this is achieved (i.e. local network / L2 / mdns access, or some cloud based system)?

Thanks for the quick reply.

From the openwrt menu itself, in the status/overview section, and also from network wireless, I see the connected devices.

But to make sure, I also see it, it is from an Android device, connected to the same Wi-Fi signal as the TV (TV Wi-Fi signal), and I use the fing app. In both cases, I see the TV connected, when it is off and connected to the WiFi TV signal.

As for the other thing you asked me, the device I use to turn on the TV is the Samsung smarThings app. And, it does have the ability to turn it on, because when I connect the TV to the other Wi-Fi network that does not go through the VPN, the AP Wi-Fi network, it turns it on and off without a problem.

And as for how the app connects, it has to be through the cloud, because when I'm away from my house, I can turn on the TV without a problem

It's something extremely strange, isn't it?

Thank you

So we need to determine if the smart things app works using a cloud service or a local connection. I suspect cloud, but let's run a test:

  1. Connect your TV to the non-VPN wifi.
  2. Connect your phone to that same wifi
  3. turn on/off the TV using the app to verify that it is working.
  4. Turn off wifi on your phone -- use your cellular connection
  5. try to turn on/off your tv using the phone again -- does it still work?

Yes, that's right, with the TV connected and the cell phone outside the VPN network, it works and turns on perfectly. But, when I connect it to the VPN network again, with the TV on it turns on perfectly, both on the same network and on the Wi-Fi network, but when I turn it off, it is still connected to the router, but disconnected from the app and the pings that it I do it inside the network and outside

I found a solution. Although it is not the best, it is practical. Because the TV off does not receive ping because it goes through the vpn but when it does not go through the vpn, if it receives ping, create a script every 60 seconds it checks a port, if it is off it stays in ap, but if the port is open switch to lan. And when it is on LAN, I set it to make a single ping to the LAN IP every half hour. If it responds, leave the interface on LAN, and do the ping again after half an hour, if it does not respond, switch to AP. I pass on the script I use, in case it helps anyone.

First script. The location I used is /etc/config/tv-wifi-changer.sh

#!/bin/sh

while true; do
     # Define the IP of the "lan" interface
     lan_ip="Define the IP of the lan interface" # I set it static

     # Define the IP of the "AP" interface
     ap_ip="Define the IP of the ap interface" # I made it static

     wifi_signal="Define the wifi signal to which you want to make the change" # With the uci show wireless command. It is the one that says .wifinet and the number

     # Get the network interface associated with the Wi-Fi signal
     wifi_interface=$(uci get wireless.$wifi_signal.network)

     # Function to change the interface to "AP" and restart the Wi-Fi signal
     change_to_ap_mode() {
         echo "Changing interface to 'AP' for signal $wifi_signal..."
         if ! uci set wireless.$wifi_signal.network="AP"; then
             echo "Error changing interface to 'AP'."
             exit 1
         fi
         uci commit wireless
         ifdown lan
         ifup lan
         echo "Interface changed to 'AP' for signal $wifi_signal and Wi-Fi signal reset."
     }

     # Function to change the interface to "lan" and restart the Wi-Fi signal
     change_to_lan_mode() {
         echo "Changing interface to 'lan' for signal $wifi_signal..."
         if ! uci set wireless.$wifi_signal.network="lan"; then
             echo "Error changing interface to 'lan'."
             exit 1
         fi
         uci commit wireless
         ifdown lan
         ifup lan
         echo "Interface changed to 'lan' for signal $wifi_signal and Wi-Fi signal reset."
     }

     # Function to ping the lan IP every 60 seconds
     ping_lan_ip() {
         while true; do
             if ping -c 1 -w 1 "$lan_ip" > /dev/null; then
                 echo "Successful ping to $lan_ip on interface 'lan'. No further pings will be performed."
                 break
             else
                 sleep 1800
             fi
         done
     }

     # Function to check the port used by the device
     check_port_that the device uses() {
         if nc -zv -w 5 "$ap_ip" to use device 2>&1 | grep -q "open"; then
             echo "Port x is open on interface 'AP' for signal $wifi_signal. Switching to interface 'lan'."
             change_to_lan_mode
             ping_lan_ip
         else
             echo "Port x is closed on interface 'AP' for signal $wifi_signal. It will remain on interface 'AP'."
         fi
     }

     # Check if the interface is "lan"
     if [ "$wifi_interface" = "lan" ]; then
         echo "Current interface is 'lan' for signal $wifi_signal. Checking IP..."
         if ping -c 1 -w 5 "$lan_ip" > /dev/null; then
             echo "Ping to $lan_ip was successful on interface 'lan'. The interface will not be changed."
         else
             echo "Ping to $lan_ip failed on interface 'lan'. Switching to interface 'AP'."
             change_to_ap_mode
         fi
     elif [ "$wifi_interface" = "AP" ]; then
         echo "Current interface is 'AP' for signal $wifi_signal. Checking port x..."
         check_port_x
     else
         echo "Interface is neither 'lan' nor 'AP' for signal $wifi_signal. No action will be taken."
     fi

     sleep 60
done

Then create /etc/init.d/tv-wifi-changer

Then in /etc/init.d/tv-wifi-changer (without any extension) and paste this:

#!/bin/sh /etc/rc.common

START=99
USE_PROCD=1

start_service() {
   procd_open_instance
   procd_set_param command "/etc/config/tv-wifi-changer.sh"
   procd_set_param respawn # This will restart the script if it terminates
   procd_set_param respawn_delay 5 # This waits 5 seconds before restarting
   procd_close_instance
}

To check that it is working:

service tv-wifi-changer status

ps | grep tv-wifi-changer

Check that you have the nc installed.

I did a load check and the cpu is 0 and the mem is 1.8.

I hope someone can help you if that were the case.
Greetings

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