How to fix ipaddress in CentOS? - centos

I am using VMWare 10, in that installed CentOS 6.5 with two networking interfaces (eth0,eth1).
When I try to use the vmware, every time the ipaddress changes.
How to make the IP address constant (not a static IP address)?

Vmware will by default allocate dhcp ip addesses. In order to have static IP address, please assign static IP address in Centos using below steps
Static IP assignment for eth0
cat /etc/sysconfig/network-scripts/ifcfg-eth0
Sample output:
DEVICE="eth0"
BOOTPROTO="dhcp"
HWADDR="xx:xx:xx:xx:xx:xx"
NM_CONTROLLED="yes"
ONBOOT="no"
TYPE="Ethernet"
Configure eth0:
In above you can look that IP address is assigned dynamically using dhcp. Change this to below, make sure you aren't changing hwaddr, device - leave it unchanged.
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="static"
HWADDR="xx:xx:xx:xx:xx:xx"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
IPADDR=192.168.1.2
NETMASK=255.255.255.0
service network restart
It will work now.

Related

Networking not initialized with cloud-init on some Centos 7 images

I'm trying to create KVM VMs of Centos 7 with cloud-init. I am using the images found at https://cloud.centos.org/centos/7/images/ .
In the meta-data file I put the following content:
network-interfaces: |
iface eth0 inet static
address 10.0.0.10
network 10.0.0.0
netmask 255.255.255.0
broadcast 10.0.0.255
gateway 10.0.0.1
bootcmd:
- ifdown eth0
- ifup eth0
However I don't get the same behaviour depending on the image used (I tried a few):
Centos-7, Centos-7-2009: The VM doesn't use the static IP given (the link is down)
Centos-7-1805: The VM uses the static IP but SSH connection initialisation is very slow (a minute or two)
Centos-7-1607: The VM uses the static IP, SSH works correctly, but the Ansible playbook I tried with an ordinary Centos-7 image (installed from an iso file) doesn't work perfectly on this image (issue with some packages missing), I would like to not change my playbook.
Is there a reason there are so much differences between the different images ? Am I doing something wrong ?
Thank you

How does ping -a know the hostname of my Raspberry Pi 4?

My Raspberry Pi 4 B is connected (for the first time) to the WiFi of my PC (running Windows). Then the raspberry(ip) showed up in the list in Network Scanner of MobaXterm. What surprised me is that the list also shows the name of my Pi. And ping -a ip also shows the name.
How does this work?
When the Raspberry Pi connects to your WiFi it doesn't just get an IP address assigned. It also gets a host name assigned. It either sends its own host name to the DHCP server or the DHCP server assigns a host name.
Now, when you have an IP address, you can do a reverse search. Usually DNS works in the way that you give it a name and it returns the IP address. But there is also reverse search, give it an IP address and get a name back.
In your local network the DHCP server and your DNS resolver work together. Whenever a reverse search for a local IP address is made, the answer is fetched from the DHCP server. And the DHCP server answers with the host name from step one.
In most WiFi routers dnsmasq does this for you, on a Windows machine it is built into Windows.

VMWare workstation Centos VM unable to obtain LAN IPIV IP address using bridged network

I'm using VMWare Workstation Pro 12.5.7 build-5813279.
I created Centox 7.x VM with network setting to use NAT vs Bridged Connection.
After Centos is installed the VM and the ifconfig shows the IP address of inet 192.168.253 on ens33.
It also shows inet6 xxxx::xxxx:xxx:xxxx:xxxx (x being hexa values).
However, I want to use a local network IP(DHCP) address on this VM so I change the network setting to
Bridged Connection and I give it a reboot. Then I get no IP IV address and it only shows the
inet6 xxxx::xxxx:xxx:xxxx:xxxx (x being hexa values).
When I use the Bridged connection for Oracle Virual Box VM I do not have this issue and I'm able to get the
local Ip address.
How can I get the Ip IV ip address from my local network's DHCP using VMWare workstation VM?
Try this from root:
dhclient –v
try this:
Go to File -> Edit -> Virtual Network Editor
Use the Change Settings" button
Highlight the first selection VMnet0
Under VMnet Information choose the "Automatic Setting" button
You will get a list of all of the adapters on your system.
Uncheck ones that might be causing the issue.
Click "Apply" then "OK"
Should help.
:)

get virtual machine information on Host

How to retrieve virtual machine data such as ip address on the HOST .
I've created virtual machines using qemu-system-x86_64.
At time of asking, it was not possible to query the guest IP address from virsh. Modern libvirt though supports the "domifaddr" command in virsh which lets you query the DHCP assigned IP address for guests that are connected to libvirt's "default" network. It does not work for guests using direct bridging to the LAN.
Second, there is now also the ability to setup an NSS module on the host, so you can login to guests based on their hostname, instead of raw IP. Again this works for guests using the default network

configure ip for bitnami owncloud virtual appliance

I installed Bitnami owncloud virtual appliance stack on Virtual box and within no time, I was able to sync files to and from this box. However, the main problem with Virtual Box is that the IP address keeps changing when the owncloud instance is powered off and then turned back on - which makes sense. Is there any way to keep the server IP static so that we don't need to configure the clients everytime the IP is changed.
You could change the config (from auto to static) in the following way
sudo vi /etc/network/interfaces (“vi” or “nano”)
iface eth0 inet static
address 192.168.0.100
# your own IP
netmask 255.255.255.0
# network mask
gateway 192.168.0.1
# standard gateway (router)
dns-nameservers 192.168.0.1 8.8.8.8
# DNS (optional)
/etc/init.d/networking restart (restart network)
ifconfig
for the IP addresses check or you “shutdown –h now” (reboot)). Please, keep in mind that multiple copies need multiple IP's. In Virtual Box remember to switch between NAT and Bridge - if required.