Trying to set a static IP with a fully qualified domain name on Redhat? Â But the command domainname still returns nothing? Here’s what you can do.
Backup the following files, then edit them:
/etc/sysconfig/network-scripts/ifcfg-eth0
IPADDR=192.168.2.201
NETMASK=255.255.255.0
GATEWAY=192.168.2.1
ONBOOT=yes
BOOTPROTO=none
(I’ve also seen “STATIC”, but mine is running with “none”)
/etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=black.testrac.com
/etc/resolv.conf
nameserver 192.168.2.1
cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.2.201 black.testrac.com black
/etc/nsswitch.conf needs a line:
hosts: files dns
You can also use the GUI tool:
/usr/bin/system-config-network &
to set a number of these parameters
You can then reset the network with commands:
Stop the network:
/etc/init.d/network stop
Start the network:
/etc/init.d/network start
or
/sbin/ifdown eth0
/sbin/ifup eth0
However, I prefer a full reboot to be sure. Recently, I had issues after rebooting that were not presenting themselves before. Turns out that two active ethernet ports are not better than one if the second is not plugged in.
Then double check your results:
ping hostname
ping fully.qualified.hostname.com
ping yahoo.com
route -v
hostname
ifconfig -a
But if your experience is like mine, you still get nothing when you run the command: domainname
Here is the secret to get domainname to work:
edit
/etc/sysctl.conf
add the line:
kernel.domainname=testrac.com
then, reinitialize the settings with:
/etc/sysctl -p
domainname
testrac.com
There, finally!
You must be logged in to post a comment.