zoukankan      html  css  js  c++  java
  • ubuntu网卡配置

    网卡配置文件采用YAML格式,必须以 /etc/netplan/XXX.yaml 文件命名方式存放
    可以每个网卡对应一个单独的配置文件,也可以将所有网卡都放在一个配置文件里

    自动获取IP

    root@ubuntu1804:~# cat /etc/netplan/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:
        eth0:
    	  dhcp4: yes
    
    # 修改网卡配置文件后需执行命令生效:
    root@ubuntu1804:~#netplan apply
    

    配置静态IP

    root@ubuntu1804:~#vim /etc/netplan/01-netcfg.yaml
    network:
      version: 2
      renderer: networkd
    ethernets:
      eth0:
        dhcp4: no
        addresses: [192.168.8.10/24,10.0.0.10/8]  #或者用下面两行,两种格式不能混用
        - 192.168.8.10/24
        - 10.0.0.10/8
        gateway4: 10.0.0.2
        nameservers:
        search: [baidu.com, google.org]
          addresses: [114.114.114.114, 8.8.8.8, 1.1.1.1]
    

    image

    配置多网卡静态IP和静态路由

    root@ubuntu1804:~#vim  /etc/netplan/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:
        eth0:
          dhcp4: no
          dhcp6: no
          addresses: [10.0.0.100/16]
          gateway4: 10.0.0.2
          nameservers:
            addresses: [223.6.6.6]
        eth1:
          dhcp4: no
          dhcp6: no 
          addresses: [10.20.0.100/16]
          routes:
         - to: 10.30.0.0/16
           via: 10.20.0.1
         - to: 10.40.0.0/16
         via: 10.20.0.1
         - to: 10.50.0.0/16
         via: 10.20.0.1
         - to: 10.60.0.0/16
         via: 10.20.0.1
    
    root@ubuntu1804:~#netplan apply
    root@ubuntu1804:~#route -n
    Kernel IP routing table
    Destination   Gateway     Genmask     Flags Metric Ref  Use Iface
    0.0.0.0     10.0.0.2     0.0.0.0     UG   0    0     0 eth0
    10.0.0.0     0.0.0.0     255.255.0.0   U   0    0     0 eth0
    10.20.0.0    0.0.0.0     255.255.0.0   U   0    0     0 eth1
    10.30.0.0    10.20.0.1    255.255.0.0   UG   0    0     0 eth1
    10.40.0.0    10.20.0.1    255.255.0.0   UG   0    0     0 eth1
    10.50.0.0    10.20.0.1    255.255.0.0   UG   0    0     0 eth1
    10.60.0.0    10.20.0.1    255.255.0.0   UG   0    0     0 eth1
    
  • 相关阅读:
    在jenkins中新建节点,启动方式中没有“通过java web启动”
    在jenkins上执行web自动化脚本出现cannot find Chrome binary
    修改禅道的默认端口
    jmeter修改字体大小
    电脑中安装了两个版本的jdk,后装的会把第一个覆盖掉
    各种浏览器的驱动
    js中的null和undefined总结
    关于 es6的 let 特性在 for 循环结构 的个人理解
    ajax五,jsonp跨域的本质
    ajax四,封装ajax并优化
  • 原文地址:https://www.cnblogs.com/firewalld/p/14666976.html
Copyright © 2011-2022 走看看