1关闭图形化界面 vi /etc/inittab 改成id:3:initdefault: 注意:不要选0或6 2.修改主机名 vi /etc/sysconfig/network 修改即可 3,修改ip地址 vi /etc/sysconfig/network-scripts/ifcfg-eth0 4.将ip地址与主机名进行绑定 修改/etc/hosts文件绑定IP地址
(一)基本操作修改 修改主机名 vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=server1.itcast.cn 修改ip地址 vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 TYPE=Ethernet ONBOOT=yes BOOTPROTO=static IPADDR=192.168.0.101 NETMASK=255.255.255.0 service network r
修改虚拟机的主机ip 和hostname import os, sys def conf_ip(ip): iplist = [] f = open("/etc/sysconfig/network-scripts/ifcfg-eth0", "r+") for i in f: iplist.append('BOOTPROTO="static"\n' if 'BOOTPROTO=' in i else i) iplist.extend(['IPADDR