1. Ubuntu18.04 修改IP地址
因为Ubuntu18.04采用的是netplan来管理network。所以可以在/etc/netplan/
目录下创建
一个以yaml结尾的文件。比如01-netplan.yaml文件。
修改 sudo vim /etc/netplan/50-cloud-init.yaml
文件
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# This file is generated from information provided by # the datasource. Changes to it will not persist across an instance. # To disable cloud-init's network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: ethernets: enp0s3: addresses: [192.168.33.34/24] gateway4: 192.168.33.1 dhcp4: no version: 2 |
特别要注意的是这里的每一行的空格一定要有的,否则会报错误而设置失败!
运行sudo netplan apply
使配置生效,通过ifconfig
查看ip是否配置成功
2. 查看网关
1 2 |
route -n netstat -r |
3. 防火墙开启/关闭
1 2 |
ufw enable ufw disable |
发表评论
沙发空缺中,还不快抢~