Skip to content

Instantly share code, notes, and snippets.

@hagevvashi
Last active January 22, 2023 13:34
Show Gist options
  • Save hagevvashi/b8505195728f4ea7f5ced29487104c98 to your computer and use it in GitHub Desktop.
Save hagevvashi/b8505195728f4ea7f5ced29487104c98 to your computer and use it in GitHub Desktop.
ubuntu server で wifi 動かすまで

インストールした順番

  1. libpcsclite1_1.9.1-1_amd64.deb

  2. libnl-3-200_3.4.0-1+b1_amd64.deb

  3. libnl-route-3-200_3.4.0-1+b1_amd64.deb

  4. wpasupplicant_2.9.0-21_amd64.deb

  5. net-tools_1.60+git20161116.90da8a0-1ubuntu1_amd64.deb

ここまでで事前準備終了

次は wpa_supplicant の設定

sudo wpa_passphrase <ssid> [passphrase] > $HOME/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=root

#ap_scan=1
network={
    ssid="your-ssid"
    #psk="your-pass"
    psk="your-pass-encrypted"
    key_mgmt=WPA-PSK
    proto=WPA WPA2
    pairwise=CCMP TKIP
    group=CCMP TKIP WEP104 WEP40
}

起動

sudo wpa_supplicant -Dwext -iwlp2s0 -c/home/<user>/wpa_supplicant.conf -B

apt で依存関係修復をしたら色々おかしくなった

で、インストールしたもの

  1. libnl-genl-3-200_3.4.0-1+b1_amd64.deb
  2. firmware-iwlwifi_20190114-2_all.deb https://packages.debian.org/search?keywords=firmware-iwlwifi ここから stable をダウンロード

2 のインストールコマンド

sudo dpkg -i --force-overwrite firmware-iwlwifi_20190114-2_all.deb

わかっていること

下記コマンドでネットワークインターフェースの状態を確認

sudo  lshw -class network
  *-network UNCLAIMED
      description: Ethernet controller
      ...

UNCLAIMEDと表示されているためドライバが認識されていなさそう

下記コマンドでPCIデバイスの情報を表示する

lspci
02:00.0 Ethernet Controller: Marvell Technology Group Ltd. 88W8897 [AVASTAR] 802.11ac Wireless

という表記が見て取れるので、この88W8897のドライバをインストールすればよい

surface laptop のデバイス/ドライバ一覧

http://linux-hardware.org/index.php?probe=76e652c78c

解決

ubuntu server のインストールから wpasupplicant 起動後以降の手順どおりにする

https://github.com/linux-surface/linux-surface/wiki/Installation-and-Setup

※この手順で linux-surface にカーネルを書き換ずにapt updateをした場合、wifiのドライバが消えるので要注意

netplan の設定

wlp2s0 が起動時に有効になっていないのでその設定

https://blog.d-shimizu.io/article/1196

https://qiita.com/zen3/items/757f96cbe522a9ad397d

https://blog.kujira-station.com/201910232379

ここに従うとよい。(ipの固定化はまだしてない)

ファイル名は 2 つ目の記事に従い、/etc/netplan/99_config.ymal とかがよい

下記のような感じで設定してうまくいった。

/etc/netplan/99_config.yaml

network:
        wifis:
                wlp2s0:
#                         optional: true
                        dhcp4: true
#                         dhcp6: true
                        access-points:
                                "ACCESS_POINT":
                                        password: "********"
        version: 2
        renderer: networkd

pass phrase は上の方の手順で行った sudo wpa_passphrase <ssid> [passphrase] で生成したものを指定

あとは下記のようにコマンド実行していった

sudo netplan generate # 多分これ不要
sudo netplan apply
sudo systemctl disable networking
sudo systemctl enable systemd-networkd.service
sudo reboot
@hagevvashi
Copy link
Author

画面の明るさ設定

cat /sys/class/backlight/intel_backlight/brightness
3235

@hagevvashi
Copy link
Author

hagevvashi commented Apr 3, 2021

画面閉じても suspend にならない設定

sudo vim /etc/systemd/logind.conf
diff --git a/login.bk.conf b/etc/systemd/logind.conf
index d380a61..e0f6ec2 100644
--- a/login.bk.conf
+++ b/etc/systemd/logind.conf
@@ -22,6 +22,7 @@
 #HandleSuspendKey=suspend
 #HandleHibernateKey=hibernate
 #HandleLidSwitch=suspend
+HandleLidSwitch=ignore
 #HandleLidSwitchExternalPower=suspend
 #HandleLidSwitchDocked=ignore
 #PowerKeyIgnoreInhibited=no

その後再起動

@hagevvashi
Copy link
Author

hagevvashi commented Apr 3, 2021

KVM の設定

/proc/cpuinfo の中身から cpu がハードウェア仮想化をサポートしているか調査

$ grep vmx /proc/cpuinfo

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d
vmx flags       : vnmi preemption_timer invvpid ept_x_only ept_ad ept_1gb flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest ple pml ept_mode_based_exec
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d
vmx flags       : vnmi preemption_timer invvpid ept_x_only ept_ad ept_1gb flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest ple pml ept_mode_based_exec
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d
vmx flags       : vnmi preemption_timer invvpid ept_x_only ept_ad ept_1gb flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest ple pml ept_mode_based_exec
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d
vmx flags       : vnmi preemption_timer invvpid ept_x_only ept_ad ept_1gb flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest ple pml ept_mode_based_exec

下記コマンドで 0 以上だったら可能と判断するのがよいらしい

egrep -c '(vmx|svm)' /proc/cpuinfo
sudo apt install qemu-kvm
sudo apt install virtinst
wget https://releases.ubuntu.com/focal/ubuntu-20.04.2-live-server-amd64.iso

libvirt はすでにインストールされていたから libvirt-daemon ではなく libvirt-daemon-system の方をインストールしてみる

sudo apt install libvirt-daemon-system
sudo virt-install \
> --name=ubuntu1 \
> --vcpus=2 \
> --ram=4096 \
> --nographics \
> --cdrom=/home/hagevvashi/ubuntu-20.04.2-live-server-amd64.iso \
> --disk path=/var/lib/libvirt/images/vm-host-ubuntu1.qcow2,size=20,format=qcow2
WARNING  CDROM media does not print to the text console by default, so you likely will not see text install output. You might want to use --location. See the man page for examples of using --location with CDROM media

Starting install...
Allocating 'vm-host-ubuntu1.qcow2'                                                                                                                |  20 GB  00:00:00
ERROR    Requested operation is not valid: network 'default' is not active
Removing disk 'vm-host-ubuntu1.qcow2'                                                                                                             |    0 B  00:00:00
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
  virsh --connect qemu:///system start ubuntu1
otherwise, please restart your installation.

network 再設定してうまくいったはず

brctl を使うため bridge-utils をインストール

$ sudo apt install bridge-utils
sudo virsh net-start default
sudo systemctl restart libvirtd
sudo virsh net-list --all
brctl show
systemctl status libvirtd

下記 2 項目の確認

  • libvirtd が active か
$ sudo systemctl is-active libvirtd
active
  • QEMU 上でもハードウェア仮想化が有効か
$ virt-host-validate
  QEMU: Checking for hardware virtualization                                 : PASS
  QEMU: Checking if device /dev/kvm exists                                   : PASS
  QEMU: Checking if device /dev/kvm is accessible                            : PASS
  QEMU: Checking if device /dev/vhost-net exists                             : PASS
  QEMU: Checking if device /dev/net/tun exists                               : PASS
  QEMU: Checking for cgroup 'cpu' controller support                         : PASS
  QEMU: Checking for cgroup 'cpuacct' controller support                     : PASS
  QEMU: Checking for cgroup 'cpuset' controller support                      : PASS
  QEMU: Checking for cgroup 'memory' controller support                      : PASS
  QEMU: Checking for cgroup 'devices' controller support                     : PASS
  QEMU: Checking for cgroup 'blkio' controller support                       : PASS
  QEMU: Checking for device assignment IOMMU support                         : PASS
  QEMU: Checking if IOMMU is enabled by kernel                               : WARN (IOMMU appears to be disabled in kernel. Add intel_iommu=on to kernel cmdline arguments)
  QEMU: Checking for secure guest support                                    : WARN (Unknown if this platform has Secure Guest support)
   LXC: Checking for Linux >= 2.6.26                                         : PASS
   LXC: Checking for namespace ipc                                           : PASS
   LXC: Checking for namespace mnt                                           : PASS
   LXC: Checking for namespace pid                                           : PASS
   LXC: Checking for namespace uts                                           : PASS
   LXC: Checking for namespace net                                           : PASS
   LXC: Checking for namespace user                                          : PASS
   LXC: Checking for cgroup 'cpu' controller support                         : PASS
   LXC: Checking for cgroup 'cpuacct' controller support                     : PASS
   LXC: Checking for cgroup 'cpuset' controller support                      : PASS
   LXC: Checking for cgroup 'memory' controller support                      : PASS
   LXC: Checking for cgroup 'devices' controller support                     : PASS
   LXC: Checking for cgroup 'freezer' controller support                     : PASS
   LXC: Checking for cgroup 'blkio' controller support                       : PASS
   LXC: Checking if device /sys/fs/fuse/connections exists                   : PASS

@hagevvashi
Copy link
Author

hagevvashi commented Apr 4, 2021

nmcli コマンドを使えるようにする

sudo apt install network-manager

↑ これ入れると netplan と競合してネットワーク使えなくなったから入れないほうがよさそう

@hagevvashi
Copy link
Author

wireless interface 上では VM bridge できない問題について書かれている

https://headtonirvana.hatenablog.com/entry/2020/07/11/223922

トリッキーなことをしないと難しいことがわかった。virtualbox ではできるみたい

@hagevvashi
Copy link
Author

hagevvashi commented Apr 4, 2021

virsh や virt を消す

まずは VM を削除

$ virsh undefine ubuntu1 --remove-all-storage
Domain ubuntu1 has been undefined
Volume 'vda'(/var/lib/libvirt/images/vm-host-ubuntu1.qcow2) removed.

default network を消す

$ virsh net-undefine default
Network default has been undefined

要らないパッケージたちを remove

$ sudo apt remove -y bridge-utils
$ sudo apt remove -y libvirt-daemon-system
$ sudo apt remove -y virtinst
$ sudo apt remove -y qemu-kvm

ubuntu のインストールメディアを削除

$ rm -f ubuntu-20.04.2-live-server-amd64.iso

@hagevvashi
Copy link
Author

hagevvashi commented Apr 4, 2021

virtual box をインストール

まずはリポジトリを登録

$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
OK
$ wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
OK
$ echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | \
>      sudo tee -a /etc/apt/sources.list.d/virtualbox.list
deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian focal contrib

パッケージリストの更新

$ sudo apt update
Get:1 http://download.virtualbox.org/virtualbox/debian focal InRelease [4,428 B]
Get:2 http://download.virtualbox.org/virtualbox/debian focal/contrib amd64 Packages [1,483 B]
Hit:3 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:6 https://pkg.surfacelinux.com/debian release InRelease
Hit:7 http://archive.ubuntu.com/ubuntu focal-security InRelease
Fetched 5,911 B in 2s (2,945 B/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.

virtualbox 6.1 のインストール

$ sudo apt install virtualbox-6.1

エラーがでる

vboxdrv.sh: failed: Look at /var/log/vbox-setup.log to find out what went wrong.

There were problems setting up VirtualBox.  To re-start the set-up process, run
  /sbin/vboxconfig
as root.  If your system is using EFI Secure Boot you may need to sign the
kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load
them. Please see your Linux system's documentation for more information.

vboxconfig を試す

$ sudo /sbin/vboxconfig
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: failed: Look at /var/log/vbox-setup.log to find out what went wrong.

There were problems setting up VirtualBox.  To re-start the set-up process, run
  /sbin/vboxconfig
as root.  If your system is using EFI Secure Boot you may need to sign the
kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load
them. Please see your Linux system's documentation for more information.

reinstall してみる

$ sudo apt install --reinstall virtualbox

別のエラーが出る

ERROR (dkms apport): kernel package linux-headers-5.11.10-surface is not supported
Error! Bad return status for module build on kernel: 5.11.10-surface (x86_64)
Consult /var/lib/dkms/virtualbox/6.1.16/build/make.log for more information.
dpkg: error processing package virtualbox-dkms (--configure):
 installed virtualbox-dkms package post-installation script subprocess returned error exit status 10
dpkg: dependency problems prevent configuration of virtualbox:
 virtualbox depends on virtualbox-dkms (>= 6.1.16-dfsg-6~ubuntu1.20.04.1) | virtualbox-source (>= 6.1.16-dfsg-6~ubuntu1.20.04.1) | virtualbox-modules; however:
  Package virtualbox-dkms is not configured yet.
  Package virtualbox-source is not installed.
  Package virtualbox-modules is not installed.
  Package virtualbox-dkms which provides virtualbox-modules is not configured yet.

dpkg: error processing package virtualbox (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of virtualbox-qt:
 virtualbox-qt depends on virtualbox (= 6.1.16-dfsg-6~ubuntu1.20.04.1); however:
  Package virtualbox is not configured yet.
  Package virtualbox-6.1 which provides virtualbox is not installed.

dpkg: error processing package virtualbox-qt (--configure):
 dependency problems - leaving unconfigured
Processing triggers for mime-support (3.64ubuntu1) ...
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          No apport report written because the error message indicates its a followup error from a previous failure.
                                           Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Processing triggers for systemd (245.4-4ubuntu3.5) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for shared-mime-info (1.15-1) ...
Errors were encountered while processing:
 virtualbox-dkms
 virtualbox
 virtualbox-qt
E: Sub-process /usr/bin/dpkg returned an error code (1)

とりあえず virtualbox を uninstall

$ sudo apt remove virtualbox

なんかエラーでたので 6.1 の方もけす

$ sudo apt remove virtualbox-6.1

やっぱりなんかでる

ERROR (dkms apport): kernel package linux-headers-5.11.10-surface is not supported
Error! Bad return status for module build on kernel: 5.11.10-surface (x86_64)

この issue にいきついた

jakeday/linux-surface#646

リポジトリを追加する

$ sudo add-apt-repository 'deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian eoan contrib'

その後改めて remove を試みる

$ sudo apt remove virtualbox-6.1

...省略...

Setting up virtualbox-dkms (6.1.16-dfsg-6~ubuntu1.20.04.1) ...
Removing old virtualbox-6.1.16 DKMS files...

------------------------------
Deleting module version: 6.1.16
completely from the DKMS tree.
------------------------------
Done.
Loading new virtualbox-6.1.16 DKMS files...
Building for 5.11.10-surface
Building initial module for 5.11.10-surface
ERROR (dkms apport): kernel package linux-headers-5.11.10-surface is not supported
Error! Bad return status for module build on kernel: 5.11.10-surface (x86_64)
Consult /var/lib/dkms/virtualbox/6.1.16/build/make.log for more information.
dpkg: error processing package virtualbox-dkms (--configure):
 installed virtualbox-dkms package post-installation script subprocess returned error exit status 10
Errors were encountered while processing:
 virtualbox-dkms
E: Sub-process /usr/bin/dpkg returned an error code (1)

とりあえず virtualbox-dkms を remove しておく

$ sudo apt remove virtualbox-dkms

これなら virtualbox-6.1 を消せる

$ sudo apt remove virtualbox-6.1

deb ファイルをダウンロードしてインストール

$ wget https://download.virtualbox.org/virtualbox/6.1.18/virtualbox-6.1_6.1.18-142142~Ubuntu~eoan_amd64.deb
--2021-04-04 08:50:37--  https://download.virtualbox.org/virtualbox/6.1.18/virtualbox-6.1_6.1.18-142142~Ubuntu~eoan_amd64.deb
Resolving download.virtualbox.org (download.virtualbox.org)... 23.217.124.4
Connecting to download.virtualbox.org (download.virtualbox.org)|23.217.124.4|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 89242136 (85M) [text/plain]
Saving to: ‘virtualbox-6.1_6.1.18-142142~Ubuntu~eoan_amd64.deb’

virtualbox-6.1_6.1.18-142142~Ubuntu~eoan_a 100%[=====================================================================================>]  85.11M  18.7MB/s    in 4.7s

2021-04-04 08:50:42 (18.3 MB/s) - ‘virtualbox-6.1_6.1.18-142142~Ubuntu~eoan_amd64.deb saved [89242136/89242136]

$ sudo apt install -y ./virtualbox-6.1_6.1.18-142142~Ubuntu~eoan_amd64.deb

同じ結果に・・・

Note, selecting 'virtualbox-6.1' instead of './virtualbox-6.1_6.1.18-142142~Ubuntu~eoan_amd64.deb'

こう出ているところをみるとリポジトリ登録したときと同様の結果かも

$ sudo dpkg -i ./virtualbox-6.1_6.1.18-142142~Ubuntu~eoan_amd64.deb

これも全く同じ結果

もう一度 apt を用いてインストール

$ sudo apt install virtualbox-6.1
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  amd64-microcode cpu-checker dctrl-tools dkms dns-root-data dnsmasq-base genisoimage gir1.2-freedesktop gir1.2-libosinfo-1.0 gstreamer1.0-plugins-base
  gstreamer1.0-plugins-good gstreamer1.0-x i965-va-driver intel-media-va-driver intel-microcode ipxe-qemu ipxe-qemu-256k-compat-efi-roms iucode-tool libaa1
  libavc1394-0 libbluetooth3 libbrlapi0.7 libcacard0 libcdparanoia0 libdbus-glib-1-2 libdv4 libfdt1 libgovirt-common libgovirt2 libgsoap-2.8.91
  libgstreamer-plugins-base1.0-0 libgstreamer-plugins-good1.0-0 libgtk-vnc-2.0-0 libgvnc-1.0-0 libidn11 libiec61883-0 libigdgmm11 libiscsi7 libjack-jackd2-0
  libjansson4 liblzf1 libmbim-glib4 libmbim-proxy libmm-glib0 libmp3lame0 libmpg123-0 libndp0 libnm0 liborc-0.4-0 libosinfo-1.0-0 libphodav-2.0-0 libphodav-2.0-common
  libpmem1 libpulse-mainloop-glib0 libqmi-glib5 libqmi-proxy libraw1394-11 libsamplerate0 libshout3 libslirp0 libspeex1 libspice-client-glib-2.0-8
  libspice-client-gtk-3.0-5 libspice-server1 libtag1v5 libtag1v5-vanilla libteamdctl0 libtheora0 libtwolame0 libusbredirhost1 libusbredirparser1 libv4l-0
  libv4lconvert0 libva-x11-2 libva2 libvirglrenderer1 libvirt-clients libvirt-daemon-system-systemd libvirt-glib-1.0-0 libvisual-0.4-0 libvncserver1 libvte-2.91-0
  libvte-2.91-common libwavpack1 linux-headers-5.4.0-67 linux-headers-5.4.0-67-generic mesa-va-drivers modemmanager msr-tools osinfo-db ovmf pptp-linux python3-libvirt
  python3-libxml2 qemu-block-extra qemu-system-common qemu-system-data qemu-system-gui qemu-system-x86 qemu-utils seabios sharutils spice-client-glib-usb-acl-helper
  thermald usb-modeswitch usb-modeswitch-data va-driver-all virt-viewer
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  virtualbox-6.1
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/89.2 MB of archives.
After this operation, 216 MB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously unselected package virtualbox-6.1.
(Reading database ... 203765 files and directories currently installed.)
Preparing to unpack .../virtualbox-6.1_6.1.18-142142~Ubuntu~eoan_amd64.deb ...
Unpacking virtualbox-6.1 (6.1.18-142142~Ubuntu~eoan) ...
Setting up virtualbox-6.1 (6.1.18-142142~Ubuntu~eoan) ...
addgroup: The group `vboxusers' already exists as a system group. Exiting.
vboxdrv.sh: failed: Look at /var/log/vbox-setup.log to find out what went wrong.

There were problems setting up VirtualBox.  To re-start the set-up process, run
  /sbin/vboxconfig
as root.  If your system is using EFI Secure Boot you may need to sign the
kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load
them. Please see your Linux system's documentation for more information.
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for systemd (245.4-4ubuntu3.5) ...
Processing triggers for shared-mime-info (1.15-1) ...
Processing triggers for mime-support (3.64ubuntu1) ...

/sbin/vboxconfig を実行

$ sudo /sbin/vboxconfig
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: failed: Look at /var/log/vbox-setup.log to find out what went wrong.

There were problems setting up VirtualBox.  To re-start the set-up process, run
  /sbin/vboxconfig
as root.  If your system is using EFI Secure Boot you may need to sign the
kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load
them. Please see your Linux system's documentation for more information.

結果は同じ

secure boot を無効にするのがよさそう

mokutil をインストール

$ sudo apt install -y mokutil

無効化していく

$ sudo mokutil --disable-validation

password 設定が求められるので 8 文字以上のパスワードを設定する

その後再起動する

sudo shutdown -r now

サーバの方で青い画面が表示される

たしか、一回 return した後、 [Change Secure Boot State] を選択する

パスワードの n 番目の文字を入力しろと数回聞かれるので、そのとおりに入力する

そうすると [Yes/No] が聞かれるので、Yes を選択して、[Reboot] を選択する

だめだった・・・

これを試したけど virtualbox が boot 時に fail を起こしてネットワーク吹っ飛んだから結構やばそう。できれば設定なかったコトにしたいが

$ sudo -i
# mkdir /root/signed-modules
# cd /root/signed-modules
# openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=VirtualBox/"
# chmod 600 MOK.priv
# mokutil --import MOK.der
# shutdown -r now

ブルースクリーンで Enter

[Enroll MOK] を選択

[Continue] を選択

パスワード入力

その後の起動時にネットワーク吹っ飛ぶ事件発生

参考: https://stackoverflow.com/questions/61248315/sign-virtual-box-modules-vboxdrv-vboxnetflt-vboxnetadp-vboxpci-centos-8

もう一度 secure boot を無効にすることで事なきを得た

$ sudo mokutil --disable-validation

調べてみると、virtualbox の方で linux-surface のカーネルのバージョンに対応していないからっぽいことがわかった

linux-surface/linux-surface#362

カーネルのバージョンを 5.9 に下げてみる

インストール可能なカーネルリストを調べる

$ sudo apt-cache search linux-image

5.9.14 が 5.9 の一番新しいものみたいなので、それをインストールする

$ sudo apt install linux-image-5.9.14-surface

再起動する

起動中の画面で Esc を押し黒いメニューを開く

[Advanced options for ubuntu] を選択

カーネルを選択する画面になるので、インストールしたカーネルを選択する

 uname -a
Linux surface-laptop-ubuntu 5.9.14-surface #1 SMP Sat Dec 12 20:50:51 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

結局ダメだった・・・

dkms というパッケージが事前にあれば vboxdrv の問題を解決できるかもしれない

参考

https://skill-up-engineering.com/2015/12/15/post-1101/

$ sudo apt install -y dkms

とはいえこれでも元の vboxdrv がない問題は解決しない

https://rougeref.hatenablog.com/entry/20180823/1535007624

おそらく途中でやったネットワークが使えなくなってしまったあれが正解なんだろうけど、下記問題が解決されないと厳しい

$ modinfo -n vboxdrv
modinfo: ERROR: Module vboxdrv not found.

@hagevvashi
Copy link
Author

ネットワークが頻繁に切れるので下記スクリプトでずっとウォッチする

network-watch.sh

#!/usr/bin/env bash
set -euo pipefail

while true
do
  if ping -c 1 google.com 2> /dev/null; then
    :
  else
    netplan apply
    systemctl disable networking
    systemctl enable systemd-networkd.service
  fi
  sleep 60
done

chmod 755 ./network-watch.sh を忘れずに

下記コマンドでデーモン化

sudo start-stop-daemon --start --pidfile /var/run/nw.pid --make-pidfile --background --exec /home/hagevvashi/network-watch.sh --user root

@hagevvashi
Copy link
Author

Buffalo のルータ使うと LAN 内で ping 通らない自体が発生

MACアクセス制限でping先のPCのMACアドレスを追加する

https://qiita.com/fukayatsu/items/4ad7af5e4a8640e4b713

@hagevvashi
Copy link
Author

/etc/netplan/99_config.yaml の設定最新

network:
  wifis:
    wlp2s0:
#      optional: true
      dhcp4: no
      dhcp6: yes
#      dhcp6: no
      addresses: [192.168.11.11/24]
      gateway4: 192.168.11.1
      access-points:
        "[access-point]":
#          password: "[password]"
          password: "[password-encryped]"
# TODO: we cannnot use WPA3 SAE by netplan
#        "[access-point-wpa3]":
#          password: "[password]"
#          password: "[password-encrypted]"
      nameservers:
        addresses: [192.168.11.1, 8.8.8.8]
  version: 2
  renderer: networkd

@hagevvashi
Copy link
Author

hagevvashi commented Jul 23, 2021

環境をきれいにしておく

$ sudo apt remove virtualbox
$ sudo apt remove virtualbox-6.1
$ sudo apt remove virtualbox-qt
$ sudo add-apt-repository --remove 'deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian eoan contrib'
$ sudo apt update
$ sudo apt autoremove
$ sudo apt upgrade

virsh がないので libvirt-clients をインストール

$ sudo apt install libvirt-clients

libvertd が Unit libvertd.service not loaded. というエラーで起動できないので libvirt-daemon-system をインストール

$ sudo apt install libvirt-daemon-system

libvertd の起動

$ sudo systemctl start libvirtd

再起動

$ sudo shutdown -r now

brctl コマンドが必要になるので bridge-utils をインストール

$ sudo apt install bridge-utils

tunctl コマンドが必要になるので uml-utilities をインストール

$ sudo apt install uml-utilities

parprouted コマンドが必要になるので parprouted をインストール

$ sudo apt install parprouted

bcrelay コマンドが必要になるので bcrelay をインストール

$ sudo apt install bcrelay

↓↓↓ここから下は再起動すると設定が消える↓↓↓

(ホストマシンの)パケットフォワードを有効にする

$ sudo /sbin/sysctl net.ipv4.ip_forward=1

ブリッジデバイス br0を作る

$ sudo /sbin/brctl addbr br0

tunデバイス tap0 を作る

$ sudo tunctl -t tap0

br0とtap0をブリッジする

$ sudo /sbin/brctl addif br0 tap0

br0 に IPアドレスを付与する

ここは DHCP 外の ip がいいみたい

$ sudo /sbin/ip addr add 192.168.11.99 dev br0

br0を起動する。

$ sudo /sbin/ip link set br0 up

なんかよくわからんやつ

/bin/echo 1 > /proc/sys/net/ipv4/conf/wlp2s0/proxy_arp
/bin/echo 1 > /proc/sys/net/ipv4/conf/br0/proxy_arp
/bin/echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp

parproutedで wlp2s0に飛んできたarpをbr0にも転送する

$ sudo /usr/sbin/parprouted wlp2s0 br0

bcrelayで、br0(仮想環境)から飛んできたブロードキャストをwlp2s0に転送する

$ sudo /usr/sbin/bcrelay -d -i br0 -o wlp2s0

↑↑↑ここから上は再起動すると設定が消える↑↑↑

losetup -l で見てみると何やら変なループデバイスが大量に作成されていた

losetup -d で削除を試みてもできないため、マウントしているファイルを全部削除した

$ sudo rm -f /var/lib/snapd/snaps/core18_2074.snap
$ losetup -l
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE                                       DIO LOG-SEC
/dev/loop1         0      0         1  1 /var/lib/snapd/snaps/core18_2074.snap (deleted)   0     512
/dev/loop4         0      0         1  1 /var/lib/snapd/snaps/snapd_12057.snap             0     512
/dev/loop2         0      0         1  1 /var/lib/snapd/snaps/lxd_20326.snap               0     512
/dev/loop0         0      0         1  1 /var/lib/snapd/snaps/core18_2066.snap             0     512
/dev/loop5         0      0         1  1 /var/lib/snapd/snaps/lxd_21029.snap               0     512
/dev/loop3         0      0         1  1 /var/lib/snapd/snaps/snapd_12398.snap             0     512

再起動したら全て消えていた

これから下記記事を参考に仮想マシンを作成する

https://qiita.com/zhh/items/df076c4614f0238f9876

ubuntu-20.04.2 のインストールイメージをダウンロードしておく

wget https://releases.ubuntu.com/focal/ubuntu-20.04.2-live-server-amd64.iso

15GBのQCOW2イメージを作る

$ qemu-img create -f qcow2 main.qcow2 150G

作成されたファイルの確認

$ ls -la main.qcow2
-rw-r--r-- 1 hagevvashi hagevvashi 196848 Jul 23 23:51 main.qcow2
$ file main.qcow2
main.qcow2: QEMU QCOW2 Image (v3), 16106127360 bytes

下記を参考に仮想マシンの作成

https://www.server-world.info/query?os=Ubuntu_20.04&p=kvm&f=2

virt-install \
  --name ubuntu1 \
  --ram 4096 \
  --disk path=./main.qcow2,bus=virtio \
  --nographics \
  --vcpus 2 \
  --network bridge=br0 \
  --location https://releases.ubuntu.com/20.04/ubuntu-20.04.2-live-server-amd64.iso,kernel=casper/vmlinuz,initrd=casper/initrd \
  --extra-args 'console=ttyS0,115200n8 serial'

ミスってしまってお掃除がうまくいっていない状態で上記コマンドを打つと下記エラーがでる

>   --extra-args 'console=ttyS0,115200n8 serial'
WARNING  /home/hagevvashi/.cache/virt-manager/boot may not be accessible by the hypervisor. You will need to grant the 'libvirt-qemu' user search permissions for the fol
lowing directories: ['/home/hagevvashi/.cache']
ERROR    Disk /home/hagevvashi/main.qcow2 is already in use by other guests ['ubuntu1']. (Use --check path_in_use=off or --check all=off to override)

サジェスチョンの通りに--check path_in_use=off を付与して実行すると次のエラーが出現する

Starting install...
ERROR    Guest name 'ubuntu1' is already in use.
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
  virsh --connect qemu:///system start ubuntu1
otherwise, please restart your installation.

一回きれいにする必要があると判断し、下記コマンドを入力

$ virsh list --all
 Id   Name      State
-------------------------
 1    ubuntu1   running

$ virsh shutdown ubuntu1
Domain ubuntu1 is being shutdown

$ virsh destroy ubuntu1
Domain ubuntu1 destroyed

$ virsh list --all
 Id   Name      State
--------------------------
 -    ubuntu1   shut off

$ virsh undefine ubuntu1
Domain ubuntu1 has been undefined

$ virsh list --all
 Id   Name   State
--------------------

permission のエラーがなんか嫌な感じなので下記の記事参考にしてみる

https://nogiro.hatenablog.com/entry/2017/12/20/030444

$ cd /
$ sudo mkdir virtual
$ sudo groupadd virtadmin
$ sudo chown -R :virtadmin virtual
$ sudo chmod 2770 virtual
$ sudo mkdir virtual/{disk,iso}
$ sudo chown root virtual/{disk,iso}
$ sudo usermod -aG virtadmin hagevvashi
$ sudo usermod -aG virtadmin libvirt-qemu

インストールメディアダウンロード

$ sudo sh -c "cd /virtual/iso; wget https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.10.0-amd64-netinst.iso"

そして満を持して virt-install

virt-install \
  --name debian1 \
  --ram 2048 \
  --vcpus 1 \
  --disk path=/virtual/disk/main.qcow2,bus=virtio \
  --nographics \
  --console pty,target_type=serial \
  --network bridge=br0 \
  --location /virtual/iso/debian-10.10.0-amd64-netinst.iso \
  --extra-args 'console=tty0 console=ttyS0,115200n8 keymap=ja' \
  --os-type=generic \
  --virt-type=kvm

DHCP使えないので無理矢理IPを設定したらいける

$ virsh start debian1
$ virsh console debian1

root と入力し Password 入力

# ip link set ens2 up
# ip addr add 192.168.11.13/24 dev ens2

これで外から触れるようになった

@hagevvashi
Copy link
Author

$ virsh console debian1

で入ったコンソールから抜ける方法はcontrol + ]

@hagevvashi
Copy link
Author

hagevvashi commented Jan 9, 2023

ブリッジ接続の一覧を表示

$ brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.0e7f316bce6b       no              tap0
                                                        vnet0

IPv4転送設定確認

$ cat /etc/sysctl.conf | grep ipv4.ip_forward
#net.ipv4.ip_forward=1

コメントアウトしてあるので設定無効っぽいので書き換え

$ cat /etc/sysctl.conf | grep ipv4.ip_forward
net.ipv4.ip_forward=1

iptables ルールを使って、ブリッジされた トラフィックがプロセスされることを阻止する

/etc/sysctl.conf 内で 以下の行を追記

net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0

確認

$ cat /etc/sysctl.conf|grep net.bridge
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0

iptablesコマンド実行

$ sudo iptables -L FORWARD

なんの意味もなさそうなのでsysctlで設定反映

$ sudo sysctl -p /etc/sysctl.conf
net.ipv4.ip_forward = 1
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: No such file or directory
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-arptables: No such file or directory

エラーが出ているのでここを参考に

$ sudo modprobe br_netfilter
$ sudo sysctl -p /etc/sysctl.conf
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0

ホストOS側で内->外が通じなくなるのでネットワーク再起動

sudo systemctl restart systemd-networkd.service

@hagevvashi
Copy link
Author

hagevvashi commented Jan 9, 2023

wlp2s0をプロミスキャスモードに変更

$ sudo ip link set wlp2s0 promisc on
$ ip a show wlp2s0

wlp2s0 に PROMISC というフラグが追加されており、プロミスキャスモードが有効になっていることがわかる

↑は必要ないかも。

tap0をプロミスキャスモードにする必要があった

$ sudo ifconfig tap0 0.0.0.0 promisc up
$ ip a show tap0

@hagevvashi
Copy link
Author

hagevvashi commented Jan 9, 2023

ゲストOSに入りネットワークを起動

$ virsh console debian1

root で入った後

~# ip addr add 192.168.11.13/24 dev ens2

上の方で作ったbr0のip(192.168.11.99)を指定して route する

~# ip route add default via 192.168.11.99
~# ip route
default via 192.168.11.99 dev ens2
192.168.11.0/24 dev ens2 proto kernel scope link src 192.168.11.13

これ全然だめ

@hagevvashi
Copy link
Author

hagevvashi commented Jan 9, 2023

br0 に wlp2s0 と tap0 をぶら下げる方式は、wlp2s0(ワイヤレスNIC)がブリッジできない。

そういうときに 4addr モードを on にするとよいのだが、

$ iw dev wlp2s0 set 4addr on
command failed: Operation not supported (-95)

というエラーになる

ここや

https://community.toradex.com/t/bridge-wifi-to-ethernet-to-add-poe-device-to-network/13142/6

ここ

https://raspberrypi.stackexchange.com/questions/88954/workaround-for-a-wifi-bridge-on-a-raspberry-pi-with-proxy-arp

に原因と解決方法が書かれているが難しい

上でもやってきたが arp 方式でもう一回チャレンジしてみる

@hagevvashi
Copy link
Author

hagevvashi commented Jan 9, 2023

arp チャレンジ

https://web.archive.org/web/20170222115348/blog.bodhizazen.net/linux/bridge-wireless-cards/

$ sudo tunctl -u hagevvashi
Set 'tap0' persistent and owned by uid 1000

root になったあと

~# echo 1 > /proc/sys/net/ipv4/ip_forward
~# echo 1 > /proc/sys/net/ipv4/conf/wlp2s0/proxy_arp
~# echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp

ユーザーに戻ってから

$ sudo ip link set tap0 up
$ sudo route add -host 192.168.11.12 dev tap0

仮想マシンインストールできなかった

ひとまず tap、 arp を自動化するすくりぷと

#!/usr/bin/env bash
set -euo pipefail

kvm_if_up(){
    tunctl -u ${USER} -t tap0

    sysctl net.ipv4.ip_forward=1
    sysctl net.ipv4.conf.wlp2s0.proxy_arp=1

    sysctl net.ipv4.conf.tap0.proxy_arp=1

    ip link set dev tap0 up

    route add -host 192.168.11.12 dev tap0
}

kvm_if_down(){

    sysctl net.ipv4.ip_forward=0
    sysctl net.ipv4.conf.wlp2s0.proxy_arp=0

    sysctl net.ipv4.conf.tap0.proxy_arp=0

    ip link set dev tap0 down

    tunctl -d tap0
}

if [ $EUID -ne 0 ]; then
  echo "This script must be run as root" 1>&2
  exit 1
else

    case "$1" in

        start)
            kvm_if_up
            ;;
        stop)
            kvm_if_down
            ;;
        *)
            echo "Usage: $0 {start|stop}"
            ;;
    esac

fi

exit 0

実行例

$ sudo ./kvm_networking.sh stop
$ sudo USER=hagevvashi ./kvm_networking.sh start

@hagevvashi
Copy link
Author

kvm コマンドで Permission denied に対処する

$ kvm -m 512 -boot c -hda main.qcow2 -net nic -net tap,ifname=tap0,script=no
Unable to init server: Could not connect: Connection refused
Could not access KVM kernel module: Permission denied
qemu-system-x86_64: failed to initialize KVM: Permission denied

kvmグループに属していないことを確認

$ ls -la /dev/kvm
crw-rw----+ 1 root kvm 10, 232 Jan 10 12:18 /dev/kvm
$ grep kvm /etc/group
kvm:x:108:
$ id | tr ',' '\n' | grep kvm

追加

$ export USER=$(whoami);sudo gpasswd -a $USER kvm;unset USER

確認

$ exit
$ id | tr ',' '\n' | grep kvm
108(kvm)

@hagevvashi
Copy link
Author

hagevvashi commented Jan 10, 2023

間違えて /dev/net/tun を削除しちゃったとき

$ sudo mknod --mode 600 /dev/net/tun c 10 200
$ sudo chmod 666 /dev/net/tun
$ sudo modprobe tun

@hagevvashi
Copy link
Author

これを参考に kvm_networking.sh を修正

https://gihyo.jp/admin/serial/01/linux_containers/0014

#!/usr/bin/env bash
set -euo pipefail

kvm_if_up(){
    tunctl -u ${USER} -t tap0 # 1

    sysctl net.ipv4.ip_forward=1
    sysctl net.ipv4.conf.wlp2s0.proxy_arp=1

    sysctl net.ipv4.conf.tap0.proxy_arp=1

    ip link set dev tap0 up # 2

    route add -host 192.168.11.12 dev tap0 # 3

    brctl addbr br0 # 4

    brctl addif br0 tap0 # 5

    ip addr add 192.168.11.99/24 dev br0 # 6

    ip link set dev br0 up # 7

    parprouted wlp2s0 br0 # 8

    bcrelay -d -i br0 -o wlp2s0 # 9

    # dhclient wlp2s0
}

kvm_if_down(){

    sysctl net.ipv4.ip_forward=0
    sysctl net.ipv4.conf.wlp2s0.proxy_arp=0

    sysctl net.ipv4.conf.tap0.proxy_arp=0

    ip link set dev br0 down # 7

    ip link set dev tap0 down # 2

    brctl delif br0 tap0 # 5

    brctl delbr br0 # 4

    tunctl -d tap0 # 1
}

if [ $EUID -ne 0 ]; then
  echo "This script must be run as root" 1>&2
  exit 1
else

    case "$1" in

        start)
            kvm_if_up
            ;;
        stop)
            kvm_if_down
            ;;
        *)
            echo "Usage: $0 {start|stop}"
            ;;
    esac

fi

exit 0

@hagevvashi
Copy link
Author

https://unix.stackexchange.com/a/544061

ここを参考に今はこう

#!/usr/bin/env bash
set -euo pipefail

kvm_if_up(){
    # brctl addbr br0 # 4
    tunctl -u ${USER} -t tap0 # 1
    # brctl addif br0 tap0 # 5
    # ip addr add 192.168.11.99/24 dev br0 # 6
    ip addr add 10.10.10.10/24 dev tap0 # 6`
    # ip link set dev br0 up # 7

    sysctl net.ipv4.ip_forward=1
    # sysctl net.ipv4.conf.wlp2s0.proxy_arp=1
    # sysctl net.ipv4.conf.tap0.proxy_arp=1

    # ip link set dev tap0 up # 2

    # route add -host 192.168.11.12 dev tap0 # 3

    # parprouted wlp2s0 br0 # 8
    parprouted wlp2s0 tap0 # 8`
    # bcrelay -d -i br0 -o wlp2s0 # 9

    # dhclient wlp2s0

    iptables -A INPUT -i tap0 -j ACCEPT
    iptables -A FORWARD -i tap0 -j ACCEPT
    iptables -A FORWARD -o tap0 -j ACCEPT
}

kvm_if_down(){

    sysctl net.ipv4.ip_forward=0
    # sysctl net.ipv4.conf.wlp2s0.proxy_arp=0
    # sysctl net.ipv4.conf.tap0.proxy_arp=0

    # ip link set dev br0 down # 7
    ip link set dev tap0 down # 2

    # brctl delif br0 tap0 # 5

    # brctl delbr br0 # 4

    tunctl -d tap0 # 1

    iptables -F
}

if [ $EUID -ne 0 ]; then
  echo "This script must be run as root" 1>&2
  exit 1
else

    case "$1" in

        start)
            kvm_if_up
            ;;
        stop)
            kvm_if_down
            ;;
        *)
            echo "Usage: $0 {start|stop}"
            ;;
    esac

fi

exit 0

@hagevvashi
Copy link
Author

arp proxyとdhcp relayの概念図はこれが参考になる RasberryPI の例だけど

https://zenn.dev/masebb/articles/cc8b1151be73fc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment