Sie sind auf Seite 1von 9

ConnectingGNS3totheinternetisjustanothersteptobringyouremulatednetworklab

closertorealgear.Therearemanywaystodothisbasedonwhatinternetconnectionyou
areusing.IfyoujusthaveanADSLmodem/routerconnectedtotheethernetportofyour
physicalmachinehavingaprivateIPaddressitisverysimpletogetyourlabtotheinternet.
ButifyouareusingaWiFiconnection/Datacard/adevicethatrequiresyoutoassigna
publicIPonthephysicalinterfacegettingyourlabtoaccesstheinternetrequiresafewmore
commandsinLinuxorafewmoreclicksinWindows.Apartfrommakingconfiguration
changestoyouroperatingsystemNAThastobeconfiguredontheemulatedrouterthat
connectstotheinternet.

ConnectingGNS3totheInternetScenario1
(PhysicalinterfacehasaprivateIPaddress)
Inthisscenarioyourphysicalmachineisconnectedtoamodem/routerusingaRJ45cable
andtheethernetportofyourcomputerhasaprivateIPaddressassignedmanuallyorvia
DHCP.
ThisisthesimplestmeansofconnectingGNS3totheinternet.OpenGNS3asan
administrator(Windows)byrightclickingitandselectingRunasadministratororasaroot
user(Linux)byusingthesudocommand.
jesin@ubuntu:~$ sudo gns3
Placeacloudnodeinyourtopology,rightclickselectconfigureandfromthedropdownlist
undertheethernettabselectLocalAreaConnectiononWindowsoreth0onLinuxand
clickOK.

Selectandaddthenetworkinterfaceofthe
physicalcomputer

Connectaroutertothiscloudusinganethernetlink,opentheconsoleoftherouterand
navigatetotheinterfacewhichisconnectedtothecloudnode.
R1>enable
R1#configure terminal
R1(config)#interface FastEthernet 0/0
Nowifthemodem/routerconnectedtothephysicalcomputerhasabuiltinDHCPserveruse
thefollowingcommandtoconfiguretherouterporttorecieveIPaddressviaDHCP.
R1(config-if)#ip address dhcp
elseassigntheastaticIPaddress
R1(config-if)#ip address 192.168.1.3 255.255.255.0
Bringthisinterfaceup
R1(config-if)#no shutdown
IfyouhadchoosetheDHCPwayofassigningIPaddressyouwillseethefollowingline

*Mar 1 01:24:31.751: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 a


IfyouassignedtheIPaddressmanuallyadefaultroutehastobeaddedtoensureinternet
connectivity.

R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.1

R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.1


TrypingingapublicIPaddresssuchas8.8.8.8,ifyoupingadomainnamesuchas
websistent.comyoullreceiveanUnrecognizedhostoraddress,orprotocolnotrunning
erroraswehavenotyetconfiguredDNS.Thatsall,nowscrolldowntothelastpartof
configuringNATandDNSservers.

ConnectingGNS3totheInternetScenario2
(WiFiorphysicalinterfacehasapublicIPaddress)
YoursetupcomesunderthisscenarioifyourphysicalmachineusesWiFitocommunicate
withyourmodemoryouareusingamodemwhichassignsapublicIPaddressdirectlytothe
physicalinterfaceofyourcomputer.
Inthiscasedirectlyconnectingtheroutertothephysicalcomputersethernetportshownin
thepreviousstepdoesnotmakeitworkbecausetheGNS3routerwillalsobeneedinga
publicIPaddresstocommunicate.IncasethephysicalcomputerisusingWiFitheproblem
willarisebecauseasecuredWLANusesWPA/WEPhencetheGNS3routerwillfailto
communicatewithyourWiFirouteritself.

Linux
InLinuxwewillbecreatingaloopback(TAP)interface,connecttheGNS3routertoitand
configureNATusingIPTablestoforwardpacketsfromtheloopbackinterfacetothephysical
networkportofthecomputer.Apackageisneededwhichcanbeinstalledusingthe
followingcommands.
InRHEL/CentOSvariants:
yum install uml-utilities
InDebian/Ubuntuvariants:
apt-get install uml-utilities
Oncethepackageisinstalledrunthefollowingcommandsasroottocreatealoopback
interfaceandassignanIPaddresstoit.
tunctl -t tap0
ifconfig tap0 10.200.200.1 netmask 255.255.255.252 up

ifconfig tap0 10.200.200.1 netmask 255.255.255.252 up


YoucanassignanyIPaddresstothetap0interfacejustmakesureitdoesnotoverlapwith
anyotherinterface.Ihaveusedaprefixlengthof/30becauseonlytwoIPaddresseswillbe
requiredonethatweassignedheretothetap0interfaceandanotherwhichwewillassign
totheGNS3router.EnterthefollowingcommandstocreateIPTablesfirewallrulesto
performNATandforwardthepacketsfromtheinterfacespecifiedafterithroughthe
interfacespecifiedaftero.
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
iptables -A FORWARD -i tap0 -j ACCEPT
Replacewlan0withtheinterfaceonthephysicalcomputerwhichconnectstotheinternetit
couldbeppp0orbr0orsomethingelse.EnsuretheIPTablesrulespersist,ifyouwantto
ensurethetap0interfacepersistsarebootcreateacronjobtoadditwhenLinuxstartsup.
crontab -e
addthefollowinglines
@reboot /usr/sbin/tunctl -t tap0 && /sbin/ifconfig
IPv4forwardinghastobeenabledatkernellevelsousethefollowingcommand.
echo 1 > /proc/sys/net/ipv4/ip_forward
Ifyouexecutethecommandaboveasanonrootusedyoullgetanerrorbash:
/proc/sys/net/ipv4/ip_forward:Permissiondeniedinthatcaseusethefollowingcommand.
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
OpenGNS3asrootuserbyusingthesudocommand.Addacloudnodetothetopology,
rightclickitselectconfigurenavigatetotheNIOTAPtabandinthetextboxentertap0,click
addandclickOK.

Entertap0undertheNIOTAPtabandclick
add

Thecloudisnowready,addaroutertothetopologyandconnectittothecloud,poweron
therouterandconfigureitsinterfacewithanIPaddressinthesamerangeastheIP
assignedtothetap0interface.
R1>enable
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#interface FastEthernet 1/0
R1(config-if)#ip address 10.200.200.2 255.255.255.252
R1(config-if)#no shutdown
Addadefaultroutesothattherouterknowswheretoforwardtheinternettraffic.
R1(config)#ip route 0.0.0.0 0.0.0.0 10.200.200.1
TrypingingapublicIPaddressandyoushouldgetareply.Pingingadomainnamewillfail
asDNSisnotyetconfigured.

Windows
MovingontoWindowstodothesamething,thefirsttaskistocreatealoopbackinterface.
Openrunandtypehdwwiz.exetoopentheAddNewHardwareWizard

OpentheAddHardwarewizardfromrun

ClicknextintheAddHardwareWizard

Selecttoaddyourhardwaremanuallyandclicknext.

ChoosetheoptiontoInstallthehardware
manuallyfromalist

UndercommonhardwaretypesselectNetworkAdapterandclicknext.

ChooseNetworkAdaptersunderCommon

hardwaretypes

UnderManufacturerselectMicrosoftandunderNetworkAdapterchooseMicrosoft
LoopbackAdapterandclicknext.

SelectMicrosoftundermanufacturerand
MicrosoftLoopbackAdapterundernetwork
adapter

Anewloopbackinterfacehasbeencreated

AnIPaddresshastobeassignedtotheloopbackinterfacenow.GotoStart>Control
Panel>NetworkandInternet>NetworkSharingCenter,fromtheleftpaneclickNetwork
Connections,rightclickyourinternetconnection(itcanbeaWLANconnection,dialup
connection,PPPoEconnectionetc)selectpropertiesandgotothesharingtab.

EnableInternetConnection
Sharingontheinterfacewhich
connectstotheinternet

Selectoptionsasshowninthescreenshotabove,theLocalAreaConnection3Ihave
selectedisthenameofthenewlycreatedloopbackinterfacewhichshouldbereplacedby
thenamedisplayedinyoursystem.ClickOKtwice,atthispointyourloopbackinterfacewill
beassignedanIPaddress(192.168.37.1/24),itisyourchoicetouseitorchangeit.Inthis
articleIwillbechangingit.RightclicktheLoopbackconnection,selectproperties,select
InternetProtocolVersion4,clickpropertiesandenteranIPaddress,subnetmask.

AssignanIPaddressandsubnetmask
totheloopbackinterface

YoumayhavetorestartyourcomputerforthisloopbackinterfacetoshowupinGNS3.Open
GNS3byrightclickingitandchoosingRunasadministrator,insertacloudnodeintothe
topology,rightclickselectconfigure

Addtheloopbackadapterfromtheconfigure
dialogboxofthecloudnode

Addaroutertothetopology,connectoneofitsethernetportstothecloudandstartthe
router.ItistimetoassignanIPaddresstothisinterface.
R1>enable
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#interface FastEthernet 1/0
R1(config-if)#ip address 10.255.255.2 255.255.255.252
R1(config-if)#no shutdown
Addadefaultrouteonthisrouter.
R1(config)#ip route 0.0.0.0 0.0.0.0 10.255.255.1
TrypingingapublicIPaddressandyoushouldgetareply.Pingingdomainnameswillresult
inanerrorasDNShasnotyetbeenconfigured.

ConfiguringDNSonCiscoIOS
NowthatroutersinGNS3areabletoconnecttotheinternetwontitbeniceifyoucoulduse
friendlydomainnamesinsteadofIPaddresses.DNScanbeconfigureintwoeasy
commandsgivenbelow.
R1(config)#ip domain-lookup
R1(config)#ip name-server 8.8.8.8 8.8.4.4

Das könnte Ihnen auch gefallen