LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 11-14-2008, 06:46 AM   #1
philwynk
Member
 
Registered: Sep 2007
Posts: 84

Rep: Reputation: 15
How do I set my host to a static IP?


Hi, all,

I just installed Fedora Core 9 on my server, and I'm trying to get it to use a static IP address.

I thought I'd configured it to create a static IP during the installation process, when the installer asked me whether to get a DHCP address or use a static IP, gateway, and DNS server. I went through the installation, came up with the IP I expected, everything was fine.

Then I restarted, and nothing could reach my web site. After hacking around for days assuming the IP config was correct, I ran ifconfig -a and discovered that my IP address is not what I expected -- instead, it's an address from within the DHCP range handed by my Linksys router.

How do I set the Fedora box to use a static IP rather than DHCP?

Thanks.

Phil W.
 
Old 11-14-2008, 08:29 AM   #2
mrrangerman
Member
 
Registered: Oct 2007
Location: MI
Distribution: Debian Slackware
Posts: 528

Rep: Reputation: 50
Here this should help.
Static
 
Old 11-14-2008, 09:11 AM   #3
philwynk
Member
 
Registered: Sep 2007
Posts: 84

Original Poster
Rep: Reputation: 15
Follow-up questions

Ok, I see the syntax. It really is as simple as updating /etc/sysconfig/network-scripts/ifcfg-eth0?

I tried the inserting the following into ifcfg-eth0, and lost my network connection to the internet:

DEVICE=eth0
IPADDR= < valid IP address. Trust me. >
NETMASK=255.255.255.0
BOOTPROTO=static
ONBOOT=yes

As soon as I restored the previous code to the file, my connection came back up.

Is there syntax to specify the preferred router? Am I missing something important? What if I specify the DNS servers?
 
Old 11-14-2008, 09:31 AM   #4
AuroraCA
Member
 
Registered: Jul 2008
Location: Northern CA USA
Distribution: Ubuntu, Slackware, Gentoo, Fedora, Red Hat, Puppy Linux
Posts: 370

Rep: Reputation: 35
I found this using a google search with the keywords "fedora static ip"

http://defindit.com/readme_files/netsetup.html
 
Old 11-14-2008, 11:49 AM   #5
mjlouis
Member
 
Registered: Nov 2008
Posts: 48

Rep: Reputation: 16
Quote:
Originally Posted by philwynk View Post
Ok, I see the syntax. It really is as simple as updating /etc/sysconfig/network-scripts/ifcfg-eth0?

I tried the inserting the following into ifcfg-eth0, and lost my network connection to the internet:

DEVICE=eth0
IPADDR= < valid IP address. Trust me. >
NETMASK=255.255.255.0
BOOTPROTO=static
ONBOOT=yes

As soon as I restored the previous code to the file, my connection came back up.

Is there syntax to specify the preferred router? Am I missing something important? What if I specify the DNS servers?
You'll need to have the DNS servers specified in resolv.conf:

Code:
nameserver xxx.xxx.xxx.xxx
Where xxx.xxx.xxx.xxx is the IP address.

You will also need to specify your gateway to the outside world into your ifcfg-eth0 (If I recall correctly) file:

Code:
GATEWAY=xxx.xxx.xxx.xxx

Last edited by mjlouis; 11-14-2008 at 11:49 AM. Reason: Tryping error :-)
 
Old 11-14-2008, 02:44 PM   #6
philwynk
Member
 
Registered: Sep 2007
Posts: 84

Original Poster
Rep: Reputation: 15
Ok, this works

Ok, here's what actually worked.

I rewrote /etc/sysconfig/network-scripts/ifcfg-etho to read as follows:

Quote:
DEVICE=eth0
IPADDR= <valid static IP addy>
NETMASK=255.255.255.0
GATEWAY= <valid IP addy of my router>
BOOTPROTO=static
ONBOOT=yes
DNS1=<valid IP addy of my dynamic DNS service's name server>
DNS2=<valid IP addy of my dynamic DNS service's other name server>
I did not have to touch resolv.conf. Once I got the DNS1 and DNS2 entries into ifcfg-eth0, resolv.conf updated automatically.

Thanks for your help, all.

Last edited by philwynk; 11-14-2008 at 02:47 PM.
 
  


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
how do i set a static ip? ninja master Slackware 9 11-20-2008 08:15 PM
How to set Static IP? maverick_29 Linux - Networking 4 05-25-2007 01:07 AM
IP_forward? Static route (-host)? HELP! haiders Linux - Networking 2 09-18-2006 01:45 PM
Configuring local host to have Static IP logosys Linux - Networking 2 03-02-2006 01:20 AM
FC2 Overriding static if in favor of dhcp system set for static pkraus109 Linux - Networking 8 09-21-2004 11:13 AM


All times are GMT -5. The time now is 01:26 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration