คำสั่งในการติดตั้ง Vagrant บน Ubuntu 24.04 LTS

Started by New User, June 17, 2026, 09:35:31 PM

Previous topic - Next topic

New User

wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install vagrant

ทำการเช็คว่าเครื่องของท่าน ได้เปิด SecureBoot ไว้หรือไม่
mokutil --sb-state
หากผลลัพธ์ของการพิมพ์คำสั่งคือ Enabled ท่านจะต้องทำการปิด Secure Boot ก่อน

หลังจากนั้นติดตั้ง virtualbox
sudo apt install virtualbox
ต่อไปเราต้องการลง metasploitable3 ซึ่งเป็น vm ที่มีช่องโหว่เอาไว้ทดสอบเรื่องความปลอดภัย
mkdir metasploitable3-workspace
cd metasploitable3-workspace
และทำการโหลด Vagrant file เพื่อทำการ deploy VMs โดยใช้คำสั่ง
wget -O Vagrantfile https://raw.githubusercontent.com/rapid7/metasploitable3/master/Vagrantfile
หลังจากนั้นทำการรันโดยการพิมพ์
vagrant up
หากท่านได้ error ว่า


The IP address configured for the host-only network is not within the
allowed ranges. Please update the address used to be within the allowed
ranges and run the command again.

  Address: 172.28.128.3
  Ranges: 192.168.56.0/21, fe80::/10

Valid ranges can be modified in the /etc/vbox/networks.conf file. For
more information including valid format see:

  https://www.virtualbox.org/manual/ch06.html#network_hostonly

ท่านจะต้องไปสร้าง ไฟล์ที่ชื่อว่า  /etc/vbox/networks.conf และอนุญาตทุก class ip ด้วยคำสั่ง
sudo mkdir /etc/vbox
sudo nano /etc/vbox/networks.conf
และใส่ข้อความคือ * 0.0.0.0/0 ::/0 ในไฟล์ดังกล่าว หลังจากนั้นจึง save และพิมพ์ vagrant up อีกครั้ง