Ubuntu 20.04.2 LTS Netplan 配置网络

使用NetPlan网络管理工具配置网卡.

1、单网卡配置dhcp获取地址;

root@ubuntu20:~# cat /etc/netplan/00-installer-config.yaml
# This is the network config written by ‘subiquity‘
network:
  ethernets:
    ens3:
      dhcp4: yes
  version: 2

2、配置Bond网卡;

  network:
  version: 2
  renderer: networkd
  ethernets:
    enp3s0:
      dhcp4: no
  bridges:
    br0:
      dhcp4: yes
      interfaces:
      - enp3s0
      - enp3s1

3、配置桥接网卡;

network:
    version: 2
    renderer: networkd
    ethernets:
        enp3s0:
            dhcp4: no
    bridges:
        br0:
            dhcp4: yes
            interfaces:
                - enp3s0

4、单网卡配置静态ip地址,网关,dns;

network:
    version: 2
    renderer: networkd
    ethernets:
        enp3s0:
            addresses:
                - 10.10.10.2/24
            gateway4: 10.10.10.1
            nameservers:
                search: [mydomain, otherdomain]
                addresses: [10.10.10.1, 1.1.1.1]

5、多网卡配置dhcp,设置路由开销;

network:
    version: 2
    ethernets:
        enred:
            dhcp4: yes
            dhcp4-overrides:
                route-metric: 100
        engreen:
            dhcp4: yes
            dhcp4-overrides:
                route-metric: 200

6、配置无线网卡连接不加密网络;

network:
    version: 2
    wifis:
        wl0:
            access-points:
                opennetwork: {SSID}
            dhcp4: yes

7、配置无线网卡连接WPA个人加密网络;

network:
    version: 2
    renderer: networkd
    wifis:
        wlp2s0b1:
            dhcp4: no
            dhcp6: no
            addresses: [192.168.0.21/24]
            gateway4: 192.168.0.1
            nameservers:
                addresses: [192.168.0.1, 8.8.8.8]
            access-points:
                "network_ssid_name":
                    password: "**********"

8、配置企业加密网络认证;

network:
    version: 2
    wifis:
        wl0:
            access-points:
                workplace:
                    auth:
                        key-management: eap
                        method: ttls
                        anonymous-identity: "@internal.example.com"
                        identity: "joe@internal.example.com"
                        password: "v3ryS3kr1t"
            dhcp4: yes

9、配置企业加密网络证书认证;

network:
    version: 2
    wifis:
        wl0:
            access-points:
                university:
                    auth:
                        key-management: eap
                        method: tls
                        anonymous-identity: "@cust.example.com"
                        identity: "cert-joe@cust.example.com"
                        ca-certificate: /etc/ssl/cust-cacrt.pem
                        client-certificate: /etc/ssl/cust-crt.pem
                        client-key: /etc/ssl/cust-key.pem
                        client-key-password: "d3cryptPr1v4t3K3y"
            dhcp4: yes

?

10、单网卡配置多个ip地址,网关;

network:
    version: 2
    renderer: networkd
    ethernets:
        enp3s0:
         addresses:
             - 10.100.1.38/24
             - 10.100.1.39/24
         gateway4: 10.100.1.1

11、配置静态路由,路由开销;

network:
    version: 2
    renderer: networkd
    ethernets:
        enp3s0:
         addresses:
             - 9.0.0.9/24
             - 10.0.0.10/24
             - 11.0.0.11/24
         #gateway4:  # unset, since we configure routes below
         routes:
             - to: 0.0.0.0/0
                 via: 9.0.0.1
                 metric: 100
             - to: 0.0.0.0/0
                 via: 10.0.0.1
                 metric: 100
             - to: 0.0.0.0/0
                 via: 11.0.0.1
                 metric: 100

12、配置使用NetworkManager作为后端管理服务;

network:
    version: 2
    renderer: NetworkManager

13、配置双网卡绑定,mode为active-backup;

network:
    version: 2
    renderer: networkd
    bonds:
        bond0:
            dhcp4: yes
            interfaces:
                - enp3s0
                - enp4s0
            parameters:
                mode: active-backup
                primary: enp3s0

14、配置多网卡绑定,option:true,不等待网卡激活,启动bond;

network:
    version: 2
    renderer: networkd
    ethernets:
        enp1s0:
            dhcp4: no
        enp2s0:
            dhcp4: no
        enp3s0:
            dhcp4: no
            optional: true
        enp4s0:
            dhcp4: no
            optional: true
        enp5s0:
            dhcp4: no
            optional: true
        enp6s0:
            dhcp4: no
            optional: true
    bonds:
        bond-lan:
            interfaces: [enp2s0, enp3s0]
            addresses: [192.168.93.2/24]
            parameters:
                mode: 802.3ad
                mii-monitor-interval: 1
        bond-wan:
            interfaces: [enp1s0, enp4s0]
            addresses: [192.168.1.252/24]
            gateway4: 192.168.1.1
            nameservers:
                search: [local]
                addresses: [8.8.8.8, 8.8.4.4]
            parameters:
                mode: active-backup
                mii-monitor-interval: 1
                gratuitious-arp: 5
        bond-conntrack:
            interfaces: [enp5s0, enp6s0]
            addresses: [192.168.254.2/24]
            parameters:
                mode: balance-rr
                mii-monitor-interval: 1

15、配置桥接网络,并打上VLAN标记;

network:
    version: 2
    renderer: networkd
    ethernets:
        enp0s25:
            dhcp4: true
    bridges:
        br0:
            addresses: [ 10.3.99.25/24 ]
            interfaces: [ vlan15 ]
    vlans:
        vlan15:
            accept-ra: no
            id: 15
            link: enp0s25

16、配置多个VLAN标记;

network:
    version: 2
    renderer: networkd
    ethernets:
        mainif:
            match:
                macaddress: "de:ad:be:ef:ca:fe"
            set-name: mainif
            addresses: [ "10.3.0.5/23" ]
            gateway4: 10.3.0.1
            nameservers:
                addresses: [ "8.8.8.8", "8.8.4.4" ]
                search: [ example.com ]
    vlans:
        vlan15:
            id: 15
            link: mainif
            addresses: [ "10.3.99.5/24" ]
        vlan10:
            id: 10
            link: mainif
            addresses: [ "10.3.98.5/24" ]
            nameservers:
                addresses: [ "127.0.0.1" ]
                search: [ domain1.example.com, domain2.example.com ]

17、配置直链路由;

IPV4配置

network:
    version: 2
    renderer: networkd
    ethernets:
        addresses: [ "10.10.10.1/24" ]
        routes:
            - to: 0.0.0.0/0
                via: 9.9.9.9
                on-link: true

IPV6配置

network:
    version: 2
    renderer: networkd
    ethernets:
        addresses: [ "2001:cafe:face:beef::dead:dead/64" ]
        routes:
            - to: "2001:cafe:face::1/128"
                scope: link
            - to: "::/0"
                via: "2001:cafe:face::1"
                on-link: true

18、配置策略路由;

network:
    version: 2
    renderer: networkd
    ethernets:
        ens3:
            addresses:
             - 192.168.3.30/24
            dhcp4: no
            routes:
             - to: 192.168.3.0/24
                 via: 192.168.3.1
                 table: 101
            routing-policy:
             - from: 192.168.3.0/24
                 table: 101
        ens5:
            addresses:
             - 192.168.5.24/24
            dhcp4: no
            gateway4: 192.168.5.1
            routes:
             - to: 192.168.5.0/24
                 via: 192.168.5.1
                 table: 102
            routing-policy:
            - from: 192.168.5.0/24
                table: 102

19、配置环回口地址;

network:
    version: 2
    renderer: networkd
    ethernets:
        lo:
            match:
                name: lo
            addresses: [ 7.7.7.7/32 ]

20、Windows dhcp配置参考;

network:
    version: 2
    ethernets:
        enp3s0:
            dhcp4: yes
            dhcp-identifier: mac

21、配置IP通道;

network:
    version: 2
    ethernets:
        eth0:
            addresses:
                - 1.1.1.1/24
                - "2001:cafe:face::1/64"
            gateway4: 1.1.1.254
    tunnels:
        he-ipv6:
            mode: sit
            remote: 2.2.2.2
            local: 1.1.1.1
            addresses:
                - "2001:dead:beef::2/64"
            gateway6: "2001:dead:beef::1"

22、配置SR-IOV 子网卡

network:
    version: 2
    ethernets:
        eno1:
            mtu: 9000
        enp1s16f1:
            link: eno1
            addresses : [ "10.15.98.25/24" ]
        vf1:
            match:
                name: enp1s16f[2-3]
            link: eno1
            addresses : [ "10.15.99.25/24" ]

?

上一篇:JVM解毒——JVM与Java体系结构


下一篇:Kali Linux 安装 Burp Suite Professional v2021.12 教程