When creating new VM, in order to have an external IP:
Click on VM/Settings (when the machine is off ... otherwise, the Setting option is not available)
Network and select Bridged Adapter / etho / Allow All
Then, run the on the VM
ifconfig -a
in order to see which network card is used . For ex , here we use eth0:
eth0 Link encap:Ethernet HWaddr 08:2e:5f:32:c6:2b
inet addr:192.168.23.148 Bcast:192.168.23.255 Mask:255.255.252.0 inet6 addr: fe80::a2e:5fff:fe32:c62b/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1148454 errors:0 dropped:304 overruns:0 frame:0 TX packets:57473 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:169648034 (169.6 MB) TX bytes:9345047 (9.3 MB) Interrupt:19
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:16436 Metric:1 RX packets:107277 errors:0 dropped:0 overruns:0 frame:0 TX packets:107277 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:70365858 (70.3 MB) TX bytes:70365858 (70.3 MB)
Then, run the dhcpClient in order to make the VM get a new IP address.
dhclient eth0
In order to get this dhcpClient run after each reboot, go to the file
/etc/sysconfig/network-scripts/ifcfg-eth0
and edit it with the following:
DEVICE="eth0"
NM_CONTROLLED="no"
BOOTPROTO="dhcp"
ONBOOT="yes"
Then, ensure you don't have firewall blocking the connection to this new IP
# service iptables save
# service iptables stop
# chkconfig iptables off
In order to give the new VM a permanent hostname :
go to file /etc/sysconfig/network
and modify the line:
HOSTNAME=your-vm-desired-name
thanks to http://servercomputing.blogspot.co.il/2011/12/change-redhat-centos-hostname.html
Once done, I suggest to add this hostname to the /etc/hosts:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.14.183 your-vm-desired-name
Somehow, my VM centos image didn't include some basic linux centos package.
So here they are:
- yum install redhat-lsb
- yum install openssh-clients
ReAssign MAC Address
If you decide to assign a new MAC address to your VM (if you clone it, for example), then do not forget to assign it a new external IP by doing the following:
remove content of
/etc/udev/rules.d/70-persisten-net.rules
Then , just reboot your VM machine
This file associates the network card (like eth0, eth1 etc) to the MAC address.
No comments:
Post a Comment