1. 程式人生 > >Ubuntu 網絡配置

Ubuntu 網絡配置

available activate describes network 微軟雅黑

1、默認情況下Ubuntu 的網絡配置文件為: sudo vim /etc/network/interfaces

# 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 ens33
iface ens33 inet static
#靜態IP,如果需要設置成DHCP模式,那下面這3行已經不需要了,直接改成: iface ens33 inet dhcp
address 10.6.2.171
network 255.255.255.0
gateway 10.6.2.254

也可以手動增加靜態路由:sudo route add default gw 10.6.2.254

2、配置DNS

默認情況下是修改:sudo vim /etc/resolv.conf

nameserver 10.6.1.1
nameserver 10.1.1.1

3、重啟網絡服務

sudo /etc/init.d/networking reload

sudo /etc/init.d/networking restart

停卡網卡:

sudo ifconfig ens33 down

sudo ifconfig ens33 up

4、如果是虛擬機克隆,可能會導致網卡檢測不到或者啟動不起來

sudo rm /etc/udev/rules.d/70-persistent-net.rules
把這個文件刪掉,再重啟Ubuntu 服務器就可以了。

5、更改服務器名

sudo hostnamectl set-hostname USRV-1

重啟,即可


Ubuntu 網絡配置