LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Permanent IP address (https://www.linuxquestions.org/questions/linux-networking-3/permanent-ip-address-857256/)

quark_arc 01-19-2011 07:23 AM

Permanent IP address
 
Hi,

We have a Linux 5.4 version running on HP DL380. I assigned the IP address to the eth0 interface using the menu Settings --> Networks --> interface. Then I rebooted the machine and used "ifconfig -a" to check the IP, but it didn't show any IP assigned to eth0.

Then I manually added the IP to eth0 as follows:

ifconfig eth0 10.125.9.161 netmask 255.255.255.248
route add default gw 10.125.9.166

ifconfig -a showed the IP address assigned. However on reboot, it didn't show any IP to eth0.

To permanently assign the IP address, do I have to define it in some configuration file?

acid_kewpie 01-19-2011 07:28 AM

Yes you do. Use the system-config-network tool or directly edit /etc/sysconfig/network-scripts/ifcfg-eth0

kaushalpatel1982 01-19-2011 08:46 AM

do check *onboot* should be *yes* in configuration file.

TB0ne 01-19-2011 09:30 AM

Quote:

Originally Posted by kaushalpatel1982 (Post 4230157)
do check *onboot* should be *yes* in configuration file.

Sorry, this is bad advice, and doesn't address the OP's question, and is incorrect to boot. The option is STARTMODE, and it should be set to 'onboot'.

Also, the OP asked how to assign a static address, not how to make sure the interface is active on boot. acid_kewpie posted the correct solution, which is to use the system configuration tool, or edit the file. In the file, the OP needs to set the IPADDR and NETMASK parameters, along these lines:
Code:

STARTMODE='onboot'
BOOTPROTO='static'
IPADDR='10.9.8.7'
NETMASK='255.255.255.0'

telling the interface to start on boot, use the IP address/netmask as shown, and that it's a static address, not DHCP provided.

acid_kewpie 01-19-2011 10:37 AM

Personally I've never seen a "STARTMODE" parameter. No sign of it in the init scripts of ifup scripts on centos 5.5

TB0ne 01-19-2011 11:29 AM

Quote:

Originally Posted by acid_kewpie (Post 4230296)
Personally I've never seen a "STARTMODE" parameter. No sign of it in the init scripts of ifup scripts on centos 5.5

Huh...I've got it in openSUSE...that's one of my interface-config scripts, with only the address changed. I've seen "onboot" and "manual" in there.

kaushalpatel1982 01-19-2011 09:22 PM

TB0ne, I have just followed the line give below.

Quote:

ifconfig -a showed the IP address assigned. However on reboot, it didn't show any IP to eth0.

TB0ne 01-20-2011 08:31 AM

Quote:

Originally Posted by kaushalpatel1982 (Post 4230954)
TB0ne, I have just followed the line give below.

Then you didn't enter and/or save the values correctly.

You SHOULD go through the system-network configuration tool, and make sure you set a static address, and that everything is set correctly. If not, edit /etc/sysconfig/network-scripts/ifcfg-eth0 as you were told above, and put the values in as shown.

The line you quoted is a command that sets is temporarily...both myself and acid_kewpie gave you the answer, neither of which involve running ifconfig. Follow the instructions given.


All times are GMT -5. The time now is 01:11 AM.