linux配置ip

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

DEVICE=eth0
HWADDR=00:0C:29:0B:E9:46
TYPE=Ethernet
UUID=290c1baf-9236-461a-86de-f702d94457f2
#开机启用
ONBOOT=yes
NM_CONTROLLED=yes
#静态IP
BOOTPROTO=static

#BROADCAST=192.168.134.255
#IP地址
IPADDR=192.168.134.150
#子网掩码
NETMASK=255.255.255.0
#NETWORK=192.168.134.0
#网关
GATEWAY=192.168.134.2
#配置DNS
DNS1=114.114.114.114
DNS2=10.203.104.41

重启网卡生效
centos6的网卡重启方法:service network restart
centos7的网卡重启方法:systemctl restart network

ok

其它ip相关命令

centos 查看网关的命令

1.ifconfig -a 和 cat /etc/resolv.conf (主要查看ip/netmask和dns)

2.netstat -rn

3.cat /etc/sysconfig/network

4.cat /etc/sysconfig/network-scripts/ifcfg-eth0

5.traceroute 第一行就是自己的网关

6.ip route show

7.route -n

复制虚拟机后,开机选择 移动虚拟机 网卡启动失败

[root@c1node01 ~]# service network restart
Shutting down loopback insterface:                                                       [   OK  ]
Bringing up loopback insterface:                                                            [   OK  ]
Bringing up interface eth0:  Device eth0 does not seem to be present,delaying initialization.                    [FAILED]
方案1
rm -rf /etc/udev/rules.d/70-persistent-net.rules
重启虚拟机
方案2
/etc/sysconfig/network-scripts/ifcfg-eth0 
重命名为eth1
打开文件 
DEVICE="eth1"
删掉uuid、物理地址
重启网卡
posted @ 2019-07-08 09:54  _DC  阅读(13607)  评论(0编辑  收藏  举报