码迷,mamicode.com
首页 > Web开发 > 详细

Ubuntu 18 LTS netplan 网络配置

时间:2019-04-26 21:17:52      阅读:588      评论:0      收藏:0      [点我收藏+]

标签:The   describes   div   load   ifconfig   sse   网络服务   optional   lob   

一、配置网络

1、通过netplan配置网络

#配置网络
nulige@ubuntu:/etc/netplan$ sudo apt install ifupdown

nulige@ubuntu:/etc/netplan$ cd /etc/netplan

nulige@ubuntu:/etc/netplan$ sudo vi 01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    ens33:
      addresses: [192.168.56.11/24]
      gateway4: 192.168.56.2
      nameservers:
        addresses: [192.168.56.2, 8.8.8.8]      
      dhcp4: no
      optional: no

nulige@ubuntu:/etc/netplan$ sudo netplan apply

nulige@ubuntu:/etc/netplan$ ip a
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:2b:1a:b2 brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.11/24 brd 192.168.56.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe2b:1ab2/64 scope link 
       valid_lft forever preferred_lft forever

2、配置一个网卡,两个IP地址

nulige@ubuntu:~$ cat /etc/network/interfaces
#sudo apt install ifupdown
auto lo
iface lo inet loopback

auto ens33
iface ens33 inet static
address 192.168.56.11
netmask 255.255.255.0
gateway 192.168.56.2

eg1:重启网络服务

sudo /etc/init.d/networking force-reload ==> 重新加载网路配置文件
sudo /etc/init.d/networking restart

eg2:重新启停以太网卡:

sudo ifconfig eth0 down
sudo ifconfig eth0 up

  

 

Ubuntu 18 LTS netplan 网络配置

标签:The   describes   div   load   ifconfig   sse   网络服务   optional   lob   

原文地址:https://www.cnblogs.com/nulige/p/10776369.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!