0

What is the "proper" way to assign my CentOS 7 Virtual Machine a static IP? I assigned my Host system (Windows 8) a static IP through the router's administration interface, but every tutorial online shows steps for using Bash and ifconfig.

I am wondering specifically because I am having a hard assigning the CentOS VM a static IP as I don't see its MAC address in the router's admin console. It is on the same subnet, 192.168.1.x, however I suspect the MAC address is messed up somehow. I think my VM is using a different MAC address than what the Host expects. Could this be the problem?

EDIT:

I should add that I am using VMWare Workstation 12 and the Virtual Machine is running on a bridged connection (it has its own IP).

0
  1. Determine which IP adapter you are using and what its MAC is:

    [root@kcalmanc7 network-scripts]# ip address show
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
        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: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
        link/ether 00:50:56:a6:5c:2b brd ff:ff:ff:ff:ff:ff
        inet 10.148.44.26/24 brd 10.148.44.255 scope global ens160
           valid_lft forever preferred_lft forever
        inet6 fe80::250:56ff:fea6:5c2b/64 scope link
           valid_lft forever preferred_lft forever
    3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
        link/ether 52:54:00:6a:3c:c0 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: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 500
        link/ether 52:54:00:6a:3c:c0 brd ff:ff:ff:ff:ff:ff
    

    (the second interface named 'ens160' shown above is the real network connection, MAC: 00:50:56:a6:5c:2b)

  2. Ensure the MAC address of the interface you think you are using matches the MAC stated in the VM configuration: Verify VM's MAC: 00:50:56:a6:5c:2b

  3. Edit the corresponding interface definition file

    [root@kcalmanc7 network-scripts]# pwd
    /etc/sysconfig/network-scripts
    [root@kcalmanc7 network-scripts]# ls -alp | grep ens160
    -rw-r--r--. 1 root root   359 Aug  7  2015 ifcfg-ens160
    [root@kcalmanc7 network-scripts]# cat  ifcfg-ens160
    TYPE="Ethernet"
    BOOTPROTO=none
    DEFROUTE="yes"
    IPV4_FAILURE_FATAL="yes"
    IPV6INIT="no"
    IPV6_AUTOCONF="yes"
    IPV6_DEFROUTE="yes"
    IPV6_PEERDNS="yes"
    IPV6_PEERROUTES="yes"
    IPV6_FAILURE_FATAL="no"
    NAME="ens160"
    UUID="52744fd5-752a-4994-a7a7-1c4a8e0c3b13"
    ONBOOT="yes"
    HWADDR=00:50:56:A6:5C:2B
    IPADDR0=10.148.44.26
    PREFIX0=24
    GATEWAY0=10.148.44.254
    DNS1=10.148.44.11
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.