CentOS6.2: Static IP and default gateway

I am a debian linux user, the way CentOS configures is slightly different, this post is a reminder for myself.

Statically assign ip address to an interface on boot
Edit the script file /etc/sysconfig/network-scripts/ifcfg-eth0

Use a text editor to put these

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
NETWORK=192.168.0.0
NETMASK=255.255.255.0
BROADCAST=192.168.0.255
IPADDR=192.168.0.100

ONBOOT if set to yes will activate the interface id specified in DEVICE after boot, if set to no the interface will be deactivated after boot.

To use dhcp and turn on interface eth0, edit the script file /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

Statically assign gateway
Edit the script file /etc/sysconfig/network

HOSTNAME=anyname.local
GATEWAY=192.168.0.1
NETWORKING=yes
NETWORKING_IPV6=yes

When changes were completed restart the network /etc/init.d/network restart

Advertisements
This entry was posted in Linux, System OS and tagged , , , , . Bookmark the permalink.

2 Responses to CentOS6.2: Static IP and default gateway

  1. google says:

    thanks

  2. LaMar says:

    How do you or do you need to find “/etc/sysconfig/network-scripts/ifcfg-eth0” I’m trying to setup an PXE Server using CentOS 6.4 64-bit

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s