This website is preserved for historical and scholarly reference and is no longer actively maintained.
VirtualBox Networking -
This page provides background on networking concepts applied in a
virtual box network environment. We organize this page into two
main sections. The first provides a brief background on networking
in VBox. The second describes the network setup that we
require for our two VM environment. The discussion walks you
through three steps (referred to a scenarios). You need to
sucessfully complete all three. We provide a test
after each scenario to ensure you correctly have setup the
scenario.
First....if for some reason your VM appears to have lost
it's guest additions - several approaches to fix this issue:
- one work around is to remove the optical disk from the VM
settings (turn off your VM) and then file and virtual media
manager. Then in virtual media mgr, add a optical disk
and have it point to the
c:/ProgramFiles/Oracle/VirtualBox/guestAdditions.iso
-Another approach is to
A second topic is to install VirtualBox Extension pack:
1 Networking in VirtualBox
This section provides details on the default virtual environment
setup with VirtualBox with ubuntu 16.04 running as a Guest. From a
TCP/IP perspective, we refer to the Guest as VM1 and the TCP/IP
host that represents VirtualBox's Host and VMM as the Host. Any
number of VMs can be created, with 1 or more virtual networks. We
then present a section describing several network options for a
single VM scenario. An additional subsection talks about
networking options for a scenario involving 2 VMs.
First, let's identify several important concepts and Linux
commands.
- As true of all modern Operating Systems, your VM supports IPV4
and IPV6. As we look at interfaces, we should always see both
IPV4 AND IPV6 IP addresses.
- An IPv4 address is a 32 bit unsigned integer. We usually use
dotted quad notation by specifying each octet as a number
(0-255).
- We will see the term NAT quite a bit. It stands for Network
Address Translation. It is commonly used in access networks,
such as your home network that requires a connection to an
Internet Service Provider. In many home network scenarios, the
'modem' serves as the router, interfacing your home network with
the outside world through a wide area link to your ISP.
- NAT likely operates at your router- it's job is to allow
all TCP/IP hosts and devices in your home network to connect
to the Internet in a manner that requires only 1 single IP
address. So NAT multiplexes multiple Hosts over a single IP
end point.
- Another concept that can be used with IP networks (and that is
supported by VirtualBox) is port forwarding. Several variants of
the idea exit, but the simplest explanation is you can cause
certain types of inbound packets (inbound to the Host OS router
implemented by the VMM) to be fowarded to VMs located on an
internal private network. Think of this as 'poking a hole' in
the firewall, and instructing the firewall to modify certain
fields in the IP or transport header (like the outbound address
or port ). When setting up port forwarding, you specify the
matching destination IP address and port and the new destination
address and port. The simple case is when the new destination IP
address is the Host's IP address, but packets with specific
ports are 'forwarded' to a new destination IP and port. NAT
generally does not allow 'unsolicited' outside connections (in
other words, NAT works only on IP flows that originate from the
private side. NAT, therefore, supports inside-to-outside
connectivity. Port forwarding is a widely used technique that
allows unsolicited outside-to-inside access.
- You can setup a port forwarding rule using the VboxManage
modifyvm command (described below) or in the VM's Machine
setup, networking, and select port forwarding.
- Linux commands related to networking
- ip : the command line interface program to all networking
config and information. Try, 'ip address'
- ifconfig, outdated by ip address, but I use it still out
of habit. This lists the network interfaces on your system.
On my VM, I have three interfaces, enp0s8, enp0s17 and lo.
- The last interface, lo, is created by default on all
Unix systems- it is the 'loopback' address of 127.0.0.1.
Try a 'ping 127.0.0.1', then try 'ping loopback'. All
addresses in the range of 127.0.0.0 through
127.255.255.255 represent a set of special addresses.
Loopback is a special name that by convention is
understood by virtually all TCP/IP implementations.
- The enp0s8 exists because I have multiple VMs on my
system and they interconnect on the network 192.168.2/24
network
- The details for the interface to the outside world
(enp0s17, IP V4 address in dotted quad format:
10.0.2.15):
- enp0s17 Link encap:Ethernet HWaddr
08:00:27:07:86:85
inet addr:10.0.2.15 Bcast:10.0.2.255
Mask:255.255.255.0
inet6 addr: fe80::e1dd:e78b:5f70:d500/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:44630 errors:0 dropped:0 overruns:0
frame:0
TX packets:35505 errors:0 dropped:0 overruns:0
carrier:0
collisions:0 txqueuelen:1000
RX bytes:21176523 (21.1 MB) TX bytes:3889298 (3.8
MB)
- sysctl - a program that allows you to set kernel config,
and to read the state of kernel settings.
- sysctl -a ;lists all options.
- sysctl net.ipv4 lists all options related to ipv4
- To see if a Host is setup to forward packets (only
meaningful if the Host has > 1 interface),
- sysctl net.ipv4.conf.all.forwarding
- It will show the current value (0 or 1). To
change:
- sudo sysctl net.ipv4.conf.all.forwarding=1
- iptables - command line interface to setting up the Linux
firewall, NAT, port forwarding, and netem (network
emulation).
- To see the list of all rules: iptables -L
- There are two ways to configure network interfaces in
Ubuntu:
- Method 1 (recommended for beginners): Use the network
manager. The alternative, method 2, is to edit network
script files which makes it a bit easier to mess things
up!!! The discussion below assumes network manager but
we likely will be looking at config files.
VirtualBox supports a number of virtualized networks:
- NAT (Section 6.3 of the Manual): This is the default as it is
the simplest. Each VM by default will use the NAT network. The
VM interface is allocated 10.0.2.15 (as all other VMs). The Host
OS's IP assigned to its interface is 10.0.2.2.
- NAT Network: This is a second NAT implementation. See section
6.4. It relies more on the VMs for NAT support than the original
NAT.
- Internal Network: This is a private network that is most
similar to how a real private network on real machines would be
setup. This is recommended over a Host only network.
- Host only network: This is a private network that connects
Hosts. This network does not have connectivity to the outside
unless one of the VMs has a second interface connected to the
Host.
- Bridge: This supports a configuration where a VM effectively
sits on the same external network as the Host OS. The VMs IP
address for the interface can be assigned by the same DHCP
server that assigned the IP of the Host OS.
These various choices of networks allows VirtualBox to support
VMs that are happy being 1)disconnected from any external network;
2)secure outside-to-inside access with NAT; 3)unsolicited
outside-to-inside access with Bridge networking; 4)more
restrictive unsolicited outside-to-inside access with NAT and port
forwarding.
Additional items to keep in mind:
- The virtual network environment supported by VirtualBox (and
VMWare) appears as a real network to the Guest OS. When we
install the extensions however, it replaces the real ethernet
driver with one that can interact directly with the VMM running
on the Host OS. So from our Linux Host, all TCP/IP protocols,
including the use of arp hold.
- We assume IPv4 networking, which means a 32 bit IP address is
to be assigned to each interface on a Guest VM.
- Guest IP addresses can be assigned dynamically or statically.
- Dynamic- this requires a Dynamic Host Configuration
Protocol (DHCP) server- which by default is provided by the
Host and which by default is required by the Guest.
- Static- To set a specific IP address, use the Guest OS
configuration.
- In TCP/IP (version 4 only - version 6 uses much larger size IP
addresses), there are 2EXP32 available numbers in a 32 bit
address space. Not all of these numbers are valid IP addresses
as portions of the address range (from 0 to 2EXP32) are
considered special (all 1's, all 0's, private IP addresses).
- Rather than identify an IP address as a unsigned number,
the number is interpreted an octet at a time, such as
130.127.22 55. This is referred to as dotted decimal
notation.
- IP v4 addresses are considered as 2 (sometimes 3) level
hierarchical address. This means there is multiple pieces of
interformation encoded in a 32 bit IP address. The original
classful address mechanism defines a 32 bit address as
<network id , host id> , further, the first several
bits (most significant bits of the 32 bit value) encode the
class (or type) of address: Class A, B, C, or D. Class A,B,C
correspond to valid IP addresses but each class specifies a
different demarcation of network and host bits. Class A
defines the network id as the most significant octet
(leaving 3 octets to define specific hosts that attach to
that network. Class B and Class C addresses define netork id
of 16 and 24 bits. The idea behind classful addressing is
that all networks are likely not the same size.
- Blocks of addresses within Class A,B,and C networks are
referred to as private addresses. For example, in Class A
networks, addresses in the range 10.0.0.0-10.255.255.255 are
private. Class B and Class C private addressing blocks are
172.16.0.0-172.31.255.255 and 192.168.0.0-192.168.255.255.
By definition, a private IP address only has meaning (i.e.,
is routable) by Hosts within a specific organization's
TCP/IP network (in Internet terminology: within a single
autonomous network).
- Clemson has several blocks of valid IP addresses, one
of which is the Class B network 130.127/16 (using
network prefix notation to identify a specific network
(the number after the slash specifies how many bits are
used to specify the network id).
- No other network in the world can be assigned any
IP address in this block 130.127/16. There are
Internet operating rules, policies, practices,
and organizations that oversee all aspects of the
Internet necessary to maintain a well
functioning global internet.
- The global routing used in the network has enough
information to know that any packet that contains a
destination IP address that falls within the block
of 64K IP addresses beginning with 130.127 are to be
routed to our clemson border routers.
- It is up to Clemson if they want to route any of
the private IP networks (they so route some
172.16/16 nets). There are many private nets on
campus, some that use the same network id. The
admins of each of these private networks is
responsible for correctly interconnecting as needed
with outside networks.
- Network address translation is the most common technique
for handling private IP networks to communicate with
external networks.
- A border gateway (in our case, VirtualBox Host)
supports NAT. There are several types of NAT but the
most basic is called NAPT (for Network Address Port
Translation). By default, a form of NAPT is used to
interconnect our VM to the outside world.
2 Network Scenarios
We present three specific VM configuration steps that are
required to support our 2 VM network setup.
- The first involves a single VM and is illustrated in Figure 1.
- The second extends the first scenario by allowing outside to
inside access to VM1. This lets you ssh directly into your VM1
from a campus computer that has access to the campus network.
- The third scenario adds a second VM (which we refer to
as VM2). VM2 can reach the Internet but the instructions
will not allow direct outside to inside access to VM2. extends
allows outside to inside access to VM1.
Figure 1 illustrates the network diagram that is applicable to
steps 1 and 2. In the discussion, we assume that the Host
OS has a campus network connection that has been assigned the IP
V4 address 130.127.10.10.
Note that the figure identifies a SoC Linux machine (ada8). When
we say VM1 has 'outside to inside access', we mean that, as
an example, from ada8, you can ssh directly into VM1 (The Host OS
/ VMM is configured to port forward ssh to VM1).
The Net1 and Net2 in Figure 1 represent two networks
involved. Net1 is clemson's network - it could be a WiFi
connection or a wired connection depending on what machine you are
using for your Host OS, and how it connects to the campus
network.
Net 2 is a Virtual Box virtual network. After completing Step
1, Net2 simply connects VM1 with virtual NIC on the
Host OS. Assuming we use the default NAT setup for VM1, Figure 1
shows the IP addresses that are involved.
ada8.computing.clemson.edu---
|
Clemson Campus Network ----Net1 -|--- Host OS ---- Net2 -----VM1
10.0.2.2
10.0.2.15
Figure 1- Network Diagram - single VM.
Step 1 - one VM, default NAT setup, only inside to outside
access. So an external machine (like Koala5.cs.clemson.edu ) can
not access the VM1.
By default, the Host OS serves as a NAT router on behalf of VM1.
The Host OS's private (virtual) side network interace is asigned
an IP address of 10.0.2.2
L1 is the link from Host to the outside (campus wifi ) and L2 is
the virtual network where the details can vary depending on how we
configure the VM. Our starting point is to have L2 be a simple
ethernet link as seen by VM1.The simplest approach is to use the
default setup of NAT. By default, VirtualBox sets the the default
network setup for VM1 will be 'NAT' (Note.....not NATNetwork). See
Section 6.2 of the Manual.
The following is how virtual box setups up the virtual network.
Internet ----host os ------'hard wired link'---- VM1
------------ ....10.0.2.2
.................................10.0.2.15
VirtualBox setups up a 'hard wired link' allowing a VM (any
number) to communicate through the Host using NAT. Don't be
alarmed when you see all VMs are assigned an IP address of the
same.
The VM will show a NAT network (Settings --- Networks ). Click
Advanced and it will show the MAC address. VirtualBox uses a
somewhat strange network scenario-it assigns all VMs to use NAT
with an IP of 10.0.2.15.
validate the network is as expected by:
- On VM1 issue ifconfig and make sure the IP is 10.0.2.15
- On VM1 issue traceroute google.com and make sure the first hop
router IP is 10.0.2.2
Explanation: Host OS is performing NAT on behalf of flows
intiated by VM1. Let's say our Host OS has an IP of 130.127.10.10.
When VM1 issues a ping to a machine like koala5.cs.clemson.edu,
the koala host will think its interacting with a host with a
source IP of the Host OS's IP address to the outside
world.....when really the source Host is VM1!!
Hosts on campus can ping the Host OS at 130.127.10.10 (using our
example). But the VM's can not be reached from the outside unless
the connection is initiated by the VM (or we allow for Scenario 2
described below).
To complete the configuration, start VM1, assuming it it Ubuntu
16.04, select System Settings and Networks. Select the Wired
network that has been assigned 10.0.2.15. If you are just doing
Scenario1, you should just see 1 wired connection. If it has not
been configured, specify options and IPV4. Set the Method to
Automotic (DHCP) - the Host OS (and VirtualBox VMM) has a DHCP
server running and will provide the required IP address,
subnet/netmask and Gateway. You can set the button 'Require IPv4
Adressing for this connection to complete (probably not
required....). Selet Routes and you should not see
anything....make sure 'Use this Connection only for resources on
its network is NOT clicked.
Step 2 - one VM but with outside to inside access
To allow outside to inside access, port forwarding can be used.
We will forward packets from two applications: ssh (requriing a -p
5555 param to force it to use 5555), and a UDPEcho application
running the server bound to port 5000 at VM1.
Question: Why require port 5555 when accessing VM1? This way, you
can still access your Host OS using ssh (without specifying a port
uses a default of 22).
Note: this will not allow direct access from the campus network
to your VM2 Kali VM!!
There are two methods: port forwarding and bridge mode.
IMPORTANT...quick review of VboxManage - this is the command
line interface available on your Host OS that allows you to do
EVERTHING the GUI Virtual Box configuration allows (and actually
much more).
- On you Host OS, issue VBoxManage list vms to find out the
name of VM1 and VM2. In my example, let's say VM1 is 'VM1'.
- On your Host OS, find out the IP address used to connect to
campus (on windows, us ipconfig, on Mac or Linux, use ifconfig).
Let's assume in the example below my Host OS IP to campus is
130.127.49.44. And...let's say my userid on VM1 is jjm
Method 1 : Port forwarding (recommended)
The VboxManage modify command to 'poke a hole' (referred to as
port forwarding) through the NAT/FW is '--natpf<1-N> [
<rulename>], tcp|udp, [<hostip>], <hostport>,
[<guestIP>], <guestport>
The --natpf<1-N> ids the interface. In our simple
HostOS---- 10.0.2/24 ----VM1---- internal network ---- VM2, there
is only one Interface from VBoxManage perpsective....the 10.0.2.2
interface that is 'virtually created' by the VMM and is the link
between the Host OS and VM1. Remember that for VM1, it's default
router must be 10.0.2.2.
- VBoxManage.exe modifyvm "VM1" --natpf1
"sshClient,tcp,,5555,,22"
- rule name sshClient (which is arbitrary....it can be
whatever you want), tcp,hostIP not specified which I believe
says use the IP assigned to the inbound packet, require the
dst port 5555, don't specify guestIP (presumably defaults to
the only option which is VM1's interface (10.0.2.15), map
the source port to port 22 (which is required for ssh to
work).
- From the outside, to ssh into your VM1, issue 'ssh -p 5555
jjm@130.127.49.44'
- VBoxManage.exe modifyvm "VM1" --natpf1
"UDPEcho,udp,,5000,,5000"
- Rule name is UDPEcho to give me the hint that the reason
I am adding this hole is if we want to run a UDP server on
VM1 operating with port 5000.
- Forwards udp packets with dst port of 5000 to the VM1
A modifyvm --natpf1 operation is required for each specific
application your want to permit and forward to a VM application. .
- If we wanted to access for example a TCPEchoServer running on
port 5000 on VM1, the rule would be
- VBoxManage modifyvm "VM1" --natpf1
"TCPEcho,udp,,5000,,5000".
- To access a web server on VM1,
- VBoxManage modifyvm "VM1" --natpf1 "http,tcp,,80,,80"
- VBoxManage modifyvm "VM1" --natpf1 "http,tcp,,443,,443"
Listing all PF rules does not seem to be available through
VBoxManage. It is easy with the GUI however. In the VM, select
Machine, Setings, network and port forwarding will list the PF
rules. If you ever need to remove a rule, you need to do this
procedure to get the rule ID number. Then on your Host OS,
assuming we want to remove PF rule number "1234":: VboxManage
modify "VM1" --natpf1 delete "1234"
To test, on your Host OS, oopen a terminal (or command line shell
on windows), issue ifconfig (on Linux/MacOS) or ipconfig on
Windows to learns the IP address assigned to your computers
connection to the campus network. As an example, let's say this is
130.127. 10.10 and your VM1 user name is jjm. Then, ssh to a
department Linux machine. From this machine, issue 'ssh -p 5555
jjm@130.127.10.10' and this allows your to login to your VM1.
You can also configure port forwarding using the VMM 's VM config
panels. Select the VM Machine config, and click on 'Port
Forwarding'. If you did a VBoxManage command you should see
the entry in this config page. To add a port forwarding
rule, click + and enter the information - it should be
similar to what was discussed above.
Method 2: Bridge Mode
There is another method for allowing outside to inside access....
VirtualBox supports 'Bridge Mode'. This does NOT use NAT and
should be used for a very different purpose: only if you want the
VM to appear as it it is physically connected to the same external
network used by the Host OS. The VM could then be setup to use
DHCP and it would interact with the same DHCP server that your
Host OS would use to get an IP address, subnetwork mask, first hop
router, and DNS NS. One some versions of MAC OS, we've seen natpf
NOT work correctly and Bridge mode was required. With recent
VirtualBox versions....both modes appear stable on all Host OSs
(Windows 10, Linux/Ubuntu, MACOS).
Modify the VM machine configuration to use Bridge Mode for the
type of network on the interface that will be used to provide
connectivity to the outside world. Modify the VM (actually this
would be the default settings in the VM OS) to used DHCP to obtain
its IP information. When the VM boots it interacts with a DHCP
server that should be in operation in the outside network. For a
campus environment, the VM is allocated an IP address in the same
way as the Host OS's interface to the campus network. The address
will be different than that allocated to the Host OS. The campus
wifi network (eduroam) is a bit problematic- you might need to
connect your laptop to a campus ethernet. The easiest to get
working is usually in your home environment where you have control
over the WiFi AP.
Step 3 - Two VMs, VM1 accessible from the outside (see Scenario
2 above) and VM2 able to reach VM1 AND the Internet. This requires
VM1 to act as the first hop router for VM2. This does NOT allow
access from the campus network directly to VM2.
We will setup the private network as shown below. VM1 will have 2
adapters. VM2 will have one adapter. The VM1 and VM2 private
network IPs will be 192.168.2.1 and 192.168.2.2 resp.
Internet ----host os ------'hard wire'---- VM1 ----- private
192.168.2/24 ---- VM2
----130.127.x.x
-------------10.0.2.2---.10.0.2.15.............192.168.2.1
---------------------192.168.2.2
Figure 2- Network Diagram
We will setup the private network as shown below. VM1 will have 2
adapters. VM2 will have one adapter. The VM1 and VM2 private
network IPs will be 192.168.2.1 and 192.168.2.2 resp. VM1
serves as a Router.VM1 is our Ubuntu 16.04 VM, VM2 is our
Kali
We assume the following
- VM1 is setup as in step 2 with the port forwarding
commands correctly issued (and you have tested by ssh'ing into
your VM1).
- VM2 can be ubuntu or kali. The network connecting VM1 and VM2
is referred to as a private network. VirtualBox gives us two
ways to create this - one called Host Only and the other is
called 'internal network'. We assume that after you
installed VM2 , the default network was NAT and it was assigned
a 10.0.2.15 address. The default Linux manager will
correctly setup this NIC - it will assume DHCP. The
VirtualBox VMM runs a DHCP server.
- We'll focus on the latter as it is closer to a real network
setup as illustrated in Figure2. An internal network does not
require any configuration from the VMM top level (file,
preferences, networks, .... ). Only the two VM Settings need to
be modified to use the internal network.
WARNING:
- Recommend that you create several test user ids (accounts) on
Kali. Kali makes it easy to do certain things as root.....but
some things are easier and safer to do as a regular user.
- Make sure that openssh-server is installed and running on both
VMs (else you won't be able to ssh into the VM).
- To see if it's running : ps aux | grep ssh
- If you don't see a sshd process running, , you might need
to install: (apt-get install openssh-server) or more likely
if it's Kali just do a restart:
There are three steps to complete....and this assumes VM1 is
setup correctly as in Scenario 2. This does not require any global
network preferences changes in the VMM manager area of the
VirtualBox VM Manager.
STEP 1: Setup the 192.168.2/24 network interfaces on
each VM. VM1 requires a second network adapter. VM2 requires the
type of network configured by default on adapter 1 is changed from
NAT to 'internal network'.
We use the VirtualBox Machine Manager, go into network settings:
- For VM1, the first adapter should remain NAT. Create a second
adapter and specify the network type as internal.
- For VM2, the first adapter should be changed to internal
network(not NAT). OR you can disable the first adapter, and
enable the second adapter to be internal.
STEP2: Each Guest OS Linux network configuration needs to be set
correctly - we use the network manager to do this.
- VM1:
- Use the Ubuntu network manager (select system settings and
then networks) to configure the two wired interfaces that
should exist (if we did STEP 1 correctly!!). One of the
interfaces should already have been allocated an IP address
of 10.0.2.15. This is the interface between VM1 and
the Host OS. If you select options, and then IPv4 Settings,
you would see that the address method is DHCP. Set an
additional DNS server to 8.8.8.8. Also, select the 'require
IPv4 addressing for this connection to complete'.
- The second interface needs to be enabled and configured as
follows: . Go into options, and IPv4Settings, set the
address method to manual. Add the address /netmask/gateway
t0
- 192.168.2.1,
24,
(NOTE: DO NOT Specify a default router )
- Set the DNS server to 8.8.8.8.
- At the end of these steps, from VM1, you should be able to
issue a ping 8.8.8.8 successfully.
- VM2,
- On Kali, click on the network icon in the upper right or
find the 'Settings' folder and select 'Network' It should
bring up a network manager very similar to that used by
Ubuntu. Configure the only wired interface. On the latest
Kali, the config input asks for:
- IPV4 Method: manual.
- Addresses:
- Add the address /netmask / gateway to be
192.168.2.2, 24, 192.168.2.1 (NOTE: The
default router is VM1!)
- Set the DNS server to 8.8.8.8
- If this is successful, from a term, you should be able to
ping VM1, (ping 192.168.2.1) but NOT a Host in the Internet
(8.8.8.8). This is because we have one more step- to setup
VM1 to serve as a NAT router..
STEP 3: Next, configure VM1 to serve as a NAT router to allow VM2
to reach the Internet.
- This is the magic step...setting up VM1 to allow VM2 to
connect with the outside world. If successful, the IP
addresses are as shown below. We will end up with something
that sounds strange but it works.....NAT is in affect at
both the HostOS and at VM1. More specifically, :
We use the addresses and network interface names for our
discussion. following addresses for the VM1-VM2 network
............................................enp0s3 ...VM1
..enp0s8.....eth0---VM2
Outside Network ---HostOS-------------VM1-----------VM2
.............................10.0.2.2 ......10.0.2.15
192.168.2.1 ------ 192.168.2.2
- On VM1, issue the following to forward IP packets.
- 'sudo sysctl net.ipv4.conf.all.forwarding=1'
- On VM1, issue the following to run NAT on outbound packets
destined for enp0s3, using the shared IP 192.168.2.1 (i.e., VM1
performs NAT for all hosts on the private IP)
- 'sudo iptables -t nat -A POSTROUTING -o enp0s3 -j SNAT
--to 192.168.2.1'
We have a script that can be used to help .... the script
supports a number of configuration commands....but the command
parameters 'NAT outboundIFName privateIP' will do the two
steps shown above:
- UbuntuNetSetup.sh
- This script provides a number of options -
try sudo ./UbuntuNetSetup.sh
showIP to see the current setup
- Using the above example, run this
script: sudo ./UbuntuNetSetup.sh startNAT
enp0s3 192.168.2.1
- simpleNAT.sh
-
- We took the 5 actual iptables commands that run in
UbuntuNetSetup when it processes a startNAT opcode. It's
meant to make it easier to focus on just we need to do.
- To run : sudo
./simpleNAT.sh (NOTE: This
hardcodes the IF name and IP address params. Edit this if you
need to change these from the default of enp0s3 and
192.168.2.1)
- You can run 'sudo ./setupVMRouter.sh show' to see the current
status. Note the last thing shown is the IP address that is
actually used by this Host in the public Internet .... note that
you need to have the program curl installed.
- There can be multiple NAT routers that a packet traverses
as it makes its way to the border router (the router that
provide access to the Internet). The technique used in the
script uses an external server to provide essentially a ping
of the source IP address.
- To check...... from VM2, issue ping 8.8.8.8 and it should
work.
- If this does not work, first see what does work. Use
ifconfig on both VMs. Ping local interfaces (e.g., on
VM2, ping 192.168.2.2 ; And if this works:
ping 192.168.2.1). If that works : ping 10.0.2.15.
If that works: ping 10.0.2.2
- You should be able to ssh from VM2 into VM1 or to a department
machine
- You should be able to ssh from VM1 into VM2. But.....you can
not ssh into VM2 directly from an outside Host (but you can ssh
from an outside Host into VM1).
last updated: 4/7/2019