Wifi client mode not working

I am working on openwrt build 18.06.1.
I have configured wifi as sta but i am not able to ping.

cat /etc/config/network

config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config interface 'lan_eth0'
        option ifname 'eth0'
        option proto 'static'
        option ipaddr '192.168.5.1'
        option netmask '255.255.255.0'

config interface 'wifi'
        option proto 'dhcp'

cat /etc/config/wireless

config wifi-device 'radio0'
        option type 'mac80211'
        option channel 'auto'
        option country 'TW'
        option hwmode '11g'
        option path 'platform/10300000.wmac'
        option htmode 'HT20'
        option disabled '0'

config wifi-iface
        option device 'radio0'
        option network 'wifi'
        option mode 'sta'
        option seq '1'
        option ssid  'Router'
        option encryption 'psk2'
        option key  routermodem123''
root@openwrt:/# ifconfig 
eth0      Link encap:Ethernet  HWaddr 9C:65:F9:1B:F3:94  
          inet addr:192.168.5.1  Bcast:192.168.5.255  Mask:255.255.255.0
          inet6 addr: fe80::9e65:f9ff:fe1b:f394/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17091 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17069 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1769750 (1.6 MiB)  TX bytes:5305819 (5.0 MiB)
          Interrupt:5 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1167 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1167 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:79420 (77.5 KiB)  TX bytes:79420 (77.5 KiB)

wlan0     Link encap:Ethernet  HWaddr 9C:30:32:39:39:65  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Below is error i got when i used the command /etc/init.d/network restart

[ 4619.753171] wlan0: deauthenticated from be:2f:3d:df:1d:df (Reason: 3=DEAUTH_LEAVING)
[ 4674.489826] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready

try correcting this.

you need to create another wan interface and select the wireless device.

configuring in luci web interface is more easier.

i have corrected and tried it but still not working

try configuring in the luci web interface. its much easier.

there's a wiki here : https://openwrt.org/docs/guide-user/network/wifi/connect_client_wifi

From web page also it's not working.
If i share hotspot from mobile its working fine.
whenever i want to access internet from router this problem exist

hello anusha, i'm not sure i quite understand your problem.

So, it works perfectly when you connect to the mobile hotspot tethering? But it doesn't work when you connect to a different wireless network?

yes , what you told was correct

cat  /etc/config/wireless
config wifi-device 'radio0'
        option type 'mac80211'
        option channel 'auto'
        option country 'TW'
        option hwmode '11g'
        option path 'platform/10300000.wmac'
        option htmode 'HT20'
        option disabled '0'


config wifi-iface 
        option device 'radio0'
        option network 'wifi'
        option mode 'sta'
        option seq '1'
        option ssid 'vivo'
        option encryption 'psk2'
        option key 'welcome2vivo'

Above mentioned code works fine but when i change option ssid 'vivo' to option ssid 'Router' and option key 'welcome2vivo' to option key 'routermodem123 ' in /etc/config/wireless file ,ping will not work.

The problem is not with OpenWrt, rather it is with the Access Point.

Change the encryption at the Access Point to WPA2-AES

Change the encryption at the Access Point to WPA2-AES ......

what is this Access point ?

Lets say, when you use your mobile phone for hotspot tethering, and connect devices to it, the mobile acts as the Access Point.

So, in this case, the wireless network you're trying to connect to, needs to change its encryption to WPA2.

@Anusha Do you know what's the IP address range for both routers?
If it works with mobile phone but not with the router then it can also be an issue of IP address. It's worth noting.

When you try to connect to Router SSID, does the router even connect to the main one? First it will be the Wi-Fi connection, if it gets connected it can lease an IP address otherwise there will be no communication between the two.