Ubuntu – How to obtain ipv4 address of ubuntu server running in virtual box along with ipv6

networkingservervirtualbox

i have installed ubuntu server on virtual box. When i execute the "ifconfig" command it shows the info of eth0 and loopback with inet6 address .but i want ipv4 address instead of ipv6 and i am not sure about the network adapter configuration of virtualbox as iam using wifi on my pc. Please help me

Best Answer

As i can guess you did bridge mode for Internet but , your dhcp not providing IP address to your port or you have not enabled networking. so , it showing like this

eth0      Link encap:Ethernet  HWaddr e8:11:32:db:1b:a5  
          inet6 addr: fe80::ea11:32ff:fedb:1ba5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:68323 errors:0 dropped:0 overruns:0 frame:0
          TX packets:51953 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:82498217 (82.4 MB)  TX bytes:4621046 (4.6 MB)

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:9075 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9075 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:916870 (916.8 KB)  TX bytes:916870 (916.8 KB)

Solution: start your network-manager using

sudo service network-manager start

or use if already started

sudo service network-manager restart

or

sudo ip link set eth0 up 

or

sudo nmcli nm enable true

or enable using GUI

network-manager--> Enable Networking and connect wired connection

or

if you still face problem then it means your wifi dhcp not providing ip to VM then you can change mode bridge to NAT for internet then you will get private ip and will able to connect internet