March 9, 2009
How to: configure the network on CentOS 5
This configuration assumes the following:
- HOSTNAME=server2.example.com
- NETWORK=192.168.1.0
- IPADDR=192.168.1.2
- NETMASK=255.255.255.0
- BROADCAST=192.168.1.255
- GATEWAY=192.168.1.1
- Change The HOSTNAME
# vi /etc/sysconfig/network
NETWORKING=yes NETWORKING_IPV6=yes HOSTNAME=server2.example.com
- Change IPADDR, NETWORK, NETMASK, GATEWAY(if you are using) and BROADCAST to your settings
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# VIA Technologies, Inc. VT6102 [Rhine-II] DEVICE=eth0 BOOTPROTO=static BROADCAST=192.168.1.255 HWADDR=00:19:DB:69:64:63 IPADDR=192.168.1.2 IPV6ADDR= IPV6PREFIX= NETMASK=255.255.255.0 NETWORK=192.168.1.0 GATEWAY=192.168.1.1 ONBOOT=yes
# vi /etc/resolv.conf
- Change the nameservers IPs to your ISP nameservers:
nameserver 84.23.101.84 nameserver 84.23.101.85
# vi /etc/hosts
- Change it to some thing like this:
# Do not remove the following line, or various programs # that require network functionality will fail. 192.168.1.2 server2.example.com computer2 192.168.1.1 server1.example.com computer1 127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6
# service network restart
- Test it by running this command:
# ping 192.168.1.2
To stop the network card
# ifdown eth0
To start the network card
# ifup eth0
To display network devices
# ifconfig
To display the routing table
# netstat -nrRHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302) (Certification Press)


