Linux配置网卡

进行操作前请先查一下你的网卡叫什么名字,可以用ip addr或者ifconfig,会列出系统所有的网卡,第一个一般是localhost(本地环回),它的名字叫lo,下面的是其他网卡,有线网卡一般叫enp3s0之类的名字。知道了网卡的名字,接下来我们要去配置它。 首先要先要获取root权限,这样我们对配置文件才有写权限。 Debian系 以UbuntuServer 16.04为例 它的配置文件是/etc/network/interface 我们使用 vim 来编辑这个文件。 在本地环回下新建网卡配置为 static 或者 dhcp 如果使用静态IP,我们要配置这几个值: auto yourNIC iface yourNIC inet static address xxx.xxx.xx.xx netmask xxx.xxx.xx.xx gateway xx.xxx.xxx.xx dns-nameservices x.x.x.x x.x.x.x 如果该网卡是无线网卡,需要添加: wpa-ssid yourssid wpa-psk yourpasswd # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto enp3s0 iface enp3s0 inet static address 192....

July 6, 2018