ubuntu 18.04.3 server 配置IP

采用修改这个文件/etc/network/interfaces ,改ip的方式在ubuntu 18里行不通:

临时配置IP方法如下:
sudo ip addr add 192.168.87.145/24 dev enp125s0f0

ip link set dev enp125s0f0 up; ip link set dev enp125s0f0 down
To verify the IP address configuration of enp125s0f0, you can use the ip command in the following manner.
ip address show dev enp125s0f0

上面的方面是临时生效,要想让这个配置长期生效,需要修改如下的配置文件:

infokist-arm:~$ cat /etc/netplan/99_config.yaml 
network:
  version: 2
  renderer: networkd
  ethernets:
    enp125s0f0:
      addresses:
        - 192.168.87.145/24
      gateway4: 192.168.87.1
      nameservers:
        search: [mydomain, otherdomain]
        addresses: [192.168.88.10,223.5.5.5]
    enp130s0f0:
      addresses:
        - 10.168.85.145/24
scutech@infokist-arm:~$ 

注意这个配置文件的缩进格式。

The configuration can then be applied using the netplan command.
sudo netplan apply

猜你喜欢

转载自blog.csdn.net/weixin_43424368/article/details/107875072