Linux

Ubuntu18 - 多网卡配置

2020-09-17  本文已影响0人  红薯爱帅

1. 前言

在日常运维中,会碰到有多网卡的服务器,如果提前配置静态IP,可以不用找外接显示器,会简单方便很多。
配置好一个网卡的静态IP后,可以用交叉网线,一端连接服务器,一端连接笔记本,然后ssh即可。

如何配置多网卡的静态IP,本文简单介绍下。

2. 配置静态IP

2.1. 确认环境

$ cat /etc/issue
Ubuntu 18.04.4 LTS \n \l

$ ip a

2.2. 修改netplan配置文件

$ cat /etc/netplan/50-cloud-init.yaml 
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  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:
        enp1s0:
            dhcp4: true
        enp2s0:
            dhcp4: no
            addresses: [192.168.200.200/24]
            gateway4: 192.168.200.1
            nameservers:
                addresses: [114.114.114.114, 114.114.115.115]
    version: 2

2.3. 应用上述网络配置,并确认

$ sudo netplan apply
$ ip a

2.4. 注意

$ sudo systemctl enable ssh
静态IP:192.168.200.201
网关:192.168.200.1
掩码:255.255.255.0/24
上一篇 下一篇

猜你喜欢

热点阅读