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
  1. Change The HOSTNAME
    # vi /etc/sysconfig/network
    NETWORKING=yes
    NETWORKING_IPV6=yes
    HOSTNAME=server2.example.com
    
  2. 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
    
  3. # vi /etc/resolv.conf
  4. Change the nameservers IPs to your ISP nameservers:
    nameserver  84.23.101.84
    nameserver  84.23.101.85
    
  5. # vi /etc/hosts
  6. 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
    
  7. # service network restart
  8. 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 -nr
RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302) (Certification Press)

Spread the word

del.icio.us Digg Furl Reddit Help

Permalink • Print

Related Entries

Made with WordPress and Semiologic • Sky Gold skin by Denis de Bernardy