ak@mac:/etc/netplan$ route -n
内核 IP 路由表
目标 网关 子网掩码 标志 跃点 引用 使用 接口
0.0.0.0 192.168.200.2 0.0.0.0 UG 20100 0 0 ens33
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 ens33
192.168.200.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
查看网关配置文件位置
ak@mac:/etc/netplan$ netplan -h
usage: /usr/sbin/netplan [-h] [--debug] ...
Network configuration in YAML
optional arguments:
-h, --help show this help message and exit
--debug Enable debug messages
Available commands:
help Show this help message
apply Apply current netplan config to running system
generate Generate backend specific configuration files from
/etc/netplan/*.yaml
ip Retrieve IP information from the system
try Try to apply a new netplan config to running system, with
automatic rollback
修改文件(建议先备份)
ak@mac:~$ cd /etc/netplan/
ak@mac:/etc/netplan$ ls
01-network-manager-all.yaml
ak@mac:/etc/netplan$ sudo cp 01-network-manager-all.yaml 01-network-manager-all.yaml.back //建议先备份
ak@mac:/etc/netplan$ sudo vim 01-network-manager-all.yaml //修改文件
ak@mac:/etc/netplan$ cat 01-network-manager-all.yaml //修改内容
应用配置,使其生效
ak@mac:/etc/netplan$ sudo netplan apply
ping任意网址查看是否联网
ak@mac:/etc/netplan$ ping www.baidu.com
PING www.a.shifen.com (14.119.104.189) 56(84) bytes of data.
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=1 ttl=128 time=6.61 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=2 ttl=128 time=6.93 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=3 ttl=128 time=9.09 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=4 ttl=128 time=7.76 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=5 ttl=128 time=7.12 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=6 ttl=128 time=7.55 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=7 ttl=128 time=6.46 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=8 ttl=128 time=6.83 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=9 ttl=128 time=6.55 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=10 ttl=128 time=6.45 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=11 ttl=128 time=6.60 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=12 ttl=128 time=6.48 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=13 ttl=128 time=6.46 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=14 ttl=128 time=7.29 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=15 ttl=128 time=6.74 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=16 ttl=128 time=6.85 ms
^C
--- www.a.shifen.com ping statistics ---
16 packets transmitted, 16 received, 0% packet loss, time 15027ms
rtt min/avg/max/mdev = 6.450/6.988/9.094/0.672 ms
ak@mac:/etc/netplan$