[Project] Small temporarily office network 1


1. Network design and diagram (2017/1/19)
2. IP design (2017/1/19)
3. Disaster backup plan (2017/1/19)
4. Recovery plan (2017/1/19)
5. Design prototype. (2017/1/16)
6. Implement design in Hyper-V (2017/1/16)
7. Implement IP design to router
8. Implement design on real machines (2017/3/12)
10. Script (2017/1/20)
11. Internet Messenger (2017/1/21)

Define criteria and needs:

The project is for creating a temporarily internal network for around three to ten people connecting to
the network and sharing files and printers. Also meet the following criteria and needs:
1 No internet connection
2 Computer(Windows, OSX) can share files and using the shearing printer once they connect to the network

Role and devices required:

Device: commercial router
Server: Ubuntu Linux(Role: Printer Server, File Server)

========================================================================
Network diagram

========================================================================
Router -IP Setup


Network:   192.168.1.0/28
Netmask:   255.255.255.240
HostMin:   192.168.1.1
HostMax:   192.168.1.14
Hosts/Net: 14

========================================================================
Script

easy_admin.sh
Run: sudo ./easy_admin.sh


#!/bin/bash
#

echo -e "\n\n"
echo "=============================================="
echo "      Easy Admin   Raymond Liu                "
echo "      2017.1.20                               "
echo "=============================================="
echo -e "\n\n"


answer=0


while [[ "$answer" != 'q' ]]
do
    echo "(1) Change \"Document\" Password"
    echo "(2) Change \"Music\" Password"
    echo "(3) Change \"Router\" Password"
    echo "(4) Show Document password"
    echo "(5) Show Music password"
    echo "(q) Exit(Quit)"
    echo -e "\n"

    echo -n "Please Enter Your Choice: "; read answer

    case $answer in
         1)
          documentnewpwd=`< /dev/urandom tr -dc a-z-0-9 | head -c10`
          (echo $documentnewpwd; echo $documentnewpwd) | smbpasswd -s document
          echo -e $documentnewpwd > documentpwd
          echo -e "\n"
          echo "Document New Password:  "$documentnewpwd
          echo -e "\n"
          ;;
         2)
          musicnewpwd=`< /dev/urandom tr -dc a-z-0-9 | head -c10`
          (echo $musicnewpwd; echo $musicnewpwd) | smbpasswd -s music
          echo -e $musicnewpwd > musicpwd
          echo -e "\n"
          echo "Music New Password:  "$musicnewpwd
          echo -e "\n"
          ;;
         3)
          ;;
         4)
          echo -e "\n\n"
          value=`cat documentpwd`
          echo "Document Password: --->   $value"
          echo -e "\n\n"
          ;;
         5)
          echo -e "\n\n"
          value=`cat musicpwd`
          echo "Music Password: --->   $value"
          echo -e "\n\n"
          ;;
     esac

done

exit 0



========================================================================
Internet Messenger

Basic prototype done

========================================================================
Setup Ubuntu Linux Server:

Step 1 Install cups and samba

sudo apt-get install cups
sudo apt-get install samba

Step 2 Create Samba user

Create User Account
sudo useradd -M -s /sbin/nologin document
sudo useradd -M -s /sbin/nologin music

Setup password for users"

sudo passwd document
sudo passwd music

$ sudo passwd music
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Add user account to the Samba database:

sudo  smbpasswd -a document
sudo  smbpasswd -a music
$ sudo  smbpasswd -a music
New SMB password:
Retype new SMB password:
Added user music.


Add user to local group

sudo groupadd shareGroup
sudo groupadd documentGroup
sudo groupadd musicGroup
sudo usermod -a -G documentGroup,shareGroup document
sudo usermod -a -G musicGroup,shareGroup music

Step 3 Creating the shared folders

sudo mkdir -p /srv/samba/share/
sudo mkdir -p /srv/samba/document/
sudo mkdir -p /srv/samba/music/

Setup folder permission 

sudo chgrp -R shareGroup /srv/samba/share/
sudo chgrp -R documentGroup /srv/samba/document/
sudo chgrp -R musicGroup /srv/samba/music/
sudo chmod 2770 /srv/samba/share/
sudo chmod 2770 /srv/samba/document/
sudo chmod 2770 /srv/samba/music/

Step 4 Config smb.conf

sudo nano /etc/samba/smb.conf
[share]
        path = /srv/samba/share/
        read only = no
        guest ok = no
        valid users = document,music
        force create mode = 0660
        force directory mode = 2770
        force group = shareGroup


[document]
        path = /srv/samba/document/
        read only = no
        guest ok = no
        valid users = document
        force create mode = 0660
        force directory mode = 2770
        force user = document
        force group = documentGroup


[music]
        path = /srv/samba/music/
        read only = no
        guest ok = no
        valid users = music
        force create mode = 0660
        force directory mode = 2770
        force user = music
        force group = musicGroup

Step 5 Start Samba Service

sudo service smbd stop
sudo service smbd start
sudo service smbd status

Step 6 Config cupsd.conf

sudo nano /etc/cups/cupsd.conf

change 
"
# Restrict access to the admin pages...
<Location /admin>
Order allow,deny
</Location>
"
to

"
# Restrict access to the admin pages...
<Location /admin>
Order allow,deny
Allow localhost
</Location>
"

Step 7 Start CUPS Service

sudo service cups stop
sudo service cups start
sudo service cups status


view cups admin page on local machines  
http://localhost:631

========================================================================

Bash On Ubuntu On Windows(Windows Subsystem for Linux)

After Windows 10 Build 14316 or later you can enable Microsoft Windows Subsystem for Linux feature
so you can run Ubuntu in your Windows box.

Check build version

C:\>systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name:                   Microsoft Windows 10 Enterprise Evaluation
OS Version:                10.0.14393 N/A Build 14393

C:\>

Step 1 Click Action center at right button corner and click all settings and
Step 2 On Windows Setting window click “Update & Security
Step 3 Click “For Developer” tab on the left
Step 4 Enable “Developer Mode” and restart the computer
Step 5 After Restart you can now open a command prompt (CMD) or powershell and type “bash“.
It will ask you to install Ubuntu just choose yes “y”

Windows PowerShell

Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS C:\Users\chako> bash
-- Beta feature --
This will install Ubuntu on Windows, distributed by Canonical
and licensed under its terms available here:
https://aka.ms/uowterms

Type "y" to continue: y
Downloading from the Windows Store... 100%
Extracting filesystem, this will take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: chako
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Installation successful!
The environment will start momentarily...
Documentation is available at:  https://aka.ms/wsldocs
chako@DESKTOP-ERGD9VC:/mnt/c/Users/chako$ systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
findstr: command not found
systeminfo: command not found
chako@DESKTOP-ERGD9VC:/mnt/c/Users/chako$

After complete the installation, you can now run “Bash On Ubuntu On Windows” 🙂

chako@DESKTOP-ERGD9VC:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:        14.04
Codename:       trusty
chako@DESKTOP-ERGD9VC:~$

Extend the activation time for evaluation version of Windows

For Microsoft 20-410~412 Windows Server 2012 R2 class, we download the evaluation version of Windows to try
things out and do our class projects. But some of you may find that the evaluation license only valid for 90 days.
So to solve this problem the simplest way is to use slmgr.vbs

Open Administrator CMD or Powershell and type:

slmgr /rearm 

It should works on Windows 8, 10, 2012, 2012 R2 and 2016.
After you done it the system should extend the activation time so you can keep doing your project :).

If you want to get more detail about the Windows machines’ activation, license and expiration date info your could try:

slmgr /dlv
or
slmgr /xpr