如何将虚拟机中centos版本的linux的ip地址与域名相互解析

如何将虚拟机中centos版本的linux的ip地址与域名相互解析,第1张

如果机器比较少\x0d\\x0d\可直编辑文件 /etc/hosts 在其中加入ip与名字的对应项目。\x0d\\x0d\命令\x0d\\x0d\vim /etc/hosts\x0d\内容例\x0d\1921681201 test1democom\x0d\192168120 test2democom\x0d\192168121 svctag-ftp\x0d\如果机器比较多,\x0d\可以搭建自己的dns服务器。(yum install bind)\x0d\然后修改/etc/resolvconf\x0d\将自己的dns服务的IP地址写入。\x0d\/etc/resolvconf内容例\x0d\\x0d\nameserver 192168153

一、 自动获取IP,一般自动获取ip跟4个文件有关系

1 /etc/sysconfig/network-scripts/ifcfg-eth0

[root@web-1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0 //由eth0来启动

BOOTPROTO=dhcp //获取IP的方式是自动获取,static是固定IP,none是手动

HWADDR=00:0c:29:62:9a:a2 //网卡的物理地址

NM_CONTROLLED=yes

ONBOOT=no //启动时网络接口是否有效

TYPE=Ethernet

UUID="ed818867-f233-4909-a55d-856833ffce9e"

USERCTL=no

IPV6INIT=no //是否支持IP6

PEERDNS=yes

2 /etc/sysconfig/network

[root@web-1 ~]# vi /etc/sysconfig/network

NETWORKING=yes //网络是否可用

HOSTNAME=web-1 //主机名,主机名在/etc/hosts里面配置

3 /etc/hosts

[root@web-1 ~]# vi /etc/hosts

127001 localhost localhostlocaldomain localhost4 localhost4localdomain4

::1 localhost localhostlocaldomain localhost6 localhost6localdomain6

4 /etc/resolvconf

[root@web-1 ~]# vi /etc/resolvconf

; generated by /sbin/dhclient-script

search localdomain //搜索要找的域名,在/etc/hosts里面设定的有

nameserver 1921681742 //DNS服务器对应的IP

如果想要自动获取IP地址,只需要/etc/sysconfig/network-scripts/ifcfg-eth0文件中的 ONBOOT=no 改为ONBOOT=yes 然后执行下面命令就可以了

[root@web-1 ~]# service network restart

Linux主机名

hostname ceshicom

mv /etc/sysconfig/network /etc/sysconfig/network_bak

echo "NETWORKING=YES" >>/etc/sysconfig/network

echo "HOSTNAME=ceshicom" >>/etc/sysconfig/network

mv /etc/hosts /etc/hosts_bak

echo "127001 ceshicom" >>/etc/hosts

以上就是关于如何将虚拟机中centos版本的linux的ip地址与域名相互解析全部的内容,包括:如何将虚拟机中centos版本的linux的ip地址与域名相互解析、如何修改 centos 自动获取ip、centos服务器 怎么绑定域名等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/9306032.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-27
下一篇2023-04-27

发表评论

登录后才能评论

评论列表(0条)

    保存