• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • Life always offers you a second chance ... Its called tomorrow !!!

    Wednesday, March 05, 2014

    How to configure Private Network in VMware Workstation

    Scenario:

    We have 3 machines each with different IP range as shown below

    Machine 1 (Windows Host) - Connected to Internet
    IP Address - 192.168.1.xx
    Gateway - 192.168.1.1
    Netmask - 255.255.255.0

    Machine 2 (Linux 1)
    LAN 1 - 172.168.0.0/24
    LAN 2 - 10.10.10.0/24
    LAN 3 - Connected to Internet - 192.168.1.0/24

    Machine 3 (Linux 2)
    LAN 1 - 172.168.0.0/24
    LAN 2 - 10.10.10.0/24
    LAN 3 - Connected to Internet - 192.168.1.0/24


    By the end of this article you should be able to do the following

    • Linux 1 and Linux 2 should be inter connected to private network for 172.168.0.0/24 and 10.10.10.0/24
    • Linux 1 and Linux 2 should be connected to Internet
    • 10.10.10.0/24 and 172.168.0.0/24 would be able to transmit/receive packets to each other
    I am going to demonstrate you above using VMware Workstation 10.  In my case I have created two virtual machines (Linux) to do the same.

    To start with you need to add 3 NIC card to both your vm as shown below.

    1. Add Network Adapter

    Open the settings windows for the vm. (Make sure the vm is powered off)

    Click on Add

    Select Network Adapter from all the available option

    You can choose any of the Network Connection as it does not matters. You will have to change those in steps ahead. Just make sure you check the box with "Connect at power on"

    Click on Finish once done.

    Follow the same step to add 1 more NIC to the VM.

    2. Create LAN Segments

    Once done it is time to create LAN Segments and add it to your virtual machines. 

    Select any of the Network Adapter as shown below. You should see a Network Connection Type as "LAN Segments". Once you click on it a different window will pop up

    In this window you will have to create 2 LAN Segments namely LAN 1 and LAN 2 as shown below. Click on Add to create the same and once done click on OK to save the changes.

    Now you need to select Network Connection Type for all the 3 Network Adapter you created.

    3. Assign Network Connection Type

    For Network Adapter select LAN 1 as shown below. 

    NOTE: Next click on Advanced and view the MAC Address of this NIC and save it in a notepad as you would need it in steps ahead
    MAC Address: 00:0C:29:A3:F5:E6

    For Network Adapter 2 select LAN 2 as shown below.
    MAC Address: 00:0C:29:A3:F5:F0

    For Network Adapter 3 select LAN 3 as shown below.
    MAC Address: 00:0C:29:A3:F5:FA


    Repeat the same above steps for Machine 2 as shown below

    For Network Adapter select LAN 1 as shown below. 
    MAC Address: 00:0C:29:51:AA:CD

    For Network Adapter 2 select LAN 2 as shown below. 
    MAC Address: 00:0C:29:51:AA:D7

    For Network Adapter 3 select LAN 3 as shown below. 
    MAC Address: 00:0C:29:51:AA:E1

    So we are set now to move to next step.

    4. Assign IP Address

    Check the IP of your Windows Machine which is connected to Internet. As you see our IP Address details are
    IP Address: 192.168.1.xx
    Netmask=255.255.255.0
    Gateway = 192.168.1.1

    Linux 1
    Login to your Linux 1 box and verify if it contains 3 NIC as we had added
    [root@test ~]# ifconfig
    eth0      Link encap:Ethernet  HWaddr 00:0C:29:A3:F5:E6
              inet6 addr: fe80::20c:29ff:fea3:f5e6/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:756 errors:0 dropped:0 overruns:0 frame:0
              TX packets:831 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:71519 (69.8 KiB)  TX bytes:63525 (62.0 KiB)
              Interrupt:19 Base address:0x2024
    
    eth1      Link encap:Ethernet  HWaddr 00:0C:29:A3:F5:F0
              inet6 addr: fe80::20c:29ff:fea3:f5f0/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:33 errors:0 dropped:0 overruns:0 frame:0
              TX packets:74 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:5981 (5.8 KiB)  TX bytes:11003 (10.7 KiB)
              Interrupt:16 Base address:0x20a4
    
    eth2      Link encap:Ethernet  HWaddr 00:0C:29:A3:F5:FA
              inet6 addr: fe80::20c:29ff:fea3:f5fa/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:964 errors:0 dropped:0 overruns:0 frame:0
              TX packets:1205 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:80476 (78.5 KiB)  TX bytes:61790 (60.3 KiB)
              Interrupt:17 Base address:0x2424
    
    lo        Link encap:Local Loopback
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
              RX packets:649 errors:0 dropped:0 overruns:0 frame:0
              TX packets:649 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:56376 (55.0 KiB)  TX bytes:56376 (55.0 KiB)
    So as you see all the 3 NIC are visible. Now you can match each Network Adapter you added with the MAC Address before you start assigning IP Address to each NIC

    For Network Adapter -- LAN 1 (172.168.0.0/24)
    MAC Address: 00:0C:29:A3:F5:E6

    NOTE: Do not provide any GATEWAY or DNS details for private network
    [root@test ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE="eth0"
    NM_CONTROLLED=no
    ONBOOT=yes
    HWADDR=00:0C:29:A3:F5:E6
    TYPE=Ethernet
    BOOTPROTO=none
    IPADDR=172.168.0.2
    PREFIX=24
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=yes
    IPV6INIT=no
    NAME="System eth0"
    USERCTL=no
    PEERDNS=yes

    [root@test network-scripts]# cp ifcfg-eth0 ifcfg-eth1
    [root@test network-scripts]# cp ifcfg-eth0 ifcfg-eth2

    For Network Adapter 2 -- LAN 2 (10.10.10.0.0/24)
    MAC Address: 00:0C:29:A3:F5:F0

    NOTE: Do not provide any GATEWAY or DNS details for private network
    [root@test network-scripts]# vi ifcfg-eth1
    DEVICE="eth1"
    NM_CONTROLLED=no
    ONBOOT=yes
    HWADDR=
    00:0C:29:A3:F5:F0
    TYPE=Ethernet
    BOOTPROTO=none
    IPADDR=10.10.10.2
    PREFIX=24
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=yes
    IPV6INIT=no
    NAME="System eth1"
    USERCTL=no
    PEERDNS=yes

    For Network Adapter 3 -- LAN 3 (192.168.1.0/24) (Connected to Internet)
    MAC Address: 00:0C:29:A3:F5:FA
    [root@test network-scripts]# vi ifcfg-eth2
    DEVICE="eth2"
    NM_CONTROLLED=no
    ONBOOT=yes
    HWADDR=00:0C:29:A3:F5:FA
    TYPE=Ethernet
    BOOTPROTO=none
    IPADDR=192.168.1.10
    PREFIX=24
    GATEWAY=192.168.1.1
    DNS1=8.8.8.8
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=yes
    IPV6INIT=no
    NAME="System eth2"
    USERCTL=no
    PEERDNS=yes

    [root@test network-scripts]# service network restart
    Shutting down interface eth0:                              
    [  OK  ]
    Shutting down interface eth1:                              [  OK  ]
    Shutting down interface eth2:                              [  OK  ]
    Shutting down loopback interface:                          [  OK  ]
    Bringing up loopback interface:                            [  OK  ]
    Bringing up interface eth0:                                [  OK  ]
    Bringing up interface eth1:                                [  OK  ]
    Bringing up interface eth2:                                [  OK  ]


    On Linux 2
    [root@test1 ~]# ifconfig
    eth1      Link encap:Ethernet  HWaddr 00:0C:29:51:AA:CD
              inet6 addr: fe80::20c:29ff:fe51:aacd/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:801 errors:0 dropped:0 overruns:0 frame:0
              TX packets:789 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:64811 (63.2 KiB)  TX bytes:72377 (70.6 KiB)
              Interrupt:19 Base address:0x2024
    
    eth2      Link encap:Ethernet  HWaddr 00:0C:29:51:AA:D7
              inet6 addr: fe80::20c:29ff:fe51:aad7/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:21 errors:0 dropped:0 overruns:0 frame:0
              TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:2470 (2.4 KiB)  TX bytes:7223 (7.0 KiB)
              Interrupt:16 Base address:0x20a4
    
    eth3      Link encap:Ethernet  HWaddr 00:0C:29:51:AA:E1
              inet6 addr: fe80::20c:29ff:fe51:aae1/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:3461 errors:0 dropped:0 overruns:0 frame:0
              TX packets:158 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:244030 (238.3 KiB)  TX bytes:23210 (22.6 KiB)
              Interrupt:17 Base address:0x2424
    
    lo        Link encap:Local Loopback
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
              RX packets:90 errors:0 dropped:0 overruns:0 frame:0
              TX packets:90 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:7200 (7.0 KiB)  TX bytes:7200 (7.0 KiB)

    For Network Adapter -- LAN 1 (172.168.0.0/24)
    MAC Address: 00:0C:29:51:AA:CD

    NOTE: Do not provide any GATEWAY or DNS details for private network
    [root@test1 network-scripts]# vi ifcfg-eth1
    DEVICE=eth1
    NM_CONTROLLED=no
    ONBOOT=yes
    HWADDR=00:0c:29:51:aa:cd
    TYPE=Ethernet
    BOOTPROTO=none
    IPADDR=172.168.0.3
    PREFIX=24
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=yes
    IPV6INIT=no
    NAME="System eth1"
    USERCTL=no
    PEERDNS=yes

    [root@test1 network-scripts]# cp ifcfg-eth1 ifcfg-eth2
    [root@test1 network-scripts]# cp ifcfg-eth1 ifcfg-eth3

    For Network Adapter 2 -- LAN 2 (10.10.10.0.0/24)
    MAC Address: 00:0C:29:51:AA:D7

    NOTE: Do not provide any GATEWAY or DNS details for private network
    [root@test1 network-scripts]# vi ifcfg-eth2
    DEVICE=eth2
    NM_CONTROLLED=no
    ONBOOT=yes
    HWADDR=00:0c:29:51:aa:d7
    TYPE=Ethernet
    BOOTPROTO=none
    IPADDR=10.10.10.3
    PREFIX=24
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=yes
    IPV6INIT=no
    NAME="System eth2"
    USERCTL=no
    PEERDNS=yes

    For Network Adapter 3 -- LAN 3 (192.168.1.0/24) (Connected to Internet)
    MAC Address: 00:0C:29:51:AA:E1
    [root@test1 network-scripts]# vi ifcfg-eth3
    DEVICE=eth3
    NM_CONTROLLED=no
    ONBOOT=yes
    HWADDR=00:0c:29:51:aa:e1
    TYPE=Ethernet
    BOOTPROTO=none
    IPADDR=192.168.1.11
    PREFIX=24
    GATEWAY=192.168.1.1
    DNS1=8.8.8.8
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=yes
    IPV6INIT=no
    NAME="System eth3"
    USERCTL=no
    PEERDNS=yes

    [root@test1 network-scripts]# service network restart
    Shutting down interface eth1:                              
    [  OK  ]
    Shutting down interface eth2:                              [  OK  ]
    Shutting down interface eth3:                              [  OK  ]
    Shutting down loopback interface:                          [  OK  ]
    Bringing up loopback interface:                            [  OK  ]
    Bringing up interface eth1:                                [  OK  ]
    Bringing up interface eth2:                                [  OK  ]
    Bringing up interface eth3:                                [  OK  ]


    Verify the configuration

    From Linux 1
    [root@test ~]# ping 172.168.0.3
    PING 172.168.0.3 (172.168.0.3) 56(84) bytes of data.
    64 bytes from 172.168.0.3: icmp_seq=1 ttl=64 time=0.513 ms
    64 bytes from 172.168.0.3: icmp_seq=2 ttl=64 time=0.639 ms
    ^C
    --- 172.168.0.3 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1520ms
    rtt min/avg/max/mdev = 0.513/0.576/0.639/0.063 ms

    [root@test ~]# ping 10.10.10.3
    PING 10.10.10.3 (10.10.10.3) 56(84) bytes of data.
    64 bytes from 10.10.10.3: icmp_seq=1 ttl=64 time=2.39 ms
    64 bytes from 10.10.10.3: icmp_seq=2 ttl=64 time=0.515 ms
    ^C
    --- 10.10.10.3 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1551ms
    rtt min/avg/max/mdev = 0.515/1.453/2.392/0.939 ms

    [root@test ~]# ping google.com
    PING google.com (74.125.236.167) 56(84) bytes of data.
    64 bytes from maa03s16-in-f7.1e100.net (74.125.236.167): icmp_seq=1 ttl=56 time=14.0 ms
    64 bytes from maa03s16-in-f7.1e100.net (74.125.236.167): icmp_seq=2 ttl=56 time=10.5 ms
    ^C
    --- google.com ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1049ms
    rtt min/avg/max/mdev = 10.584/12.334/14.085/1.754 ms


    From Linux 2
    [root@test1 ~]# ping 172.168.0.2
    PING 172.168.0.2 (172.168.0.2) 56(84) bytes of data.
    64 bytes from 172.168.0.2: icmp_seq=1 ttl=64 time=0.261 ms
    64 bytes from 172.168.0.2: icmp_seq=2 ttl=64 time=0.460 ms
    ^C
    --- 172.168.0.2 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1127ms
    rtt min/avg/max/mdev = 0.261/0.360/0.460/0.101 ms

    [root@test1 ~]# ping 10.10.10.2
    PING 10.10.10.2 (10.10.10.2) 56(84) bytes of data.
    64 bytes from 10.10.10.2: icmp_seq=1 ttl=64 time=1.12 ms
    64 bytes from 10.10.10.2: icmp_seq=2 ttl=64 time=0.628 ms
    ^C
    --- 10.10.10.2 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1074ms
    rtt min/avg/max/mdev = 0.628/0.875/1.123/0.249 ms

    [root@test1 ~]# ping google.com
    PING google.com (74.125.236.163) 56(84) bytes of data.
    64 bytes from maa03s16-in-f3.1e100.net (74.125.236.163): icmp_seq=1 ttl=56 time=9.69 ms
    64 bytes from maa03s16-in-f3.1e100.net (74.125.236.163): icmp_seq=2 ttl=56 time=10.3 ms
    ^C
    --- google.com ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1520ms
    rtt min/avg/max/mdev = 9.699/10.006/10.314/0.323 ms


    So I think everything is working as expected. Let me know your success and failures


    Related Articles
    Creating an internal network using VMware Workstation
    Configure Red Hat Cluster using VMware, Quorum Disk, GFS2, Openfiler

    Follow the below links for more tutorials

    Step by Step Linux Boot Process Explained In Detail
    10 examples to help you understand top command usage in Unix/Linux
    Script to take backup of any critical directory in Unix/Linux
    Configure Red Hat Cluster using VMware, Quorum Disk, GFS2, Openfiler
    Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
    How to configure Samba 4 Secondary Domain Controller
    How to secure Apache web server in Linux using password (.htaccess)
    How to register Red Hat Linux with RHN (Red Hat Network )
    15 tips to enhance security of your Linux machine
    Why is Linux more secure than windows and any other OS
    What is the difference between "su" and "su -" in Linux?
    What is kernel-PAE in Linux?
    What is swappiness and how do we change its value?
    How to log iptables messages in different log file
    What are the s and k scripts in the etc rcx.d directories
    What is virtual memory, paging and swap space?

    1 comments: