Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I configured a network interface with the following commands:

ifconfig eth0 up
ip addr add 192.168.9.1/28 dev eth0
route add default gw 192.168.0.1

This works. However, when I reboot the machine I lose all the configurations made. How can I make sure this is persistent? I'm using CentOS 6.3.

share|improve this question
    
check this stackoverflow.com/questions/6016713/… –  harish.venkat Dec 29 '12 at 18:18
    
The other (and more correct) option will be setting the corresponding values in your system configuration files. Which Linux distro are you using? (If that's Linux, of course) –  Leonid Dec 29 '12 at 19:02
    
@harish.venkat That's the wrong way to configure things for your network. –  gertvdijk Dec 29 '12 at 20:46
    
Are you using GUI or a CLI-only? –  gertvdijk Dec 29 '12 at 20:48
add comment

1 Answer

up vote 5 down vote accepted

First of all, your given configuration of the default gateway is not valid. 192.168.0.1 is not within the network of 192.168.9.1/28. I suspect you made a typo, so I assume you meant 192.168.9.10 as the default gateway here.

Referring to the RHEL 6 Deployment Guide section 8.2 for the address and section 8.4 for routes:

  1. Create/edit a file /etc/sysconfig/network-scripts/ifcfg-eth0 containing:

    DEVICE=eth0
    BOOTPROTO=none
    ONBOOT=yes
    NETMASK=255.255.255.240 # this is /28
    IPADDR=192.168.9.1
    USERCTL=no
    
  2. Create/edit the route configuration file /etc/sysconfig/network-scripts/route-eth0:

    default 192.168.9.10 dev eth0
    
share|improve this answer
    
@UlrichDangel Good point. Wasn't completely awake I guess. Fixed. –  gertvdijk Dec 29 '12 at 21:31
    
@gertvdijk got it,just provided a quick fix. –  harish.venkat Dec 30 '12 at 3:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.