LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-14-2009, 05:38 PM   #1
RBMike
LQ Newbie
 
Registered: Dec 2009
Posts: 3

Rep: Reputation: 0
How can I tell if my Linux server has a static or dynamic IP address assigned to it?


Hi there,

I work for a small company and have been tasked with managing a server that runs linux. My boss has asked me to assign a fixed IP to the server. The server is not new, it has been up and running for months.

I have a hunch that it already has a fixed IP address, but how can I tell for sure? I can run the "ifconfig" command, and it gives me the IP address and some other information. I'd post the results here if I could, but it's on a different machine.

So, is there a command I can run to see if my server has a static or dynamic IP? I'm a total beginner so it would be helpful if you don't get too technical.

Thanks in advance.

Mike
 
Old 12-14-2009, 05:48 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Start by telling us which distribution (aka name) and version of Linux you have. That'll help enormously.
If you don't already know, open a cmd line terminal and try try the following cmds

uname -a

cat /etc/*release*


and post the results.
Also, post the output from ifconfig.
 
Old 12-14-2009, 06:47 PM   #3
worm5252
Member
 
Registered: Oct 2004
Location: Atlanta
Distribution: CentOS, RHEL, HP-UX, OS X
Posts: 567

Rep: Reputation: 57
You can use cat to view a file. In a command window run this command as root

Code:
cat /etc/network/interfaces
I for example have a static IP so this is what mine looks like
Code:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
  address 10.1.1.20
  netmask 255.255.255.0
  network 10.1.1.0
  broadcast 10.1.1.255
  gateway 10.1.1.1
If you have a dynamic IP (DHCP) it will look like this

Code:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
 
Old 12-15-2009, 12:29 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Quote:
Originally Posted by worm5252 View Post
You can use cat to view a file. In a command window run this command as root

Code:
cat /etc/network/interfaces
that is only for a Debian style network config.

Chrism asked the OP what distro he is using: best to wait for the reply.

Cheers,

Evo2.
 
Old 12-15-2009, 12:31 AM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Quote:
Originally Posted by chrism01 View Post
cat /etc/*release*
Depending on the distro, may need:
Code:
cat /etc/*version*
Cheers,

Evo2.
 
Old 12-15-2009, 02:18 AM   #6
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Rep: Reputation: 62
Well I don't know about this being distro-dependent - how about this: use ifconfig to note down your IP address, then turn off and turn on your net connection, and (preferably the next day or something) run ifconfig again and see whether you have the same IP - this should solve your problem no?
But this obviously presupposes that you won't get the same IP twice which isn't guaranteed, and may very well be the case.
 
Old 12-15-2009, 02:24 AM   #7
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Quote:
Originally Posted by resetreset View Post
Well I don't know about this being distro-dependent - how about this: use ifconfig to note down your IP address, then turn off and turn on your net connection, and (preferably the next day or something) run ifconfig again and see whether you have the same IP - this should solve your problem no?
But this obviously presupposes that you won't get the same IP twice which isn't guaranteed, and may very well be the case.
I think stopping and restarting the networking is probably something the OP would rather avoid. Also not only is it possible that the IP will be the same even in the DHCP case, but very likely since DHCP clients usually request the same IP that they had previously.

A distro indep. way could just be looking in /var/log/messages.

Cheers,

Evo2.
 
Old 12-15-2009, 10:29 AM   #8
RBMike
LQ Newbie
 
Registered: Dec 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by chrism01 View Post
Start by telling us which distribution (aka name) and version of Linux you have. That'll help enormously.
If you don't already know, open a cmd line terminal and try try the following cmds

uname -a

cat /etc/*release*


and post the results.
Also, post the output from ifconfig.
Thanks for everyone's help. Since I don't know how to email the results from that machine, the only thing I could think of was to take a photo of the screen. Here are the results of the three commands.

This machine has been shut down and restarted a few times, and the IP address has always been the same: 192.168.1.109. That's why I suspect that it is configured for static IP.

Thanks,

Mike
Attached Thumbnails
Click image for larger version

Name:	IMG_2204.JPG
Views:	1376
Size:	65.9 KB
ID:	2192   Click image for larger version

Name:	IMG_2205.JPG
Views:	1427
Size:	122.7 KB
ID:	2193  
 
Old 12-15-2009, 11:22 AM   #9
Zmyrgel
Senior Member
 
Registered: Dec 2005
Location: Finland
Distribution: Slackware, CentOS, RHEL, OpenBSD
Posts: 1,006

Rep: Reputation: 37
Check if you have /etc/sysconfig/network-scripts/ifcfg-eth0 file and whats its contents are.
It seems to be where CentOS keeps its network configuration options.
 
1 members found this post helpful.
Old 12-15-2009, 11:42 AM   #10
RBMike
LQ Newbie
 
Registered: Dec 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Zmyrgel View Post
Check if you have /etc/sysconfig/network-scripts/ifcfg-eth0 file and whats its contents are.
It seems to be where CentOS keeps its network configuration options.
I ran this command and it sure looks like it has been set as static. Is that what the "BOOTPROTO=static" means?

If so, then my issue will be resolved. Thank you!

Mike
Attached Thumbnails
Click image for larger version

Name:	IMG_2210.JPG
Views:	1087
Size:	66.2 KB
ID:	2196  
 
Old 12-15-2009, 11:52 AM   #11
worm5252
Member
 
Registered: Oct 2004
Location: Atlanta
Distribution: CentOS, RHEL, HP-UX, OS X
Posts: 567

Rep: Reputation: 57
Well there you go. It says in your /etc/sysconfig/network-scripts/ifcfg-eth0 file BOOTPROTO=STATIC. That tells you right there it is a static (Fixed) IP.
 
Old 12-15-2009, 05:05 PM   #12
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
And you don't need to keep taking photos, just copy & paste eg from an ssh session into your browser, if necessary.

BTW, Centos (free version of RHEL) 4.4 is very old.
They are currently on 4.8 and the latest is 5.4

Here's the RHEL 4.x Admin guide (which will work for Centos) http://www.linuxtopia.org/online_boo...ide/index.html
 
  


Reply



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
Static vs Dynamic IP Address Question amcmahon Linux - Networking 3 06-14-2007 10:24 AM
Set IP address to static from DHCP assigned address jborn Linux - Networking 4 02-02-2007 08:38 PM
[SOLVED] Converting static IP-address to dynamic IP-address Blue_Ice Linux - Networking 3 07-20-2006 03:35 AM
Static Server / Dynamic IP Router? Sapient Linux - Networking 19 10-28-2005 01:33 AM
DHCP Server MAC Address found, IP address not assigned wmburke Linux - Wireless Networking 17 11-17-2004 10:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:53 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