Networking Forums

Networking Forums > Computer Networking > Linux Networking > How to set the IP and which configuration files?

Reply
Thread Tools Display Modes

How to set the IP and which configuration files?

 
 
Jonathan Taub
Guest
Posts: n/a

 
      05-03-2004, 04:41 PM
I want to configure manually my NICs.
I know I need to edit the "ifcfg-eth[X]" file(s).
However, there are three location which they are present:
- "/etc/sysconfig/networking/devices"
- "/etc/sysconfig/network-scripts"
- "etc/sysconfig/networking/profiles/default"

I think the file I shoud edit are the ones in the
"/etc/sysconfig/network-scripts" directory
but want to be absolutely sure.



Secondly, I wish to set my computer's IP.
I followed the instructions in
"http://linuxguide.automatedshops.com/LinuxGuide/linux-ethernet.html"
but it didn't help.

The following is the contents of each file:
---> /etc/sysconfig/network-scripts/ifcfg-eth0 <---
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
TYPE=Ethernet
IPADDR=10.1.1.137
NETMASK=255.255.255.0

---> /etc/sysconfig/network <---
NETWORKING=yes
HOSTNAME=nlayers.il.nlayers.com
GATEWAYDEV=eth0
GATEWAY=10.1.1.254

---> /etc/hosts <---
127.0.0.1 nlayers.il.nlayers.com nlayers localhost.localdomain
localhost
10.1.1.137 nlayers.il.nlayers.com nlayers

After doing "service network restart" or even rebooting, the computer
stays with its previously 10.1.1.88 assigned address from DHCP.
I suspect it may still get its IP from there although I haven't found
or don't know where to look for files which will confirm this.

P.S.
I'm using Redhat linux 9 with 4 NICs.
 
Reply With Quote
 
 
 
 
Bit Twister
Guest
Posts: n/a

 
      05-03-2004, 05:28 PM
On 3 May 2004 09:41:12 -0700, Jonathan Taub wrote:
> I want to configure manually my NICs.
> I know I need to edit the "ifcfg-eth[X]" file(s).
>
> I think the file I shoud edit are the ones in the
> "/etc/sysconfig/network-scripts" directory
> but want to be absolutely sure.


Then follow the code in /etc/rc.d/init.d/network
I do not have rh9 to look at.

>
> The following is the contents of each file:
> ---> /etc/sysconfig/network-scripts/ifcfg-eth0 <---
> DEVICE=eth0
> BOOTPROTO=none <================= static
> ONBOOT=yes
> USERCTL=no
> TYPE=Ethernet
> IPADDR=10.1.1.137
> NETMASK=255.255.255.0



> ---> /etc/hosts <---
> 127.0.0.1 nlayers.il.nlayers.com nlayers localhost.localdomain
> localhost
> 10.1.1.137 nlayers.il.nlayers.com nlayers


Maybe this will work better

127.0.0.1 localhost.localdomain localhost
10.1.1.137 nlayers.il.nlayers.com nlayers

 
Reply With Quote
 
/dev/rob0
Guest
Posts: n/a

 
      05-03-2004, 06:38 PM
On Mon, 03 May 2004 09:41:12 -0700, Jonathan Taub wrote:
> I want to configure manually my NICs. I know I need to edit the
> "ifcfg-eth[X]" file(s). However, there are three location which they are
> present: - "/etc/sysconfig/networking/devices" -


Although I suppose you'll be answered here, please note that this is a
question specific to your distro. Mine does not have those directories
or files.

> Secondly, I wish to set my computer's IP. I followed the instructions in
> "http://linuxguide.automatedshops.com/LinuxGuide/linux-ethernet.html" but
> it didn't help.


No surprise there. I followed the link and saw this at the top:
#v+
Created on November 9, 1997
Last modified: July 28, 2000
Development stage: Alpha
#v-

I read down a bit and saw that the author's level of understanding was
very poor. Of course so was my own understanding in July 2000! What a
difference 45 months can make ... in the free software world, that's a
long time!

> After doing "service network restart" or even rebooting, the computer
> stays with its previously 10.1.1.88 assigned address from DHCP. I suspect
> it may still get its IP from there although I haven't found or don't know
> where to look for files which will confirm this.


I guess you want a static IP, and not to use the DHCP server. I guess
somewhere there is a flag being set which tells the script (on RH I
think it's /etc/rc.d/init.d/network) to use DHCP, and when set it will
override the static IP settings. If you read that script you can trace
through it to see which files are being read, and what values it looks
for in the environment.

> P.S.
> I'm using Redhat linux 9 with 4 NICs.


4 NIC's, wow!

BTW I bet Red Hat provides some kind of network configuration tool or
script. In Slackware it's "netconfig".
--
/dev/rob0 - preferred_email=i$((28*28+28))@softhome.net
or put "not-spam" or "/dev/rob0" in Subject header to reply

 
Reply With Quote
 
P Gentry
Guest
Posts: n/a

 
      05-04-2004, 12:05 AM
(E-Mail Removed) (Jonathan Taub) wrote in message news:<(E-Mail Removed) om>...
> I want to configure manually my NICs.
> I know I need to edit the "ifcfg-eth[X]" file(s).
> However, there are three location which they are present:
> - "/etc/sysconfig/networking/devices"
> - "/etc/sysconfig/network-scripts"
> - "etc/sysconfig/networking/profiles/default"
>
> I think the file I shoud edit are the ones in the
> "/etc/sysconfig/network-scripts" directory
> but want to be absolutely sure.


The ifcfg-ethX file is duplicated in several of these dirs. Look at
all the plain text files for configuration -- only _read_ the scripts
to see what's going on when ifup runs. You can edit this file by
hand. I _think_ the other copies are used by the gui tools(?).

> Secondly, I wish to set my computer's IP.
> I followed the instructions in
> "http://linuxguide.automatedshops.com/LinuxGuide/linux-ethernet.html"
> but it didn't help.


This "guide" is nearly 4 years old and never got beyond alpha in the
author's mind -- ie., nearly worthless.

For setting your IP by hand you would normally use ifconfig. Get the
full set of How-Tos from tldp and look at the networking HowTos:
http://www.tldp.org/docs.html
These are the best set of basic (and some advanced) docs to reference
first.
To edit files directly by hand see RH docs below.

> The following is the contents of each file:
> ---> /etc/sysconfig/network-scripts/ifcfg-eth0 <---
> DEVICE=eth0
> BOOTPROTO=none
> ONBOOT=yes
> USERCTL=no
> TYPE=Ethernet
> IPADDR=10.1.1.137
> NETMASK=255.255.255.0
>
> ---> /etc/sysconfig/network <---
> NETWORKING=yes
> HOSTNAME=nlayers.il.nlayers.com
> GATEWAYDEV=eth0
> GATEWAY=10.1.1.254
>
> ---> /etc/hosts <---
> 127.0.0.1 nlayers.il.nlayers.com nlayers localhost.localdomain
> localhost
> 10.1.1.137 nlayers.il.nlayers.com nlayers


Have you edited some of these by hand? Not recommended unless you
know what to do and where to do it. But you know that now -- that's
why you're asking ;-) You're close, though. Drop the 2 aliases
(FQDN) for 127.0.0.1 -- certainly don't use them here and with
10.1.1.137. Try to keep it simple.

> After doing "service network restart" or even rebooting, the computer
> stays with its previously 10.1.1.88 assigned address from DHCP.
> I suspect it may still get its IP from there although I haven't found
> or don't know where to look for files which will confirm this.


Gui tools if you have X running. Try redhat-config-network. Edit ...
the eth0 Device.

> P.S.
> I'm using Redhat linux 9 with 4 NICs.


While some -- or even all -- of these files can be edited by hand ...
Why? That's why RH included things like neat. If X is available,
from an x-term, simply enter this as root:

# neat
or even
$ redhat-config-network

If you're running without X there are other tools, but I guess you
ought to get familiar with the scripts and files used by RH when
bringing up network interfaces. Note that some of the _scripts_ will
edit these files -- and any dhcp client will have to edit files to
store lease info, etc. The ifup script is the place to start looking
at all the ways RH can bring up the network interfaces.

Get the RH docs if you don't have them handy:
https://www.redhat.com/docs/manuals/linux/
http://www.redhat.com/support/resour...sysconfig.html

Look at the Reference Guide and the Customization Guide (?). The
first goes through all the applicable files.

You can also use ifconfig, route, and ip for some chores. Then there
are /etc/resolv.conf and /etc.hosts. Anymore ...? Check the docs --
memory running low at end of the workday.

hth,
prg
email above disabled
 
Reply With Quote
 
Jonathan Taub
Guest
Posts: n/a

 
      05-04-2004, 06:32 AM
> Then follow the code in /etc/rc.d/init.d/network
> I do not have rh9 to look at.


I thought I should follow /etc/init.d/network which pointed to these
set of files. But anyway, I checked the "rc.d" file and it points to
the same location.

> Maybe this will work better
>
> 127.0.0.1 localhost.localdomain localhost
> 10.1.1.137 nlayers.il.nlayers.com nlayers


No, it doesn't.
 
Reply With Quote
 
Jonathan Taub
Guest
Posts: n/a

 
      05-04-2004, 10:29 AM
I managed to get it.
I've changed the ifcfg-eth0 file residing under
/etc/sysconfig/networking/profiles/default.
All other files don't change anything.

This is strange since in the /etc/rc.d/init.d/network file the system
scans for interfaces inside the /etc/sysconfig/network-scripts
directory.

Anyway it works now (Wushhh...).
 
Reply With Quote
 
Juha Laiho
Guest
Posts: n/a

 
      05-04-2004, 04:07 PM
(E-Mail Removed) (Jonathan Taub) said:
>I managed to get it.
>I've changed the ifcfg-eth0 file residing under
>/etc/sysconfig/networking/profiles/default.
>All other files don't change anything.
>
>This is strange since in the /etc/rc.d/init.d/network file the system
>scans for interfaces inside the /etc/sysconfig/network-scripts
>directory.


This comes from the need_config() function defined in the
/etc/sysconfig/network-scripts/network-functions (and called by
/sbin/ifup).

need_config ()
{
CURRENT_PROFILE=${CURRENT_PROFILE:-default}
CURRENT_PROFILE=${CURRENT_PROFILE##*/}
CONFIG=../networking/profiles/$CURRENT_PROFILE/ifcfg-${1}
[ -f "${CONFIG}" ] && return || CONFIG=../networking/profiles/$CURRENT_PROFILE/${1}
[ -f "${CONFIG}" ] && return || CONFIG=../networking/default/ifcfg-${1}
[ -f "${CONFIG}" ] && return || CONFIG=../networking/default/${1}
[ -f "${CONFIG}" ] && return || CONFIG="ifcfg-${1}"
[ -f "${CONFIG}" ] && return || CONFIG="${1}"
}

So, if CURRENT_PROFILE is not defined (the most usual case), the
CURRENT_PROFILE is set to "default". Then, whatever value CURRENT_PROFILE
has, any possible path prefix is removed from it (so, from the start of
string until the last /-character, inclusive, is removed).

Then, CONFIG gets the first value which matches a file name, from the
list of
.../networking/profiles/$CURRENT_PROFILE/ifcfg-${1}
.../networking/profiles/$CURRENT_PROFILE/${1}
.../networking/profiles/default/ifcfg-${1}
.../networking/profiles/default/${1}
ifcfg-${1}
${1}

where the current directory when this is executed is
/etc/sysconfig/network-scripts, and ${1} contains the name of the
interface.

So, if the first one exists (as it usually does), the others are not
used. Failing that, the profiles/default entry definitely should
exist.

The /etc/sysconfig/network-scripts -entries apparently exist just
for compatibility reasons; the networking/profiles -entries being
the current implementation.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RRAS (win2003 server) configuration files? liljester Windows Networking 0 11-15-2006 08:26 PM
Wireless Zero Configuration (WZC) -> Files missing ... Truty Wireless Networks 5 05-14-2006 11:36 PM
Wireless Zero Configuration (WZC) -> Files missing ... Truty Wireless Internet 0 05-11-2006 01:04 PM
Network configuration files under Windows XP Petr Windows Networking 2 10-15-2004 06:49 PM
Which ethernet configuration files to edit Jonathan Taub Linux Networking 2 05-03-2004 06:38 PM



1 2 3 4 5 6 7 8 9 10 11