Sunday, October 28, 2007

Network Configuration File for RedHat/CentOS/Fedora

Because I work with my Linux Server directly from terminal, No fancy GUI. So I edit the network configuration
directly to ifcfg-ethx file (x = NIC Index), the file name depend to your device name, for example my Linux Server
Only have 1 network card so the configuration will had name ifcfg-eth0.
The configuration file located at /etc/sysconfig/network-scripts directory.

Here the the network file configuration when assign static IP
DEVICE=eth0
BOOTPROTO=none #If DHCP, then change to yes
HWADDR=00:00:1C:0A:AC:60 #MAC Addr
ONBOOT=yes #Set active on boot
TYPE=Ethernet
NETWORK=192.168.1.0
NETMASK=255.255.255.0
IPADDR=192.168.1.10
USERCTL=no #Set Yes if you want te ordinary user change the Network configuratin
IPV6INIT=no
PEERDNS=yes
GATEWAY=192.168.1.254



Here for DHCP
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:00:1C:0A:AC:60
ONBOOT=yes
TYPE=Ethernet
#NETWORK=192.168.1.0
#NETMASK=255.255.255.0
#IPADDR=192.168.1.10
#USERCTL=no
DHCP_HOSTNAME=komputerku.rumahku.local
#IPV6INIT=no
#PEERDNS=yes
#GATEWAY=172.17.8.254


And here for DNS servers
nameserver: 192.168.1.1
nameserver: 192.168.1.2.


For the DNS server, you can edit the file resolv.conf, you can find that at /etc directory.

When you finished, then restart the Network service, you can use command "/sbin/service network restart"
or "/etc/init.d/network restart". You must have root privilege to run both those command.

No comments: