How to set up networking on a Centos 7 VM on Windows 7

Issues related to configuring your network
Post Reply
captainclueless
Posts: 1
Joined: 2017/08/13 18:32:15

How to set up networking on a Centos 7 VM on Windows 7

Post by captainclueless » 2017/08/13 18:57:56

Hello,

First post. I'll try not to be too facepalmy.

I'm running VirtualBox on Windows 7, and trying to set up Centos 7 1611 everything iso as a VM.

The main objectives here are to:
1. to learn how to do it...
2. to end up with a straightforward and reliable set of instructions to follow
3. ...instructions that aid understanding of what I as a user am doing, and why.
4. to try understand what i don't understand in terms of what I've been banging my head against a wall over, to reduce the chances of me asking silly questions.

So, FWIW, I'm using the latest Vbox, which is 5.1.22r115126 (Qt5.6.2). My vanilla home LAN is all on 192.168.1.xx, which is the IP range of my Win7 host PC.

I build a basic VM, as RH64, leave it with one network adapter set on the default NAT, and click through all the defaults of memory and storage size, .vdi etc..., and add the .iso to the CD, and install, go to the software selection and choose GNOME in the LHS column, and most of the options in the RHS column.

I go in networking, and do a bit of configuring... change the name to "centos7-pcname.local"
change the ip to 192.168.1.xx/24 and gateway 192.168.1.1, DNS of 8.8.8.8 and click through the setup steps.

I get to the desktop... I find I have to add my user to wheel for sudo, which is a bit of nuisance... have to use vi instead of nano :( visudo uncomment wheel, then su and do usermod -aG user, and then I turn my attention to the network side of things.

i do ifconfig, and I see the 192.168.1.xx IP I've added, (no sign of the pesky default 10.0.2.xx and 192.168.56.xx) but I see vibr0 192.168.122.xx

in win7 I run cmd and do arp -a, and I see the 192.168.56.xx interface, but no sign of my chosen 192.168.1.xx address... and I can't ping my gateway/router at 192.168.1.1

I find a mix of online guides, and get in a bit of a muddle, but at some point, after adding a second adapter as VM host-only, and changing back from bridged to NAT, I can suddenly ping my gateway, but I can't yum install anything, and there's no sign of a DNS problem. I get in yet more of a muddle via online guides, and end up back to not being able to ping anything.

<sigh>

why does it have to be so difficult, I sigh to myself... and I get fed up and do something else.

Obviously there's a number of problems with what I'm doing, and my response to them, but please, can anyone, offer up a simple spoon-fed step by step to just get a basic Centos VM up and running on Windows 7 Virtual Box?

The irritating thing is that I got it going on a minimal install on another machine a couple of days ago, and could yum install lots of things, apart from anything from a http address, like elrepo or something, so part of this is me wanting to understand what I'm doing and why.

A simple do this - because of this, then do that, because of that, would be fab, and hopefully useful for other useless people like me :D

clearly NAT works (sometimes, but what set up makes it work), bridged might work, but maybe the name is confusing me, host-only might help in some way, but not really sure... and lots of similarly embarrassingly stupid questions are on the tip of tongues like mine... any takers? :D

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: How to set up networking on a Centos 7 VM on Windows 7

Post by hunter86_bg » 2017/08/13 21:33:35

First of all, instead of using "ifconfig" - start using "ip" command.
Second , Network Manager is the recommended way - if you find "nmcli" too hard - > use "nmtui".
For defining your hostname -> use "hostnamectl".

Have you defined your network to start on boot ? If no - you can use the following:

Code: Select all

#Check Network Manager managed devices:
nmcli device
#Check defined Network Profiles in NM:
nmcli con show
#To enable 'enp2s0' device:
nmcli connection modify enp2s0 autoconnect yes

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: How to set up networking on a Centos 7 VM on Windows 7

Post by jlehtone » 2017/08/14 07:54:37

vibr0 192.168.122.xx
CentOS installs and runs libvirt by default. Libvirtd creates the above by default.

You probably do not want to create and run VM's inside a VM.
Stop and disable the libvirtd service:

Code: Select all

sudo systemctl stop libvirtd.service
sudo systemctl disable libvirtd.service
After reboot the virbr0 should be gone. Less things to worry about.
clearly NAT works (sometimes, but what set up makes it work), bridged might work, but maybe the name is confusing me, host-only might help in some way
I don't know virtualbox, but ...

There are three types of networks: routed, bridged, and isolated.

Isolated is simple. The members of the subnet see each other and nobody else. I guess the "host-only" is an isolated network. It is like you had two PC's, the Windows and the VM that you both connect to a "network switch". Ideally the virtualbox runs a DHCP server to configure the VM's networking.

Routed network is what you have at home. One of the devices (192.168.1.1) is a member of two separate subnets and forwards (aka routes) traffic from one to another. The other devices are told to send nonlocal traffic to the router (aka gateway). The router usually has a DHCP server and configures the other subnet members, so that they do not need manual config.

Routed in virtualbox is the same, but now the host is a router between your external subnet 192.168.1.x/24 and the virtual subnet that has members Windows and VM. Ideally the virtualbox runs a DHCP server to configure the VM's networking.

The NAT is a special form of routing. The router masquerades the source address. Your home router probably has NAT on. Outsiders do not know that they talk with a 192.168.1.x/24 member. They see only the public IP address of your router. Virtualbox with NAT hides the fact that there are any VM's "behind the Windows machine".

Bridged network is like you would have three PC's: your router, the Windows, and the VM, all three connected to same switch. No routing on the Windows host. The VM "sees" the external router directly. If the router offers DHCP, then I would use that on the VM and not set IP manually.

Post Reply