linux配置网络

来源:互联网 发布:cv2.calchist python 编辑:程序博客网 时间:2024/06/06 12:42
先用查看网卡 
ifconfig 


配网络
setup


重启网卡
/etc/init.d/network restart


网卡的配置文件
vi /etc/sysconfig/network-scripts/ifcfg-eth0


干掉(dd删除一行)  :wq保存    :q!不保存
hWADDR
UNID


把ONBOOT改成
yes


重启网卡
/etc/init.d/network restart


查看网络
ifconfig eth0


桥接模式
setup---networkconfiguration----dev
去掉DHCP
再tab 键配置IP


重启网卡
/etc/init.d/network restart


查看能不能上网
ping g.cn
查主机名字
hostname


修改主机名字
vi /etc/sysconfig/network


vi /etc/hosts


重启服务器
reboot


7:修改主机名字
vi /etc/sysconfig/network


NETWORKING=yes
HOSTNAME=zabbix
GATEWAY=172.19.16.2


vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.19.16.228 zabbix
改名成功
[root@localhost ~]# hostname zabbix
[root@localhost ~]# hostname

zabbix


vi /etc/hostname 

172.19.16.228 zabbix

[nfyguser@server-7b0db96e ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eth0 
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"

3、同样地,清除 /etc/udev/rules.d文件的网络设备命名规则,因为这些规则将从实例的网卡获得。
rm -rf /etc/udev/rules.d/70-persistent-net.rules