Search This Blog

Total Pageviews

Friday, 27 December 2024

Linux virtual machine can't ping google while host can do it !!!!!


1. on vm > setting > network > bridged adapter 


2.

on laptop

=====================================================

on DOS cmd !!!!!


C:\Users\>ipconfig -all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : DESKTOP-*****
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : ******

Ethernet adapter Ethernet 5:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : VirtualBox Host-Only Ethernet Adapter
   Physical Address. . . . . . . . . : 0A-00-27-00-00-17
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::d6d3:a222:fb62:c216%23(Preferred)
   IPv4 Address. . . . . . . . . . . : 192.168.56.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 822738983
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-2D-80-59-CC-8C-04-BA-09-51-49
   NetBIOS over Tcpip. . . . . . . . : Enabled

Wireless LAN adapter Local Area Connection* 1:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter
   Physical Address. . . . . . . . . : D0-AB-D5-2C-F5-DE
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Wireless LAN adapter Local Area Connection* 10:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter #2
   Physical Address. . . . . . . . . : D2-AB-D5-2C-F5-DD
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Wireless LAN adapter WiFi:

   Connection-specific DNS Suffix  . : lan
   Description . . . . . . . . . . . : Intel(R) Dual Band Wireless-AC 8265
   Physical Address. . . . . . . . . : D0-AB-D5-2C-F5-DD
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   IPv6 Address. . . . . . . . . . . : 2a00:23c6:9735:5900:ddd6:4f4d:42d7:b65e(Preferred)
   IPv6 Address. . . . . . . . . . . : fd78:4c15:7f9d::fa5(Preferred)
   Lease Obtained. . . . . . . . . . : 25 December 2024 06:20:46
   Lease Expires . . . . . . . . . . : 28 December 2024 07:22:17
   IPv6 Address. . . . . . . . . . . : fd78:4c15:7f9d:0:241d:5b8:815f:9899(Preferred)
   Temporary IPv6 Address. . . . . . : 2a00:23c6:9735:5900:18c3:619d:8145:53f5(Preferred)
   Temporary IPv6 Address. . . . . . : 2a00:23c6:9735:5900:589a:f4b4:6eac:936a(Deprecated)
   Temporary IPv6 Address. . . . . . : 2a00:23c6:9735:5900:6c49:e836:4352:6eb5(Deprecated)
   Temporary IPv6 Address. . . . . . : 2a00:23c6:9735:5900:ecbc:b24d:a806:8b47(Deprecated)
   Temporary IPv6 Address. . . . . . : 2a00:23c6:9735:5900:fd1f:74b6:8106:6ba2(Deprecated)
   Temporary IPv6 Address. . . . . . : fd78:4c15:7f9d:0:18c3:619d:8145:53f5(Preferred)
   Temporary IPv6 Address. . . . . . : fd78:4c15:7f9d:0:589a:f4b4:6eac:936a(Deprecated)
   Temporary IPv6 Address. . . . . . : fd78:4c15:7f9d:0:6c49:e836:4352:6eb5(Deprecated)
   Temporary IPv6 Address. . . . . . : fd78:4c15:7f9d:0:ecbc:b24d:a806:8b47(Deprecated)
   Temporary IPv6 Address. . . . . . : fd78:4c15:7f9d:0:fd1f:74b6:8106:6ba2(Deprecated)
   Link-local IPv6 Address . . . . . : fe80::f22a:c00e:45e2:27b7%2(Preferred)
   IPv4 Address. . . . . . . . . . . : 192.168.1.213(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : 25 December 2024 06:20:55
   Lease Expires . . . . . . . . . . : 28 December 2024 07:22:05
   Default Gateway . . . . . . . . . : fe80::ba6a:f1ff:fec4:ae90%2
                                       192.168.1.254
   DHCP Server . . . . . . . . . . . : 192.168.1.254
   DHCPv6 IAID . . . . . . . . . . . : 47229909
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-2D-80-59-CC-8C-04-BA-09-51-49
   DNS Servers . . . . . . . . . . . : 192.168.1.254   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< check dns !!!!!!!!!!
   NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter Bluetooth Network Connection:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Bluetooth Device (Personal Area Network)
   Physical Address. . . . . . . . . : D0-AB-D5-2C-F5-E1
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

=======================================================================================================



on vm !!!!



[root@srv1 ~]# ifconfig -a
enp0s3: flags=4163  mtu 1500                          >>>> card name enp0s3
        inet 192.168.1.120  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fd78:4c15:7f9d::677  prefixlen 128  scopeid 0x0
        inet6 fe80::8f73:744d:ce36:6e12  prefixlen 64  scopeid 0x20
        inet6 2a00:23c6:9735:5900:9af9:fed8:2570:486b  prefixlen 64  scopeid 0x0
        inet6 fd78:4c15:7f9d:0:1155:a65a:49d8:fcc8  prefixlen 64  scopeid 0x0
        inet6 2a00:23c6:9735:5900::677  prefixlen 128  scopeid 0x0
        ether 08:00:27:a5:38:cd  txqueuelen 1000  (Ethernet)
        RX packets 13009  bytes 1299156 (1.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2974  bytes 305294 (298.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

=========================================================================================


[root@srv1 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 enp0s3   <<<<<<<<<<<<<<<<<----- wrong gateway should be 192.168.1.254
192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 enp0s3
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
[root@srv1 ~]#



[root@srv1 ~]# ip a
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:a5:38:cd brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.120/24 brd 192.168.1.255 scope global noprefixroute enp0s3
       valid_lft forever preferred_lft forever
    inet6 fd78:4c15:7f9d::677/128 scope global noprefixroute dynamic
       valid_lft 86203sec preferred_lft 43003sec
    inet6 2a00:23c6:9735:5900::677/128 scope global noprefixroute dynamic
       valid_lft 86203sec preferred_lft 43003sec
    inet6 fd78:4c15:7f9d:0:1155:a65a:49d8:fcc8/64 scope global noprefixroute
       valid_lft forever preferred_lft forever
    inet6 2a00:23c6:9735:5900:9af9:fed8:2570:486b/64 scope global noprefixroute dynamic
       valid_lft 315274393sec preferred_lft 315274393sec
    inet6 fe80::8f73:744d:ce36:6e12/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
3: virbr0:  mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:bd:bd:d5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic:  mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:bd:bd:d5 brd ff:ff:ff:ff:ff:ff
[root@srv1 ~]#




cat /etc/sysconfig/network-scripts/ifcfg-enp0s3

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s3
UUID=85024e4e-c958-4e04-8cda-3ed286b66822
DEVICE=enp0s3
ONBOOT=yes
IPV6_PRIVACY=no
IPADDR=192.168.1.120
PREFIX=24
GATEWAY=192.168.1.254   <<<< add dns router ip  or  add via this command >>>  route add default gw 192.168.1.254 enp0s3
DNS1=192.168.1.254


================================

command !!!!  or add on network card 

route add default gw 192.168.1.254 enp0s3

=====================================

chattr -i /etc/resolv.conf

=====================================

edit below file 

[root@srv1 ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search localdomain
nameserver 192.168.1.254
nameserver 8.8.8.8
nameserver 8.8.4.4


chattr +i /etc/resolv.conf

=====================================


[root@srv1 ~]# ip route show
default via 192.168.1.1 dev enp0s3 proto static metric 100
192.168.1.0/24 dev enp0s3 proto kernel scope link src 192.168.1.120 metric 100
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
[root@srv1 ~]#



[root@srv1 ~]# route -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.254   0.0.0.0         UG    100    0        0 enp0s3
192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 enp0s3
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0



nmcli connection down "connection_name"
nmcli connection up   "connection_name"
nmcli connection down "enp0s3"  

systemd-resolve --flush-caches


nmcli networking off
nmcli networking on

[root@srv1 ~]# systemctl restart NetworkManager
[root@srv1 ~]# systemctl status NetworkManager



[root@srv1 ~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=6.84 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=8.01 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=117 time=7.42 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=117 time=7.09 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=117 time=7.15 ms



=============================================================================================================


dhcp setting 


cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="enp0s3"
UUID="fdc2fc8c-f5b5-4e81-9c9e-b579991f2249"
DEVICE="enp0s3"
ONBOOT="yes"


[root@oragrid ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.254   0.0.0.0         UG    100    0        0 enp0s3
192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 enp0s3
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
[root@oragrid ~]#




Oracle DBA

anuj blog Archive