Previous - Up - Next

4.10   Connect to a Real Network

A simulation can be connected to a real network. By doing this, simulated computers and real computers are able to communicate with each other.


Note: If you experience timing problems, for example TCP timeouts, when using real network, the simulation is running too fast. In these cases, slow it down by using the enable-real-time-mode command.

Before following the steps in this example, launch a new ebony-linux-firststeps.simics. Don't boot it yet.

Connecting a simulated machine to a real network is done with one command:

simics>  connect-real-network 10.10.0.50
No ethernet-link found, creating 'ethlink0'.
No service-node found, creating 'ethlink0_sn0' with IP '10.10.0.1'.
Connecting device 'emac1' to 'ethlink0'
Connecting device 'emac0' to 'ethlink0'
NAPT enabled with gateway 10.10.0.1 on link ethlink0.
Host TCP port 4021 −> 10.10.0.50:21 on link ethlink0
Host TCP port 4023 −> 10.10.0.50:23 on link ethlink0
Host TCP port 4080 −> 10.10.0.50:80 on link ethlink0
Real DNS enabled at 10.10.0.1 on link ethlink0.
simics>  continue


Note: Note that the IP address specified in the connect-real-network command is the IP address of the simulated machine

This command will create a new ethernet-link, connect it to both the simulated network cards, and to the real network. It will also enable NAPT, network address port translation. Finally, it will forward ports 4021, 4023 and 4080 to the simulated machine's telnet, FTP and HTTP ports.

To actually make the real network accessible from the simulated machine, the simulated system must be configured. These commands set up the service node as gateway and domain name server:

root@firststeps: ~# route add default gw 10.10.0.1
root@firststeps: ~# echo nameserver 10.10.0.1 > /etc/resolv.conf
root@firststeps: ~#

This tells the simulated system to direct all accesses outside the local network to the gateway at 10.10.0.1 (which is the service node connect-real-network created for us).

Now, if your computer is connected to Internet, we can try to telnet to a real computer on Internet. In this example we use gnu.org.

root@firststeps: ~# telnet gnu.org 80
GET /
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>301 Moved Permanently</TITLE>
</HEAD><BODY>
<H1>Moved Permanently</H1>
The document has moved <A HREF="http://www.gnu.org/">here</A>.<P>
<HR>
<ADDRESS>Apache/1.3.31 Server at gnu.org Port 80</ADDRESS>
</BODY></HTML>
Connection closed by foreign host.
root@firststeps: ~#

Since connect-real-network forwards ports to the telnet, FTP and HTTP ports of the simulated machine, it is possible to telnet into the simulated machine, or access its web server from a web browser. To access the web server, enter the address http://localhost:4080 in a web browser on your real machine.

Figure 2. Montavista Linux HTTP server front page

In an new shell on your computer, you can also try to telnet into the simulated machine:

joe@computer: ~$ telnet -l root localhost 4023
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.


Welcome to MontaVista Linux 2.1, Professional Edition



BusyBox v0.60.2 (2002.08.28-16:54+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

# exit
Connection closed by foreign host.
joe@computer: ~$

You can read more about real network in chapter 10.

Previous - Up - Next