LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-15-2020, 11:41 PM   #1
marjan.sayyad@gmail.com
LQ Newbie
 
Registered: Nov 2020
Posts: 4

Rep: Reputation: Disabled
Wrong ip address - ifconfig


Hello Everyone,
I have installed CentOS 8. Then I have installed Nagios core on it. I installed it on Vmware 6.5 in my company.
After complete installation of OS and Nagios Core I noticed "ifconfig -a" is showing IP address different than I saved in /etc/sysconfig/network-script/ifcfg-ens192. I gave static IP address on ifcfg0ens192 file.
The problem is "ifconfig -a" is showing one of our dhcp Ip that our user workstation is using.

The thing is both IP address are working on http://IPAddress/nagios without any issue.
I will appreciate if someone can help me why is it showing wrong IP Address.
Thanks,
Marjan
 
Old 11-16-2020, 05:58 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 5,964

Rep: Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840
Did you reboot after changing the ifcfg-ens192 file? Are you sure that this file describes the connection that your system is using?

Use nmcli con to check the currently active connection, then nmcli con show CONNECTION to see its details, where CONNECTION is the name of the active connection.

Also use ip address to see all addresses for ens192. ifconfig might not be able to show them all.

By the way, RHEL has good documentation for network configuration, which is obviously also applicable to Centos.

Last edited by berndbausch; 11-16-2020 at 06:02 PM.
 
Old 11-17-2020, 04:20 PM   #3
marjan.sayyad@gmail.com
LQ Newbie
 
Registered: Nov 2020
Posts: 4

Original Poster
Rep: Reputation: Disabled
UnExpected DHCP IP is assgned.

Quote:
Originally Posted by berndbausch View Post
Did you reboot after changing the ifcfg-ens192 file? Are you sure that this file describes the connection that your system is using?

Use nmcli con to check the currently active connection, then nmcli con show CONNECTION to see its details, where CONNECTION is the name of the active connection.

Also use ip address to see all addresses for ens192. ifconfig might not be able to show them all.

By the way, RHEL has good documentation for network configuration, which is obviously also applicable to Centos.
Hi berndbausch,
Thanks for your respond.
As you see in ifcfg-ens file, I only gave one static IP, but "ip a" is showing 2 IPs.( Please see the attachments)
Under the DHCP Ip address, time is decreasing. It seems like it is a temporary Ip Address.
Even when I remove the temporary dhcp IP with this command, “ip addr change IP address” and change valid life time to a lower number like 10 seconds, After 10 seconds it removes it, but after restarting machine, it shows up again.

I found this link: https://access.redhat.com/discussions/3206861 and did " omit_dracutmodules+="ifcfg" ", but it did not work.
Is the any other file can I check if my system set up to get dhcp IP from it, I can check and fix?

When I installed centos on physical machine, using same CentOS ISO file "CentOS-8.2.2004-x86_64-minimalCentOS-8.2.2004-x86_64-minimal", I did not have this issue. Is it possible on VMs, it creates temporary IP Address?

Your help is really appreciated!!!
Attached Thumbnails
Click image for larger version

Name:	ifcfgens.PNG
Views:	11
Size:	4.3 KB
ID:	34603   Click image for larger version

Name:	CentOSIPIssue.PNG
Views:	12
Size:	55.2 KB
ID:	34604  
 
Old 11-17-2020, 06:13 PM   #4
computersavvy
Member
 
Registered: Aug 2016
Posts: 725

Rep: Reputation: 223Reputation: 223Reputation: 223
Quote:
Originally Posted by marjan.sayyad@gmail.com View Post
As you see in ifcfg-ens file, I only gave one static IP, but "ip a" is showing 2 IPs.( Please see the attachments)
Under the DHCP Ip address, time is decreasing. It seems like it is a temporary Ip Address.
Even when I remove the temporary dhcp IP with this command, “ip addr change IP address” and change valid life time to a lower number like 10 seconds, After 10 seconds it removes it, but after restarting machine, it shows up again.
On my system the ifcfg file does not have quotes around any of the values in that file. Mine currently is (partial)
Code:
BROWSER_ONLY=no
BOOTPROTO=none
IPADDR=192.168.2.112
PREFIX=24
GATEWAY=192.168.2.1
DNS1=192.168.2.1
DEFROUTE=yes
PEERDNS=no
In my experience I have never seen quotes in any ifcfg files on any systems, and I wonder if that might have an effect on how the IP is assigned. I also see that your ifcfg shows BOOTPROTO="static" while mine, configured with the network manager shows BOOTPROTO=none.

I am using fedora and you are on Centos, but that should not be an issue.

One thing that comes to mind from past lives is that the behavior you are describing is reminiscent of when I was using alias IPs for a web server, in that multiple IPs were assigned to a single nic on the host as it served multiple guest web sites. Each IP was fully capable independent of the others. IIRC, each IP required a separate ifcfg file to assign a separate interface name to the same device.

The disconcerting thing really is that it gets dhcp assigned IP as primary and static IP as secondary which, to me, would imply multiple ifcfg files with dhcp happening first.
Are you certain there is not another ifcfg file with a different name for the same interface. You would need to look at the line DEVICE=???? in each ifcfg file to find out.
You would also need to make certain the host for this vm is not assigning the dhcp address for you.

Last edited by computersavvy; 11-17-2020 at 06:23 PM.
 
Old 11-17-2020, 07:10 PM   #5
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 5,964

Rep: Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840
At least we see that the static address you configured has been made effective. Now show us the output of nmcli con and nmcli con show ens192.

Quotes should be fine.

By the way, if these are private addresses, there is no need of hiding them.
 
Old 11-18-2020, 02:02 PM   #6
marjan.sayyad@gmail.com
LQ Newbie
 
Registered: Nov 2020
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thumbs up

Quote:
Originally Posted by computersavvy View Post
On my system the ifcfg file does not have quotes around any of the values in that file. Mine currently is (partial)
Code:
BROWSER_ONLY=no
BOOTPROTO=none
IPADDR=192.168.2.112
PREFIX=24
GATEWAY=192.168.2.1
DNS1=192.168.2.1
DEFROUTE=yes
PEERDNS=no
In my experience I have never seen quotes in any ifcfg files on any systems, and I wonder if that might have an effect on how the IP is assigned. I also see that your ifcfg shows BOOTPROTO="static" while mine, configured with the network manager shows BOOTPROTO=none.

I am using fedora and you are on Centos, but that should not be an issue.

One thing that comes to mind from past lives is that the behavior you are describing is reminiscent of when I was using alias IPs for a web server, in that multiple IPs were assigned to a single nic on the host as it served multiple guest web sites. Each IP was fully capable independent of the others. IIRC, each IP required a separate ifcfg file to assign a separate interface name to the same device.

The disconcerting thing really is that it gets dhcp assigned IP as primary and static IP as secondary which, to me, would imply multiple ifcfg files with dhcp happening first.
Are you certain there is not another ifcfg file with a different name for the same interface. You would need to look at the line DEVICE=???? in each ifcfg file to find out.
You would also need to make certain the host for this vm is not assigning the dhcp address for you.
=========
Thank you very much. I had copied the original ifcfg file with another name "OLD" at the end, and I believe because the IP was the same that I had inside the ifcfg-ens192 file, system gave a dhcp IP to the nic card. I deleted the second file and I removed all double quotation. Now It is only showing my static IP.
Thanks for your help.

ens192
 
Old 11-18-2020, 02:05 PM   #7
marjan.sayyad@gmail.com
LQ Newbie
 
Registered: Nov 2020
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thumbs up

Quote:
Originally Posted by berndbausch View Post
At least we see that the static address you configured has been made effective. Now show us the output of nmcli con and nmcli con show ens192.

Quotes should be fine.

By the way, if these are private addresses, there is no need of hiding them.

After deleting second ifcfg file, now it is showing one active connection ( Please see the attachment) , but before it was showing 2 connections.
My problem has been resolved. Thanks for your all helps!
Attached Thumbnails
Click image for larger version

Name:	nmcli.PNG
Views:	4
Size:	4.9 KB
ID:	34607  
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't find local IP Address in ifconfig on Kali Linux, am I doing something wrong? MrAppleJuice Linux - Newbie 4 11-14-2016 08:51 PM
[SOLVED] ifconfig -a sees eth0 ifconfig does not thllgo Linux - Networking 2 05-05-2016 04:38 PM
Why "-bash: ifconfig : command not found" when typing "$ifconfig" dangdtvn Linux - Server 9 09-20-2013 07:01 AM
ifconfig reports wrong mac address and wireless doesn't work blackdragonblood Linux - Wireless Networking 7 04-15-2006 01:08 PM
connecting /sbin/ifconfig to bash command ifconfig flammable2 Fedora 4 11-12-2005 08:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration