Ubuntu 22.04 複数のインターフェースによるインターネット接続の共有

Ubuntu 22.04 複数のインターフェースによるインターネット接続の共有

私が使うLubuntu 22.04 LTS と Cinnamon正確にはデスクトップです。

マザーボード上に 1 つのインターフェースを持つネットワーク デバイスが 1 つあります。

エンプ5s0私のISPルーターに接続されており、固定されている192.168.1.19/24 のIPアドレス

4 つのインターフェースを持つ別のネットワーク デバイスがあります。

ここに画像の説明を入力してください

この 2 番目のネットワーク デバイスをルーターとして使用したいのですが、どうすればよいでしょうか?

今のところ、方法を変更して IP を編集することで、1 つのインターフェースにのみ共有できます。

共有 enp7s4f0 インターフェース

答え1

ネットブート サーバーのセットアップを探して解決策を見つけました:

  1. 2番目のデバイスからenp7f4s0と一致するようにすべてのインターフェイスを編集しました(IPも同じです)インターフェース_IP_config
  2. dnsmasqをインストールしました:

sudo apt install dnsmasq

  1. 提案されているように設定ファイルを作成しましたUbuntu.com ネットブートについて構成。

touch /etc/dnsmasq.d/pxe.conf

  1. 私は編集しましたpxe.confファイルは次のようになります:

    interface=enp5s0,lo

    bind-interfaces

    dhcp-range=enp7s4f0,192.168.2.2,192.168.2.10

    dhcp-range=enp7s4f1,192.168.2.11,192.168.2.20

    dhcp-range=enp8s6f0,192.168.2.21,192.168.2.30

    dhcp-range=enp8s6f1,192.168.2.31,192.168.2.40

    dhcp-boot=pxelinux.0

    dhcp-match=set:efi-x86_64,option:client-arch,7

    dhcp-boot=tag:efi-x86_64,bootx64.efi

    enable-tftp

    tftp-root=/srv/tftp

現在、インターネット接続は 2 番目のイーサネット デバイスのすべてのインターフェイスで共有されています。

● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
     Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-06-18 07:19:38 CEST; 35min ago
   Main PID: 3458 (dnsmasq)
      Tasks: 1 (limit: 18871)
     Memory: 656.0K
        CPU: 19ms
     CGroup: /system.slice/dnsmasq.service
             └─3458 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local-service --trust-anchor=.,20326,8,2,e06d44b80b8f1d39a95c0b0d7c65d08458e880409>

Jun 18 07:19:38 lubuton dnsmasq-dhcp[3458]: DHCP, IP range 192.168.2.31 -- 192.168.2.40, lease time 1h
Jun 18 07:19:38 lubuton dnsmasq-dhcp[3458]: DHCP, IP range 192.168.2.21 -- 192.168.2.30, lease time 1h
Jun 18 07:19:38 lubuton dnsmasq-dhcp[3458]: DHCP, IP range 192.168.2.11 -- 192.168.2.20, lease time 1h
Jun 18 07:19:38 lubuton dnsmasq-dhcp[3458]: DHCP, IP range 192.168.2.2 -- 192.168.2.10, lease time 1h
Jun 18 07:19:38 lubuton dnsmasq-dhcp[3458]: DHCP, sockets bound exclusively to interface enp5s0
Jun 18 07:19:38 lubuton dnsmasq-tftp[3458]: TFTP root is /srv/tftp
Jun 18 07:19:38 lubuton dnsmasq[3458]: reading /etc/resolv.conf
Jun 18 07:19:38 lubuton dnsmasq[3458]: using nameserver 127.0.0.53#53
Jun 18 07:19:38 lubuton dnsmasq[3458]: read /etc/hosts - 5 addresses
Jun 18 07:19:38 lubuton systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server. 

dnsmasq 構成への最後の変更も機能しました:

interface=enp5s0,lo
bind-interfaces
log-dhcp
dhcp-host=pxe.home.lan,192.168.2.1
dhcp-range=192.168.2.2,192.168.2.40
enable-tftp
tftp-root=/srv/tftp

関連情報