ubuntu 从17.10开始,改成netplan方式配置IP,配置写在/etc/netplan/01-n服务器托管网etwork-manager-all.yaml或者类似名称的yaml文件里。
1、查看你要设置静态IP的网卡名称
通过ifconfig命令,查看到网卡的名字为enp1s0
test@test:/etc/netplan$ ifconfig
enp1s0: flags=4163 mtu 1500
inet 192.168.100.110 netmask 255.255.255.0 broadcast 192.168.100.255
inet6 fe80::5054:ff:fe54:a819 prefixlen 64 scopeid 0x20
ether 52:54:00:54:a8:19 txqueuelen 1000 (Ethernet)
RX packets 352291 bytes 404510742 (404.5 MB)
RX errors 0 dropped 17674 overruns 0 frame 0
TX packets 172029 bytes 32435361 (32.4 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 7029 bytes 3959595 (3.9 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 7029 bytes 3959595 (3.9 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
3、通过netplan的yaml文件配置静态IP
使用vi打开/etc/netplan/00-installer-config.yaml或者类似名称的yaml文件配置文件后
test@test:/etc/netplan$ cd /etc/netplan/
test@test:/etc/netplan$ ls
00-installer-config.yaml
修改或增加如下图所示内容(第2到12行):
sudo vi /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
enp1s0:
dhcp4: no
addresses: [192.168.100.86/24]
routes:
- to: default
via: 192.168.100.1
nameservers:
addresses: [114.114.114.114,8.8.8.8]
search: [localhost,local]
version: 2
4、让静态IP生效
通过以下命令或者重启系统后,网卡enp1s0的静态IP地址就设置好了。
test@test:/etc/netplan$ sudo netplan apply
服务器托管,北京服务服务器托管网器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
在C++中,可以将虚函数声明为纯虚函数,语法格式为: virtual 返回值类型 函数名 (函数参数) = 0; 纯虚函数没有函数体,只有函数声明,在虚函数声明的结尾加上=0,表明此函数为纯虚函数。 最后的=0并不表示函数返回值为0,它只起形式上的作用,告诉编…