ubuntu 17.10 配置静态IP地址
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu 17.10 配置静态IP地址相关的知识,希望对你有一定的参考价值。
系统安装完成之后默认是动态分配IP
[email protected]:~$ ifconfig ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.209.221 netmask 255.255.255.0 broadcast 192.168.209.255 inet6 fe80::20c:29ff:fe9b:2437 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:9b:24:37 txqueuelen 1000 (Ethernet) RX packets 632 bytes 78029 (78.0 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 440 bytes 56139 (56.1 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 102 bytes 7728 (7.7 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 102 bytes 7728 (7.7 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
之前的版本是在/etc/network/interfaces中修改,新版本使用/etc/netplan/*.yaml
[email protected]:~$ cat /etc/netplan/01-netcfg.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: ens32: dhcp4: yes
编辑YAML文件配置IP信息
[email protected]:~$ sudo vim /etc/netplan/01-netcfg.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: ens32: dhcp4: no dhcp6: no addresses: [192.168.209.221/24] gateway4: 192.168.209.2 nameservers: addresses: [8.8.8.8, 114.114.114.114]
执行命令让配置生效:
[email protected]:~$ sudo netplan apply
显示debug信息
[email protected]:~$ sudo netplan --debug apply ** (generate:2842): DEBUG: Processing input file //etc/netplan/01-netcfg.yaml.. ** (generate:2842): DEBUG: starting new processing pass ** (generate:2842): DEBUG: ens32: setting default backend to 1 ** (generate:2842): DEBUG: Generating output files.. ** (generate:2842): DEBUG: NetworkManager: definition ens32 is not for us (backend 1) DEBUG:netplan generated networkd configuration exists, restarting networkd DEBUG:no netplan generated NM configuration exists DEBUG:device ens32 operstate is up, not replugging DEBUG:netplan triggering .link rules for ens32 DEBUG:device lo operstate is unknown, not replugging DEBUG:netplan triggering .link rules for lo
netplan 其他参数指令:
netplan generate: 执行后使用 /etc/netplan 生成/run/systemd/network/10-netplan-ens32.network
netplan ifupdown-migrate: 尝试从/etc/network/interfaces转换成netplan需要的yaml格式,如果转换成功会禁止使用/etc/network/interfaces
本文出自 “网络收藏夹” 博客,请务必保留此出处http://liyaoyi.blog.51cto.com/442933/1983481
以上是关于ubuntu 17.10 配置静态IP地址的主要内容,如果未能解决你的问题,请参考以下文章