Tuesday, September 7, 2010

rhel & changing network settings

I am not fond of GUIs and enjoy editing configuration files by hand; sure it can be dangerous if you don't know what you're doing - but if you do and don't like GUIs mangling stuff, hand confs are the way to go. Here's how to change RHEL's network conf files - notice the differences between RedHat and Ubuntu.

Edit configuration files stored in /etc/sysconfig/network-scripts/ , /etc/sysconfig & /etc

First, edit network interface card files: 

 * /etc/sysconfig/network-scripts/ifcfg-eth0
 * /etc/sysconfig/network-scripts/ifcfg-eth1 &c.

## Intel Corporation 82573E Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=00:30:48:56:A6:2E
IPADDR=192.168.10.3
NETMASK=255.255.255.192
ONBOOT=yes


Edit the file which contains gatway and hostname:

 * /etc/sysconfig/network

## network
NETWORKING=yes
HOSTNAME=super.silly.domain.com
GATEWAY=192.168.10.1


Edit DNS server configuration file:

 * /etc/resolv.conf file:

## resolv.conf
search domain.com silly.domain.com
nameserver 192.168.10.1
nameserver 192.168.10.2
domain domain.com


Restart networking:

# /etc/init.d/network restart

Do a couple tests:

$ ping 192.168.10.1

Output:

PING 192.168.10.1 (192.168.10.1) 56(84) bytes of data.
64 bytes from 192.168.10.1: icmp_seq=1 ttl=251 time=0.972 ms
64 bytes from 192.168.10.1: icmp_seq=2 ttl=251 time=1.11 ms

You can also check for Internet connectivity with nslookup or host command:

$ nslookup not.silly.domain.com
Output:

Server:         192.168.10.1
Address:        192.168.10.1#53

Non-authoritative answer:
Name:   not.silly.domain.com
Address:192.168.10.4

No comments: