This commit is contained in:
63
Docs/Ubuntu配置网络.md
Normal file
63
Docs/Ubuntu配置网络.md
Normal file
@@ -0,0 +1,63 @@
|
||||
> 本文作者:丁辉
|
||||
|
||||
# Ubuntu配置网络
|
||||
|
||||
> 不同的 Ubuntu 版本, 可能配置方式不一样
|
||||
|
||||
## 配置动态获取IP
|
||||
|
||||
1. 编辑网络配置文件
|
||||
|
||||
```bash
|
||||
vi /etc/netplan/00-installer-config.yaml
|
||||
```
|
||||
|
||||
内容如下
|
||||
|
||||
```yaml
|
||||
network:
|
||||
ethernets:
|
||||
eth0:
|
||||
dhcp4: true
|
||||
```
|
||||
|
||||
2. 更新网络配置
|
||||
|
||||
```bash
|
||||
netplan apply
|
||||
```
|
||||
|
||||
## 配置静态IP
|
||||
|
||||
1. 编辑网络配置文件
|
||||
|
||||
```bash
|
||||
vi /etc/netplan/00-installer-config.yaml
|
||||
```
|
||||
|
||||
内容如下
|
||||
|
||||
```yaml
|
||||
network:
|
||||
ethernets:
|
||||
ens160:
|
||||
addresses:
|
||||
- 192.168.100.10/24 #本地IP
|
||||
nameservers:
|
||||
addresses:
|
||||
- 192.168.100.2 #dns配置
|
||||
- 114.114.114.114
|
||||
search: []
|
||||
routes:
|
||||
- to: default
|
||||
via: 192.168.100.2 #网关
|
||||
version: 2
|
||||
```
|
||||
|
||||
2. 更新网络配置
|
||||
|
||||
```bash
|
||||
netplan apply
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user