Skip to content

Instantly share code, notes, and snippets.

@omas-public
Last active May 13, 2024 05:10
Show Gist options
  • Save omas-public/176b6a0ce7551c65f701b8ae3a7352c3 to your computer and use it in GitHub Desktop.
Save omas-public/176b6a0ce7551c65f701b8ae3a7352c3 to your computer and use it in GitHub Desktop.

サーバ技術者養成講座(2024 Term I)

環境設定

  • virtualbox
  • vagrant
  • centos/7

仮想ネットワーク設定

$ sudo mkdir /etc/vbox/
$ sudo touch /etc/vbox/networks.conf

/etc/vbox/networks.conf

+ * 192.168.0.0/24

/etc/hosts

+ 192.168.0.18 h2g.example.com h2g

vagrant 作成

$ mkdir -p ~/Boxes/xxx && cd $_
$ vagrant init centos/7
$ vagrant up
$ vagrant halt

Vagrantfile

-  # config.vm.network "private_network", ip: "192.168.33.10" 
+  config.vm.network "private_network", ip: "192.168.0.18"
-  # config.vm.provider "virtualbox" do |vb|
+  config.vm.provider "virtualbox" do |vb|
-  #  vb.memory = "1024"
+    vb.memory = "2048"
-  # end
+  end

確認

$ vagrant up
$ ping h2g.example.com
$ ^C

ServerInstall(on Vagrant Machine)

p28

server$ sudo yum install ftp **vsftpd**
server$ sudo yum install httpd
server$ sudo yum install samba-client
server$ sudo yum install **mailx** sendmail-cf sendmail
server$ sudo yum install telnet telnet-server
server$ sudo yum install xinetd
server$ sudo yum install uw-imap libc-client

設定ファイル

  • /etc/xinetd.d/ipop3
  • /etc/mail/sendmail.cf
  • /etc/vsftpd/vsftpd.conf
  • /etc/selinux/config
  • /etc/hosts

自動起動デーモンの削除と登録

p27

server$ sudo set enforce 0
server$ sudo systemctl disable firewalld
server$ sudo systemctl disable NetworkManager 
server$ sudo systemctl enable telnet.socket
server$ sudo systemctl enable xineted
server$ sudo systemctl enable httpd.service
server$ sudo systemctl enable sendmail.service

systemctlで確認

  • systemctl status ${Unit}
  • systemctl start ${Unit}
  • systemctl stop ${Unit}
  • systemctl enable ${Unit}
  • systemctl disable ${Unit}
  • systemctl is-enabled ${Unit}
  • systemctl list-unit-files --type=service

ssで確認

server$ ss -at | grep 'LISTEN'

Server上のアプリケーションで確認

ftpd

$ ftp localhost
>> Name: vagrant
>> Password: vagrant
>> exit

telnet

server$ telnet localhost
>> login:vagrant
>> Password:vagrant
>> exit

http

server$ curl localhost

smtp

server$ mail vagrant@localhost
>> Subject:test
>> Test message
>> .
>> EOT

pop3

server$ mail
>> & 1
>> & quit

Remoteからプロトコルを用いて確認

telnet

client$ nc -t h2g.example.com 23
>> login: vagrant
>> Password: vagrant
>> exit
$ ^C

http

client$ telnet h2g.example.com 80
>> HEAD / HTTP/1.0

smtp

client$ telnet h2g.example.com 25
>> EHLO example.com
>> MAIL FROM: <MailAddress>
>> RCPT TO:<[email protected]>
>> DATA
>> message
>> .
>> quit

pop

client$ telnet h2g.example.com 110
>> user vagrant
>> pass vagrant
>> stat
>> list
>> retr 1
>> quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment