I'm running a CentOS Linux release 7.2.1511 (Core) 64-bit on an Oracle VM VirtualBox and I wanted my local machine (Windows) to be able to connect to my VM because I want to use it for local hosting for testing. To my understanding, to be able to achieve this I have to use Bridged Adapter. I checked several sites on how to configure my network and found this configuration for enp0s3:
DEVICE=enp0s3 HWADDR=your_mac_addr TYPE=Ethernet UUID=your_UUID ONBOOT=yes NM_CONTROLLED=no BOOTPROTO=none IPADDR=192.168.0.35 NETMASK=255.255.255.0 GATEWAY=192.168.0.1 DNS1=8.8.8.8 IPV6INIT=no USERCTL=no The problem is, when I tried to follow this and set my adapter to Bridged in Oracle VirtualBox my Machine suddenly cannot connect to the internet. Originally my VM can connect to internet as well as ping my local machine, just not the other way around.
On windows:
- IP: 10.120.20.71
- Subnet Mask: 255.255.255.0
- Default Gateway : 10.120.20.1
On CentOS7:
TYPE="Ethernet" BOOTPROTO=none NM_CONTROLLED=no USERCTL=no IPADDR=10.0.2.15 GATEWAY=10.120.20.1 NETMASK=255.255.255.0 DNS1=8.8.8.8 DEFROUTE="yes" PEERDNS="yes" PEERROUTES="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" NAME="enp0s3" UUID=<UUID> DEVICE="enp0s3" ONBOOT="yes" I also found this and tried configuring ifcfg-enp0s3, /etc/sysconfig/network and /etc/resolv.conf and the same thing happens.
61 Answer
The steps provided in the link (that you attached) gist work fine. Probably you forgot to change the line : "BOOTPROTO=none" to "BOOTPROTO=static". Also the gateway should be defined in /etc/sysconfig/network rather than ifcfg-enp0s3.
Below the steps described in the link with some modifications:
Configure enp0s3
#vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
DEVICE=enp0s3 NM_CONTROLLED=yes ONBOOT=yes HWADDR=<Your MAC @> TYPE=Ethernet BOOTPROTO=static NAME=enp0s3 UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 IPADDR=192.168.1.44 NETMASK=255.255.255.0 Configure Default Gateway
#vi /etc/sysconfig/network
NETWORKING=yes HOSTNAME=centos6 GATEWAY=192.168.1.1 Configure DNS Server
#vi /etc/resolv.conf
nameserver 8.8.8.8 # Replace with your nameserver ip nameserver 192.168.1.1 # Replace with your nameserver ipenter code here restart NetworkManager and network
$systemctl restart NetworkManager $systemctl restart network PS : ahh didn't seen the above comments, any way just to mention all the steps as advised by music2myear in the comment below.
3