No internet in VirtualBox with 2 network cards

Issues related to configuring your network
Post Reply
tom3f
Posts: 4
Joined: 2014/10/15 06:52:05

No internet in VirtualBox with 2 network cards

Post by tom3f » 2014/10/22 06:59:37

Hello,

I have installed CentOS 7 minimal instalation with instaled Oracle XE. I use it as local database server for development purpose only. On my virtualmachine I set up 2 network cards. First is Host-only Adapter -> vboxnet0
I use this adapter for comunication with my database server. Second network adapter is NAT. I want to use this one for internet connection in my virtual machine. My network setup is shown down. After every reboot host only adapter works fine but i have no internet connection. I must run command dhclient -v enp0s8 to get internet connection. I check my internet connection with command ping google.sk.

My network conffiguration folder:

[root@localhost ~]# ls /etc/sysconfig/network-scripts/
ifcfg-enp0s3 ifdown ifdown-ippp ifdown-post ifdown-sit ifdown-tunnel ifup-bnep ifup-ipv6 ifup-plusb ifup-routes ifup-TeamPort init.ipv6-global
ifcfg-enp0s8 ifdown-bnep ifdown-ipv6 ifdown-ppp ifdown-Team ifup ifup-eth ifup-isdn ifup-post ifup-sit ifup-tunnel network-functions
ifcfg-lo ifdown-eth ifdown-isdn ifdown-routes ifdown-TeamPort ifup-aliases ifup-ippp ifup-plip ifup-ppp ifup-Team ifup-wireless network-functions-ipv6

My enp0s3 config:

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=e4ccc3c9-facc-4cc8-a918-54722b05acab
ONBOOT=yes
HWADDR=08:00:27:84:7A:6C
IPADDR0=10.0.0.9
PREFIX0=24
GATEWAY0=10.0.0.1


My enp0s8 config file:

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s8
DEVICE=enp0s8
BOOTPROTO=dhcp
ONBOOT=yes
HWADDR=08:00:27:1E:51:1B

Can you help me get internet connection on enp0s8 automaticaly after every boot ? Thanks.
Attachments
After running dhclient -v enp0s8 i get internet connection
After running dhclient -v enp0s8 i get internet connection
after dhclient internet works fine.png (82.96 KiB) Viewed 19798 times
dhclient.png
dhclient.png (42.97 KiB) Viewed 19798 times
After reboot I dont have internet connection
After reboot I dont have internet connection
after boot no internet connection.png (82.63 KiB) Viewed 19798 times

User avatar
TrevorH
Site Admin
Posts: 33218
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: No internet in VirtualBox with 2 network cards

Post by TrevorH » 2014/10/22 08:20:35

Your problem is most likely that the default route you have specified on your first adapter is taking preference over the one from the DHCP server. To confirm this, when it is not working, run ip route show and see if you have more than one default route and which one takes precedence. You can tell by running ip route get some.ip.add.ress and it will tell you which route would be used.

If your 10.0.0.9 interface is used only for communicating with hosts on the same subnet then you should remove the GATEWAY= line for that - it's not required.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

tom3f
Posts: 4
Joined: 2014/10/15 06:52:05

Re: No internet in VirtualBox with 2 network cards

Post by tom3f » 2014/10/22 08:28:40

Thank you very much, after I removed gateway it works perfect.

Post Reply