Find the answer to your Linux question:
Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By docbop
This belongs in no specific distro but I am using CentOS6. I am learning the ip command and can assign a Class C address using this command: Code: ip addr ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2010
    Location
    Virginia
    Posts
    9

    ip addr command drops ipv4 address after a few minutes


    This belongs in no specific distro but I am using CentOS6.

    I am learning the ip command and can assign a Class C address using this command:

    Code:
    ip addr add dev eth0 local 192.168.3.229/24
    It works for a few minutes. I am able to ping other nodes on the network. However, it loses the value, meaning I can't ping and ip addr does not show the ip addres any more.

    Is this the best way to assign an ip address using the ip command? I understand ifconfig works but I am learning the ip command and want to create a permanent ip4v address.

    Thanks!

  2. #2
    Linux Engineer docbop's Avatar
    Join Date
    Nov 2009
    Location
    Woodshed, CA
    Posts
    902
    If you want to permenatly change the config then you want to edit the interface file.

    /etc/network/interfaces
    lifeontheway likes this.

  3. #3
    Just Joined!
    Join Date
    Jan 2014
    Posts
    5
    I think the previous post must be used to a Debian derivative. Red Hat/Centos doesn't have an /etc/network directory that I know of.

    The place to put the file to make this permanent is /etc/sysconfig/network-scripts/ifcfg-eth0. Run system-config-network if you don't know what should go in it. Either use "/etc/init.d/network restart" or "ifup eth0" to start it once that file is built.

    However, that's only half the problem. Setting the IP address with ip should last until the next reboot, and if I read between the lines correctly, it's going away before that. I don't know of anything in stock Centos that would reset an Ethernet card. Someone may have set up a security script which goes out and "fixes" things like an Ethernet card that it doesn't know about having an IP address. Setting the card's address via the ifcfg-eth0 file would probably fix that.

    Hope this helps

    Stuff doesn't just "get lost". Something is

  4. #4
    Linux Engineer docbop's Avatar
    Join Date
    Nov 2009
    Location
    Woodshed, CA
    Posts
    902
    Yes, sorry that was Debian flavor. Here's a link that covers Redhat flavor and Debian.

    Linux Static IP Address Configuration

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •