Linux-虚拟机下设置静态IP

1.桥接是必须的:







2.修改网络配置文件:

[oracle@Linux_Guoky home]$  su----------------------------------切换至root用户

Password: ------------------------ 输入root用户密码

[root@Linux_Guoky home]# cd /etc/sysconfig/network-scripts---------------------------切换路径至/etc/sysconfig/network-scripts

[root@Linux_Guoky network-scripts]# vi ifcfg-eth0-------------------------------------------编辑文件ifcfg-eth0

DEVICE=eth0
TYPE=Ethernet


ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.11.144


GATEWAY=192.168.11.254
DNS1=192.168.8.232
NETMASK=255.255.255.0

---------------------------------------------------------------------------------------------------------------------修改内容如上,:wq保存退出;

[root@Linux_Guoky network-scripts]# cat ifcfg-eth0 ----------------------------------------------查看修改结果

[root@Linux_Guoky network-scripts]# service network restart----------------------------------重启网络服务,使修改生效;

3.备注:

3.1

修改ifcfg-eth0之前,记得备份;

备份如下:

[root@Linux_Guoky network-scripts]# cp ifcfg-eth0  bak-ifcfg-eth0

cp含义----拷贝文件;

3.2

关于修改后的ifcfg-eth0文件说明:

DEVICE=eth0-------------------------------------------------设备名称
TYPE=Ethernet------------------------------------------------网络类型


ONBOOT=yes-------------------------------------------------开机自启动
NM_CONTROLLED=yes
BOOTPROTO=static----------------------------------------静态ip
IPADDR=192.168.11.144---------------------------------ip地址


GATEWAY=192.168.11.254------------------------------网关(可参考主机网关,查看主机网关可用cmd----ipconfig /all查看)
DNS1=192.168.8.232---------------------------------------DNS(参考主机DNS)
NETMASK=255.255.255.0--------------------------------子网掩码





你可能感兴趣的:(--------【VM虚拟机】,--------【LINUX】,★服务器)