centos虚拟机网卡配置参数实例
时间: 2023-02-05 11:44:12 浏览: 77
在 CentOS 虚拟机中,可以使用命令行工具 `ifconfig` 来配置网卡。
例如,要为网卡 `eth0` 配置 IP 地址 `192.168.1.100`,子网掩码 `255.255.255.0`,网关 `192.168.1.1`,可以使用如下命令:
```
ifconfig eth0 192.168.1.100 netmask 255.255.255.0
route add default gw 192.168.1.1 eth0
```
要查看网卡的配置信息,可以使用 `ifconfig` 命令,例如:
```
ifconfig eth0
```
还可以使用 `ip` 命令来管理网卡。例如,要为网卡 `eth0` 配置 IP 地址 `192.168.1.100`,子网掩码 `255.255.255.0`,网关 `192.168.1.1`,可以使用如下命令:
```
ip addr add 192.168.1.100/24 dev eth0
ip route add default via 192.168.1.1 dev eth0
```
要查看网卡的配置信息,可以使用 `ip` 命令,例如:
```
ip addr show eth0
```
此外,还可以使用 `vi` 编辑器修改网卡的配置文件 `/etc/sysconfig/network-scripts/ifcfg-eth0`。
例如,要为网卡 `eth0` 配置 IP 地址 `192.168.1.100`,子网掩码 `255.255.255.0`,网关 `192.168.1.1`,可以将该文件修改为如下内容:
```
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
```
然后使用