電訊茶室's Archiver

角色 發表於 2018-3-5 01:13

VirtualBox + RouterOS——Case Study 006

[i=s] 本帖最後由 角色 於 2018-3-5 12:51 編輯 [/i]

Please take a look at the following diagram:

[attach]4071[/attach]

Objectives:

1. Interface e1 is able to obtain a) IP address from the DHCP server, b) Gateway 192.168.55.1 and c) DNS servers via the DHCP client.
2. PC2 and PC4 are mutually pingable.
3. PC2 and PC4 are able to ping hostnames (e.g. [url]www.abc.com[/url]).

Procedures:

1. Clone the CHR RouterOS

2. Reset and initialise the VirtualBox Manboard for R1 VM
- add 4 NIC (one bridge, three internal networks)
- set each NIC promiscuous mode to allow-vmd
- add cables for NIC2-3[code]
VBoxManage modifyvm R1 --nic1 bridged
VBoxManage modifyvm R1 --bridgeadapter1 'en6: Thunderbolt Ethernet 3'

VBoxManage modifyvm R1 --nic2 intnet
VBoxManage modifyvm R1 --nic3 intnet
VBoxManage modifyvm R1 --nic4 intnet
VBoxManage modifyvm R1 --nic5 none
VBoxManage modifyvm R1 --nic6 none
VBoxManage modifyvm R1 --nic7 none
VBoxManage modifyvm R1 --nic8 none

VBoxManage modifyvm R1 --intnet2 Cable2
VBoxManage modifyvm R1 --intnet3 Cable3
VBoxManage modifyvm R1 --intnet4 Cable4

VBoxManage modifyvm R1 --nicpromisc2 allow-vms
VBoxManage modifyvm R1 --nicpromisc3 allow-vms
VBoxManage modifyvm R1 --nicpromisc4 allow-vms
[/code]#

3. Reset and initialise the R1 vm[code]/system reset-configuration no-defaults=yes[/code]#

After intialisation, you are able to ping any valid hostname via the console terminal since the default settings for ether1 (e1) after initialisation is dhcp client. (For the case that you do not have this settings, you can manually type[code]/ip dhcp-client add interface=ether1 disabled=no[/code]#

4. Set IP addresses for ether2 (e2) and ether4(e4)[code]/ip address add address=10.10.10.1/24 interface=ether2
/ip address add address=10.10.20.1/24 interface=ether4[/code]#

Now the settings for RouterOS R1 is complete. We proceed to the settings for PC2 and PC4

5. Clone the CHR RouterOS for PC2 and PC4 using the VirtualBox GUI

6. Initialise VirtualBox montherboards for PC2 and PC4

The following codes are used for setting up PC2[code]
VBoxManage modifyvm PC2 --nic1 intnet
VBoxManage modifyvm PC2 --nic2 none
VBoxManage modifyvm PC2 --nic3 none
VBoxManage modifyvm PC2 --nic4 none
VBoxManage modifyvm PC2 --nic5 none
VBoxManage modifyvm PC2 --nic6 none
VBoxManage modifyvm PC2 --nic7 none
VBoxManage modifyvm PC2 --nic8 none

VBoxManage modifyvm PC2 --intnet1 Cable2

VBoxManage modifyvm PC2 --nicpromisc1 allow-vms
[/code]#

The following codes are used for setting up PC4[code]
VBoxManage modifyvm PC4 --nic1 intnet
VBoxManage modifyvm PC4 --nic2 none
VBoxManage modifyvm PC4 --nic3 none
VBoxManage modifyvm PC4 --nic4 none
VBoxManage modifyvm PC4 --nic5 none
VBoxManage modifyvm PC4 --nic6 none
VBoxManage modifyvm PC4 --nic7 none
VBoxManage modifyvm PC4 --nic8 none

VBoxManage modifyvm PC4 --intnet1 Cable4

VBoxManage modifyvm PC4 --nicpromisc1 allow-vms
[/code]#

7. Start the PC2 and PC4 vms.

8. perform system reset for both PCs[code]/system reset-configuration no-defaults=yes[/code]#

9. Remove the default dhcp client in interface ether1[code]/ip dhcp-client remove 0[/code]#

10. Set the IP address for the ether1 of both PCs

PC2:[code]/ip address add address=10.10.10.2/24 interface=ether1[/code]#
PC4:[code]/ip address add address=10.10.20.2/24 interface=ether1[/code]#

11. Add default gateway for PC2 and PC4

PC2:[code]/ip route add gateway=10.10.10.1[/code]#
PC4:[code]/ip route add gateway=10.10.20.1[/code]#

With the above default gateways for each PC, both PC are able to be mutually pingable.

Up to this moment, we are still not able to ping [url]www.abc.com[/url] because the return address (10.10.10.0/24 and 10.10.20.0/24) is not known. The only know return address is 192.168.55.0/24. As a result, we need to add the masquerade rule for Router R1. Also we need to set up the dns server in PC2 and PC4.

11. Add nat masquerade rule in Router R1[code]/ip firewall nat add acition=masquerate chain=srcnat out-interface=ether1[/code]#

With Step 11, you are able to ping Internet IP address only. In order to ping hostname, we need two more steps.

12. Enable the DNS server in R1 to allow remote request[code]/ip dns set allow-remote-requests=yes[/code]#

13. Set the dns server in PC2 and PC4
PC2:[code]/ip dns set servers=10.10.10.1[/code]#
PC4:[code]/ip dns set servers=10.10.20.1[/code]#

At this mement, both PC2 and PC4 are able to ping any valid hostname, e.g. '[url]www.abc.com[/url]'.

頁: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.