问题:刚刚创建了一个centos虚拟机,网卡使用的桥接模式,无法联网,ifconfig提示“ifconfig:command not found”;
可通过ip addr查看网络配置
1.网络配置:
进入网卡配置目录:
cd /etc/sysconfig/network-scripts
复制ifcfg-ens33,起名为ifcfg-eth0
cp ifcfg-ens33 ifcfg-eth0
修改ifcfg-eth0文件
vi ifcfg-eth0
以下代码有则改,无则加
BOOTPROTO=static
NAME=eth0
ONBOOT=yes
#相关的ip配置
DNS1=114.114.114.114
IPADDR=192.168.10.166
NETMASK=255.255.255.0
GATEWAY=192.168.10.1
修改完后etc->:wq保存,重启网络服务
/etc/init.d/network restart
2.安装ifconfig命令
打开sbin目录,查看ifconfig命令是否存在,我这儿不存在
cd /sbin
ls
执行命令安装ifconfig
yum -y install net-tools
执行完成后,使用ifconfig运行正确
[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.166 netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80::27ab:ada4:715e:6f99 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:91:8f:6f txqueuelen 1000 (Ethernet)
RX packets 19818 bytes 1736421 (1.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 18001 bytes 2114883 (2.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 4 bytes 348 (348.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4 bytes 348 (348.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost ~]#