在安装完CentOS系统后,就要对CentOS系统进行网络相关设置了,以便CentOS能够联网,下面小编给大家介绍下CentOS使用vim手动配置网络相关的方法,会涉及到一些命令使用,感兴趣的话可以来了解下。
网络相关的几个命令如下:
配置固定IP地址
[root@localhost~]#vi/etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost~]#cat/etc/sysconfig/network-scripts/ifcfg-eth0
#AdvancedMicroDevices[AMD]79c970[PCnet32LANCE]
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:0C:29:D1:A6:ED
ONBOOT=yes
IPADDR=192.168.160.11
NETMASK=255.255.255.0
BROARDCAST=192.168.160.255
GATEWAY=192.168.160.1
[root@localhost~]#/etc/init.d/networkrestart
Shuttingdowninterfaceeth0:[OK]
Shuttingdownloopbackinterface:[OK]
Bringinguploopbackinterface:[OK]
Bringingupinterfaceeth0:[OK]
[root@localhost~]#ifconfigeth0
eth0Linkencap:EthernetHWaddr00:0C:29:D1:A6:ED
inetaddr:192.168.160.11Bcast:192.168.160.255Mask:255.255.255.0
inet6addr:fe80::20c:29ff:fed1:a6ed/64Scope:Link
UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1
RXpackets:13960errors:0dropped:0overruns:0frame:0
TXpackets:4796errors:0dropped:0overruns:0carrier:0
collisions:0txqueuelen:1000
RXbytes:3749651(3.5MiB)TXbytes:480572(469.3KiB)
Interrupt:75Baseaddress:0x2000
配置DNS地址
[root@localhost~]#vi/etc/resolv.conf
[root@localhost~]#cat/etc/resolv.conf
searchlocaldomain
nameserver192.168.160.1
nameserver202.101.172.46
修改主机名
[root@localhost~]#vi/etc/sysconfig/network
[root@localhost~]#cat/etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=leekwen.leekwen
[root@localhost~]#ifconfigeth0
[root@localhost~]#vi/etc/resolv.conf
[root@localhost~]#cat/etc/resolv.conf
searchlocaldomain
nameserver192.168.160.1
nameserver202.101.172.46
上面就是CentOS使用vim配置网络相关的方法介绍了,需要配置固定ip地址、DNS地址、修改主机名,本文介绍的是在vim下的设置,需要用到vim文本编辑器。