Friday, May 17, 2013

CentOS 6.2 Minimal Setup - Part 1 - Enable Networking

I am going to describe the steps I go through to setup my clean CentOS 6.2 Minimal install so that it can run my app on tomcat using mysql as the database.

The first thing I need to do is enabled the networking, which by default is disabled.

So first I need to decide if I am going to use DHCP or Static configuration for the IP address. If this was my production machine it would be fixed. If it was my development or test server that is running on my local machine as a Virtual Machine it would be DHCP.

DHCP
Edit the /etc/sysconfig/network-scripts/ifcfg-eth0 file.

Make the following changes:
NM_CONTROLLER="no"
ONBOOT="yes"
BOOTPROTO="dhcp"

So it should look something like the following except the HWADDR will be different.


Then restart the network service using service network restart.

STATIC
Edit the /etc/sysconfig/network-scripts/ifcfg-eth0 file.

Make the following changes:
NM_CONTROLLER="no"
ONBOOT="yes"
BOOTPROTO="static"
IPADDR=xxx.xxx.xxx.xxx
NETMASK=xxx.xxx.xxx.xxx

The IPADDR and NETMASK will have been provided by your hosting company.

Edit the /etc/sysconfig/network file.
Make the following changes:
HOSTNAME=server1
GATEWAY=xxx.xxx.xxx.xxx

The GATEWAY will have been provided by your hosting company.

Edit the /etc/resolv.conf file.

Make the following changes:
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx

The 2 nameservers will have been provided by your hosting company.

Edit the /etc/hosts file.

Make the following change:
xxx.xxx.xxx.xxx server1.mydomain.com server1

The IP Address will be the same one entered for the IPADDR in /etc/sysconfig/network-scripts/ifcfg-eth0.

Test with hostname and hostname -f to make sure configured correctly. So for hostname you should see server1. And for hostname -f you should see server1.mydomain.com.

Then restart the network service using service network restart.

No comments:

Post a Comment