h1

Permanently add static IP and default gateway

July 2, 2006

Red Hat Linux has made it fairly easy to set up network so that it will start automatically. There are a series of scripts in /etc/sysconfig/network-scripts that will do most of the work.

1. Binding IP address

In “/etc/sysconfig/network-scripts/ifcfg-eth0”, add your IPADDR (IP address), NETMASK, NETWORK and BROADCAST address

DEVICE=eth0

ONBOOT=yes

IPADDR=192.168.0.x

NETMASK=255.255.255.0

NETWORK=192.168.0.0

BROADCAST=192.168.0.255

2. Adding Default Gateway

In “/etc/sysconfig/network” add your default gateway.

GATEWAY=192.168.0.1

You can now restart your network:

#/etc/sysconfig/network-scripts/ifdown eth0

#/etc/sysconfig/network-scripts/ifup eth0
( please dont run the command remotely.. else you may have shutdown the interface and will be disconnected )

or in redhat:

#service network restart
or
# /etc/init.d/network restart

Check your “/sbin/route” (routing) to verify everything is in place and restarting your computer should hold your new settings.

10 comments

  1. Please add on your comments to not /etc/sysconfig/network-scripts/ifdown eth0 remotely. I was just following the tutorial, and realized the command by the time i pressed enter, and my connect went out! Great!
    Lucky my server is in the other room.
    Thanks for the help!


  2. Thank you nick0 … corrected it.


  3. very interesting. i’m adding in RSS Reader


  4. or just use ifdown eth0 && ifup eth0


  5. page turn union past


  6. reducing article institute


    • For a remote restart, if using SSH, an option is to execute /etc/init.d/network restart. The SSH client will reconnected as soon it senses the server is back. At least this is what I usually do and works.


  7. Nice post, for the

    #/etc/sysconfig/network-scripts/ifdown eth0
    #/etc/sysconfig/network-scripts/ifup eth0

    section

    I would replace with /etc/init.d/network restart as this works remotely


  8. Pretty portion of content. I simply stumbled upon your weblog and in accession capital to assert that I acquire in fact loved account your weblog posts.
    Any way I will be subscribing to your feeds or even I achievement you get admission to constantly quickly.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: