DA-681 Linux
Managing Communications
3-5
/etc/hostname
1.
Mount the root file system with write permission.
MOXA:~# mount -o remount,rw /dev/hda1 /
2.
Edit
/etc/hostname
:
MOXA:~# vi /etc/hostname
MOXA
3.
After you finish writing or modifying the code, remember to execute “umount /” to change the root directory
back to Read-only mode.
MOXA:~# umount /
4.
Re-configure the hostname.
MOXA:~# /etc/init.d/hostname.sh start
5.
Check the new hostname.
MOXA:~# hostname
/etc/resolv.conf
This is the most important file that you need to edit when using DNS. For example, before you using
# ntpdate
time.nist.goc
to update the system time, you will need to add the DNS server address to the file. Ask your
network administrator which DNS server address you should use. The DNS server’s IP address is specified with
the
nameserver
command. For example, add the following line to /etc/resolv.conf (assuming the DNS
server’s IP address is 168.95.1.1):
nameserver 168.95.1.1
MOXA:/etc# cat resolv.conf
#
# resolv.conf This file is the resolver configuration file
# See resolver(5).
#
#nameserver 192.168.1.16
nameserver 168.95.1.1
nameserver 140.115.1.31
nameserver 140.115.236.10
MOXA:/etc#
/etc/nsswitch.conf
This file defines the sequence of files,
/etc/hosts
or
/etc/resolv.conf
, to be read to resolve the IP address.
The
hosts
line in
/etc/nsswitch.conf
means use
/etc/host
first and DNS service to resolve the address.
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try: