<?xml version="1.0" encoding="UTF-8" ?>
			<rss version="2.0">
				<channel>
					
								<generator><![CDATA[Doteasy Hosted Blogs - Powered By Doteasy.com]]></generator>
							
								<description><![CDATA[Kepler&#39;s Blog on e5link.com

&nbsp;

Certified Cisco Instructor since 1999

&nbsp;]]></description>
							
								<link><![CDATA[http://apps.e5link.com/Blog/]]></link>
							
								<title><![CDATA[Kepler's Blog on eFlying Link]]></title>
							
								<pubDate>Sun, 05 Apr 2026 06:15:23 GMT</pubDate>
							
								<lastBuildDate>Sun, 05 Apr 2026 06:15:23 GMT</lastBuildDate>
							
								<ttl><![CDATA[60]]></ttl>
							
						<item>
							
											<description><![CDATA[<p>Want to discuss this topics long long time ago, that is the subnet calculation. As I find that many students are not really know how to find the subnet address of an given IP for non-byte boundary subnet mask such as /27, /19 etc.</p>

<p>That&#39;s understandable, as all the formal training (like CCNA) teaches how to do the calculation in binary, but who would like to deal with those 0&#39;s and 1&#39;s? Probably, nobody. So when I teach CCNA, I will teach them how to use decimal for the calculation. Especially, when you take the CCNA examination, no calculator (not to mention your mobile phone) is allowed, you need to do it by hand. Thus, you really need to learn a more effective way for those calculation.</p>

<p>&nbsp;</p>

<p><a href="https://youtu.be/UUMNwnBqJvI"><img alt="subnet26_ppt" height="378" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/9ee60c581c7ac2a41c47c52151daed34.jpg" target="_new" width="504" /></a></p>

<p>&nbsp;</p>

<p>I&#39;ve just created two youtube videos for the <a href="https://youtu.be/UUMNwnBqJvI">subnet calculation using decimal in Part 1 </a>and <a href="https://youtu.be/vMslMHwYBPM">Part 2</a>. Part 1 will focus the basic technique for Class C network number and how to tackle one of the common question in the examination. While Part 2 discusses more common questions and the case for Class B and Class A network number.</p>

<p>In fact, its just like cutting a cake. E.g. following illustrate the case of /27 subnets</p>

<p><img alt="subnet_27" height="356" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/6b9ced0cfce7259fc93239a165034b4a.jpg" target="_new" width="389" /><br />
<br />
&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>]]></description>
										
											<guid><![CDATA[http://apps.e5link.com/Blog/?e=99089&d=01/20/2022&s=Calculating%20subnet%2C%20broadcast%20address%20using%20decimal]]></guid>
										
											<link><![CDATA[http://apps.e5link.com/Blog/?e=99089&d=01/20/2022&s=Calculating%20subnet%2C%20broadcast%20address%20using%20decimal]]></link>
										
											<title><![CDATA[Calculating subnet, broadcast address using decimal]]></title>
										
											<pubDate>Thu, 20 Jan 2022 09:57:09 GMT</pubDate>
										
						</item>
					
						<item>
							
											<description><![CDATA[<p>In the recent Cisco training courses, the whole certification track has been revised. &nbsp;For the CCNA course, personally I really think that it&#39;s no longer an introductory course (even for the previous version). As new topics that originally from other specialized training has been added into the course. Somewhat like SDN, wireless controller, those are no longer basic network technologies.</p>

<p>Of course, the key topics are still routing and switch. Yet, EIGRP has been taken out. The new version only discuss OSPF. As there are so many topics to discuss, obvious the course pace will be quite fast. If you are completely new to network, it&#39;s not easy to catch up.</p>

<p>What I recommend (that&#39;s I already recommend 10 years ago!), before you attend the class, you should at least get some basic knowledge about switch and router, how they works in the network. Recently, I&#39;ve created a youtube video <a href="https://youtu.be/mIX22JHN628">CCNA Pre-class</a> to help you getting the fundamental concepts. Even if you have been working in networking field for a short period of time, this video can help you clear all the basic concepts.</p>

<p>Besides, if you are new to Cisco equipment, try download some simulator (something like <a href="https://www.gns3.com/">GNS3</a>) and practice the basic command line interface before you attend the class.</p>

<p><br />
<a href="https://youtu.be/mIX22JHN628"><img alt="netfld" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/3d075a15d285d9423f42228a68e2f422.jpg" target="_new" /></a><br />
&nbsp;</p>]]></description>
										
											<guid><![CDATA[http://apps.e5link.com/Blog/?e=99082&d=01/12/2022&s=How%20the%20network%20works%20%2D%20CCNA%20pre%2Dclass%20training]]></guid>
										
											<link><![CDATA[http://apps.e5link.com/Blog/?e=99082&d=01/12/2022&s=How%20the%20network%20works%20%2D%20CCNA%20pre%2Dclass%20training]]></link>
										
											<title><![CDATA[How the network works - CCNA pre-class training]]></title>
										
											<pubDate>Wed, 12 Jan 2022 10:22:08 GMT</pubDate>
										
						</item>
					
						<item>
							
											<description><![CDATA[<p>Have been busy for planning to move back to Canada, until now have time to write some blog. This time I am not going to discuss technical topics, instead want to share a bad experience on COVID test in Canada BC.</p>

<p>As I arrived Canada before 5 July, so I needed to go thru&#39; the 3 days hotel quarantine (I am not going to complaint about how expense of the hotel fee, as its already being complained by so many people) and 14 days quarantine period. What I want to share is about the experience of day 8 home kit test. I believe my case is not alone, most likely some other people are also suffering.</p>

<p>What happen is that, I and my wife have completed the home test (virtually monitored by someone over the Web online which is already frustrating. As first time, I waited for over an hour with nobody dial in, then I need to rebook the virtual appointment) on the day 8 which is on Monday. Then Fedex picked up both kits on Tuesday (day 9) and delivered to the lab on Wed morning (day 10) by using the Fedex tracking system.</p>

<p>On Thursday morning, I received the result and report, but my wife didn&#39;t. As the official website of the lab (the company call LifeLabs) mentioned that result should be notified by Email within 48 to 72 hours after picked up. So after waiting for one more day and still not getting the result, we called the LifeLabs on Friday. As usual, you need to wait for at least an hour until somebody answer your call. What the agent said, as its over 72 hours, she will add a remark to escalate the case to LifeLabs and urge them to examine the kit ASAP, and ask us to wait for the result.</p>

<p>On Sat (day 13), there was nothing coming up, we called again. After waiting another hour, an agent pickup the call and what she said is &quot;in progress&quot;, should be completed in couple of hours, probably should have the result later in the day or worse case tomorrow morning.</p>

<p>Once again, just got another disappointment. Nothing coming up on Sun morning. As its the last day of quarantine, the LifeLabs should give my wife result, so that she can end the quarantine period. We called again, the agent pickup the phone after more than an hour, what she said &quot;I got the result&quot;, but my wife didn&#39;t get an Email notification, so she immediately send an Email to my wife. We open the Email and immediately check the result which is negative. So happy and dropped the call.</p>

<p>Wait a minute, its not the end of the story. I checked the report in more detail. Oh Shit! She send us the day 1 test result (which we already have it long long time ago). So waste another hour to call, another agent picked up, he said that he will send an Email to Lifelabs and push them to tell him the status, then he will call back us.</p>

<p>&quot;He promise to call back&quot;, will you trust? No result, no call back, nothing coming up even on Monday morning (day 15). Once again, frustrated. In fact, yesterday I also called the ArriveCan to ask what happen if the day 8 result never comes back, can my wife go out after 14 days quarantine period. You know what? He said, he can&#39;t answer this question, he gave me another number to call and disconnected. I checked the number, you know what number is it? I believe some of clever reader already got the answer. Yes, its the phone number of LifeLabs.</p>

<p>Then we checked the website, what it says unless you get a negative result of day 8 test, you need to stay 14 more days. Its really ridiculous and unreasonable. My wife have completed what should be done officially, its the fault of the Lifelabs who didn&#39;t perform their task in time, but let us suffer.</p>

<p>I have a preparation that they may lose the testing kit (it seems that it&#39;s possible), so I re-order the testing kit for my wife on day 15. Surprisingly, on day 16 morning, my wife get the result from the Email, really thank God. Eventually we can go out. Though its late for 1 day, I believe we are not the worse case!</p>

<p><img alt="view" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/9d5a48822b24b6c29e290799f79cbb11.jpg" target="_new" /><br />
&nbsp;</p>

<p>You may think that its the end of the story. Actually its not, its just the beginning, what? The purpose of writing this blog is not only complaining about the LifeLabs and also the government doesn&#39;t perform a monitoring job. The most important is that I have the <strong>RIGHT TO COMPLAINT</strong>.</p>

<p>Yes, you may wonder RIGHT TO COMPLAINT should be a nature thing for everyone. I tell you that as a person who just left Hong Kong and return to Canada, I have the responsibility to tell the world what&#39;s happening in Hong Kong. <strong><span style="font-size:14px;">People in Hong Kong are losing the right to complaint, and even lost the right to tell the truth (even worse right to KNOW the truth).</span></strong></p>

<p>Since the National Security bill passed last year, any words that you complaint the Government, the police, not to mention the one who really govern the Hong Kong Government, you may have the risk of offending the National Security bill. Without evening judged by the court, you may already be detained. (Because of this, I&#39;ve removed 2 of my previous blog entries that has the title &quot;Shame on Hong Kong Government and Hong Kong Police&quot;).</p>

<p>Freedom of speech is no longer valid in Hong Kong, you can&#39;t even say&nbsp; &quot;<a href="https://en.wikipedia.org/wiki/Glory_to_Hong_Kong">Glory to Hong Kong</a>&quot; which will be treated as against the CCP, against the country. Or something like &quot;Cheer up Hong Kong&quot; (Chinese direct translation is somewhat like &quot;Add Oil to Hong Kong&quot;) is also prohibited. Not sure is it because China is so fragile that just by saying something can risk the security of the country.</p>

<p>Finally, following Chinese (to be more specific should be Cantonese) poem vent my feeling about leaving Hong Kong:</p>

<p><span style="font-size:16px;">離别香江走遠方，<br />
親友送别祝安康;<br />
雖有難捨意離去，<br />
他日重逢見榮光。</span></p>

<p>To translate in English:</p>

<p><span style="font-family:courier new,courier,monospace;"><span style="font-size:16px;">Leaving Hong Kong to a far place,<br />
Friends and relatives farewell with blessing,<br />
Feeling hard, yet still decide to leave,<br />
Glory comes when we meet again.</span></span></p>

<p>Yes, glory to my Lord and glory to Hong Kong, <a href="https://www.youtube.com/watch?v=WbBU1AZS8HA">revolution of our times</a>. May the God bless Hong Kong and the real HongKongers.</p>

<p>&nbsp;</p>]]></description>
										
											<guid><![CDATA[http://apps.e5link.com/Blog/?e=98715&d=07/19/2021&s=Day%208%20quarantine%20test%20result%20not%20received]]></guid>
										
											<link><![CDATA[http://apps.e5link.com/Blog/?e=98715&d=07/19/2021&s=Day%208%20quarantine%20test%20result%20not%20received]]></link>
										
											<title><![CDATA[Day 8 quarantine test result not received]]></title>
										
											<pubDate>Mon, 19 Jul 2021 09:39:28 GMT</pubDate>
										
						</item>
					
						<item>
							
											<description><![CDATA[<p>Here I want to introduce a python script that allow you to remotely access your GNS3 projects by a SSH client (such as putty), only port 22 is required to be externally accessible.</p>

<p>Without the GNS3 client installed in your PC, it&#39;s difficult to start or stop projects remotely unless you can use remote desktop to login to the hosted Windows machine. Moreover, without knowing the console port number of the devices (unfortunately it changes randomly every time when you load the project), you cannot get the console access of the devices.</p>

<p>Think about, if you just setup some labs and want to share with others, but not willing to give the Windows access to the others, currently GNS doesn&#39;t provide a ready to use solution. So here, I create a python script which makes use of the REST API provided by the GNS3 to allow the remote access of the projects that have been created in the GNS.</p>

<p>Before I discuss how to setup the script, just want to show some of the screens provided by the script. It&#39;s very simple to use, just use putty and SSH to the GNS3 VM machine, after login, you will get a intuitive menu. It allows you to load and start different projects and then access the console of different devices of the project:</p>

<p><img alt="main" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/df54b99226d3b3b8b7037c2e75e5e921.jpg" target="_new" /></p>

<p>In the main menu, you can start, stop and check the status of the GNS. However, to remotely start the GNS (option 1), you need to setup two more tools: the rmcd provided in the<a href="http://iptools.sourceforge.net/"> iptools</a> package and the <a href="https://www.autohotkey.com/">AutoHotkey</a>. As the setup is a bit complicated, I am not going to discuss it here, drop a comment below if anyone interest in it. Otherwise, don&#39;t use this option.</p>

<p>For option 2, it will display the available projects, just select the project, load and start it. Here are some projects example that I used to deliver the CCNP ROUTE course:</p>

<p><img alt="projs" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/23467c95ec80eb78480d5caa33ff5a7c.jpg" target="_new" /></p>

<p>After the project started, press ENTER to go back to main menu. Under option 3 of the main menu, you can access the consoles of different devices of the project (following screen shows the devices in the selected project C1):</p>

<p><img alt="devices" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/b5da4fefd32420f5efe0da4bbdc659fb.jpg" target="_new" /></p>

<p>You can use Ctrl-] and quit to exit the console.</p>

<p>Option 4 of the main menu allows you to power cycle the devices. For option 5 and 6, they are for snapshot management. However, due to the issues of the GNS itself, these options doesn&#39;t function very well.</p>

<p>Now, I am going to discuss how to setup the script. As the script is written in python, so you can just execute it under any Linux machine that have the python installed. Of course, the most convenient way is to run the script under the GNS3 VM itself. Followings highly the major steps:</p>

<p>1. Configure and verify some GNS3 settings.</p>

<p>2. Download the script and put it under any path. Recommend to put it under /home/gns3.</p>

<p>3. Create a Linux user account and configure the script as the login script of the new account.</p>

<p>&nbsp;</p>

<p><span style="color:#006400;"><span style="font-size:14px;"><strong>Configure and verify some GNS3 settings</strong></span></span></p>

<p>In fact, the only setting that need to be changed is to uncheck <strong>&quot;Protect Server with password (recommended)</strong>&quot; setting. You can find it under <strong>Edit &gt; Preferences....&gt; Server screen</strong> (as below).</p>

<p>Well, wait a minute... I know you may concern the security issue for uncheck this option. If you want to enable it, you may need to change the python script to handle the HTTP authentication which is not currently implemented. As in my environment, GNS3 is only used for testing or lab purpose, so should be under a restricted network. I believe it&#39;s not supposed to be used in production environment, if so, you should handle the security issue by yourself.</p>

<p><img alt="srv_pref" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/d08b184ad1646bca3a914021990a458c.jpg" target="_new" /><br />
&nbsp;</p>

<p>Another setting that you may want to check is under <strong>General &gt; General</strong> tab, just verify your project path. You should put all the projects under the &quot;My projects&quot; path, as the python script will locate the projects under there.</p>

<p><br />
<img alt="prj_path" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/c304daab335a86d35f8f66f3ae42bb15.jpg" target="_new" /><br />
&nbsp;</p>

<p><span style="color:#006400;"><span style="font-size:14px;"><strong>Download the script and put it under any desirable path</strong></span></span></p>

<p>You can find the script under <a href="https://github.com/keplerlam/gns3remote/blob/main/gns_admin.py">https://github.com/keplerlam/gns3remote/blob/main/gns_admin.py</a></p>

<p>Download the script, edit the script, near the end of the script, change the following:</p>

<p><span style="font-family:courier new,courier,monospace;">GNS_HOST=&quot;<strong>192.168.1.1</strong>&quot;&nbsp;&nbsp; # Change the IP address to the machine host the GNS client</span></p>

<p>Then put it under the GNS VM. You can use the GNS VM console, start a command line (as shown below):</p>

<p><img alt="shell" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/1cdaef9445e7dc33615539558aa2d92d.jpg" target="_new" /><br />
&nbsp;</p>

<p>Under the Linux command prompt, you can use ftp or scp to copy the script from the file server (of course you need a FTP or SFTP server and download the script under the server first).</p>

<p>If you don&#39;t have the file server, maybe you can just copy and paste the script using the editor. It seems the only available editor under the GNS VM is nano. So under the Linux prompt:</p>

<p><span style="font-family:courier new,courier,monospace;">gns3@gns3-iouvm:~$ <strong>nano gns_admin.py</strong></span></p>

<p>Then paste the script content and save the file.</p>

<p>After that, you need to change the execution mode of the script:</p>

<p><span style="font-family:courier new,courier,monospace;">gns3@gns3-iouvm:~$ <strong>chmod a+x gns_admin.py</strong></span></p>

<p>&nbsp;</p>

<p><span style="color:#006400;"><span style="font-size:14px;"><strong>Create a Linux user account and configure the script as the login script of the new account</strong></span></span></p>

<p>Actually, you can test the script right now:</p>

<p>gns3@gns3-iouvm:~$ ./<strong>gns_admin.py</strong></p>

<p>But most likely, you want to use another Linux user account and automatically run the script once login. You can use the adduser command, below is an example for adding an user <strong>tester</strong>:</p>

<p><span style="font-family:courier new,courier,monospace;">gns3@gns3-iouvm:~$ <strong>sudo adduser tester</strong></span></p>

<p><span style="font-family:courier new,courier,monospace;">sudo: unable to resolve host gns3-iouvm</span></p>

<p><span style="font-family:courier new,courier,monospace;">Adding user `tester&#39; ...</span></p>

<p><span style="font-family:courier new,courier,monospace;">Adding new group `tester&#39; (1002) ...</span></p>

<p><span style="font-family:courier new,courier,monospace;">Adding new user `tester&#39; (1002) with group `tester&#39; ...</span></p>

<p><span style="font-family:courier new,courier,monospace;">Creating home directory `/home/tester&#39; ...</span></p>

<p><span style="font-family:courier new,courier,monospace;">Copying files from `/etc/skel&#39; ...</span></p>

<p><span style="font-family:courier new,courier,monospace;">Enter new UNIX password:</span></p>

<p><span style="font-family:courier new,courier,monospace;">Retype new UNIX password:</span></p>

<p><span style="font-family:courier new,courier,monospace;">passwd: password updated successfully</span></p>

<p><span style="font-family:courier new,courier,monospace;">Changing the user information for tester</span></p>

<p><span style="font-family:courier new,courier,monospace;">Enter the new value, or press ENTER for the default</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Full Name []: <strong>Tester</strong></span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Room Number []:</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Work Phone []:</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Home Phone []:</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Other []:</span></p>

<p><span style="font-family:courier new,courier,monospace;">Is the information correct? [Y/n] <strong>y</strong></span></p>

<p>The last step is to configure the script to be automatically run when login to the newly created user tester by following command :</p>

<p><span style="font-family:courier new,courier,monospace;">gns3@gns3-iouvm:~$ <strong>sudo chsh tester</strong></span></p>

<p><span style="font-family:courier new,courier,monospace;">sudo: unable to resolve host gns3-iouvm</span></p>

<p><span style="font-family:courier new,courier,monospace;">Changing the login shell for tester</span></p>

<p><span style="font-family:courier new,courier,monospace;">Enter the new value, or press ENTER for the default</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Login Shell [/bin/bash]: <strong>/home/gns3/gns_admin.py</strong></span></p>

<p><span style="font-family:arial,helvetica,sans-serif;">Now open a ssh session and login to the user tester to fire the script.</span></p>]]></description>
										
											<guid><![CDATA[http://apps.e5link.com/Blog/?e=98149&d=12/29/2020&s=GNS3%20remote%20access%20by%20putty%20using%20port%2022%20%28ssh%29%20only]]></guid>
										
											<link><![CDATA[http://apps.e5link.com/Blog/?e=98149&d=12/29/2020&s=GNS3%20remote%20access%20by%20putty%20using%20port%2022%20%28ssh%29%20only]]></link>
										
											<title><![CDATA[GNS3 remote access by putty using port 22 (ssh) only]]></title>
										
											<pubDate>Mon, 28 Dec 2020 04:35:42 GMT</pubDate>
										
						</item>
					
						<item>
							
											<description><![CDATA[<p>Just delivery the SIMOS class remotely, haven&#39;t been writing any blog entry for a long time, as its a very hard time in here. After almost half years of social campaign, its now still under the risk of coronavirus. Hopefully people in Hong Kong has the experience of SAS virus before, thus wearing mask everyday, and most likely it lower the chance of being infected.</p>

<p>Anyway, back to this bog entry which I want to compare the traditional DMVPN with the FlexVPN using the NHRP.&nbsp;</p>

<p>Although the functionsseems almost the same, both support the full mesh VPN tunnels. Both use static tunnel between the hub and all spokes sites, then establish dynamic tunnel between spokes sites on demand. The major different is the way how the spoke site learn the tunnel IP address of the other spoke site.</p>

<p>In the traditional DMVPN, the next hop address to the internal subnet of the other remote spoke site requires to be tunnel IP address of the remote spoke site.</p>

<p>E.g. in the following, the left spoke router f&zwnj;inds the destination network (192.168.13.024) reachable over the 10.1.1.3 next hop on its mGRE interface.</p>

<p><img alt="DMVPN" height="244" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/c0bbd1dc889e623ad97f1a1452a22e75.jpg" target="_new" width="523" /><br />
&nbsp;</p>

<p>In order to satisfy this requirement, you need to be care about the routing configuration.</p>

<p>For OSPF, you need to use the OSPF broadcast mode under the mGRE interface of all the spoke sites. If you use the default point-to-multipoint mode, the learnt next hop will become the hub&#39;s IP and simply won&#39;t work. Please refer to my other blog entry on <a href="http://apps.e5link.com/Blog/?e=88046&amp;d=04/12/2014&amp;s=OSPF%20mode%20in%20DMVPN%20configuration">OSPF mode in DMVPN configuration</a>.</p>

<p>Similarly, for EIGRP, you need to disable the &quot;next-hop-self&quot;&nbsp; in the hub site&#39;s mGRE interface.</p>

<p>For the FlexVPN, you don&#39;t need to rely on the routing protocol to advertise the correct next hop. Instead, the hub site can advertise a default route to all spokes using the IKEv2 mode configure. So that, all spoke site will have a default route pointing to hub site.</p>

<p>Then what happen for spoke-to-spoke site traffic? Initially, the spoke will send the packet to the hub using the default route. But then the hub finds that the traffic can directly reach the other spoke using the remote spoke&#39;s tunnel IP, the hub will send a NHRP redirect (somewhat like the ICMP redirect) to the original spoke site, so that the original spoke will response a HNRP request to resolve the physical IP address of the remote site in order to establish the dynamic tunnel.</p>

<p>Following diagram illustrate the process:</p>

<p><img alt="FlexVPNnhrp" height="312" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/182cf576199c765a42c6ebedae0ab296.jpg" target="_new" width="529" /><br />
&nbsp;</p>

<p>Wish the above explains. Finally, may the God bless the the world to control the Wuhan virus.</p>]]></description>
										
											<guid><![CDATA[http://apps.e5link.com/Blog/?e=97357&d=03/02/2020&s=DMVPN%20vs%20FlexVPN%20with%20NHRP]]></guid>
										
											<link><![CDATA[http://apps.e5link.com/Blog/?e=97357&d=03/02/2020&s=DMVPN%20vs%20FlexVPN%20with%20NHRP]]></link>
										
											<title><![CDATA[DMVPN vs FlexVPN with NHRP]]></title>
										
											<pubDate>Sun, 01 Mar 2020 06:13:19 GMT</pubDate>
										
						</item>
					
						<item>
							
											<description><![CDATA[<p>To complete the discussion of the whole demostration. This last part disccus another supporting Python script <strong>nxapi_utils.py</strong> come from Cisco, it provides the <strong>ExecuteiAPICommand</strong> function call to connect to the Nexus box and execute the command. It just return the XML as &quot;text&quot;, then the text can be passed into <strong>minidom.parseString</strong> which parses the fields and arrange the information into a python XML class (with hierarchy).</p>

<p>To get back the value of a particular field, there are 2 methods:</p>

<p>1. Use the <strong>GetNodeDataDom</strong> by passing the XML and the field name as the parameters.</p>

<p>2. or use the XML class method <strong>getElementsByTagName</strong></p>

<p>Here is the script:</p>

<p><span style="font-family:courier new,courier,monospace;">#!/usr/bin/env python<br />
#<br />
# tested with build n9000-dk9.6.1.2.I1.1.510.bin<br />
#<br />
# Copyright (C) 2013 Cisco Systems Inc.<br />
#<br />
# Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);<br />
# you may not use this file except in compliance with the License.<br />
# You may obtain a copy of the License at<br />
#<br />
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; http://www.apache.org/licenses/LICENSE-2.0<br />
#<br />
# Unless required by applicable law or agreed to in writing, software<br />
# distributed under the License is distributed on an &quot;AS IS&quot; BASIS,<br />
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br />
# See the License for the specific language governing permissions and<br />
# limitations under the License.</span></p>

<p>&nbsp;</p>

<p><span style="font-family:courier new,courier,monospace;">import requests </span></p>

<p><span style="font-family:courier new,courier,monospace;">def GetiAPICookie(url, username, password):<br />
&nbsp;&nbsp;&nbsp; xml_string=&quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;ISO-8859-1\&quot;?&gt; \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ins_api&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;version&gt;0.1&lt;/version&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;type&gt;cli_show&lt;/type&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;chunk&gt;0&lt;/chunk&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;sid&gt;session1&lt;/sid&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input&gt;show clock&lt;/input&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;output_format&gt;xml&lt;/output_format&gt;\<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/ins_api&gt;&quot;<br />
&nbsp;&nbsp;&nbsp; try:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r = requests.post(url, data=xml_string, auth=(username, password))<br />
&nbsp;&nbsp;&nbsp; except requests.exceptions.ConnectionError as e:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Connection Error&quot;<br />
&nbsp;&nbsp;&nbsp; else:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return r.headers[&#39;Set-Cookie&#39;]</span></p>

<p><span style="font-family:courier new,courier,monospace;">def ExecuteiAPICommand(url, cookie, username, password, cmd_type, cmd):<br />
&nbsp;&nbsp;&nbsp; headers = {&#39;Cookie&#39;: cookie}</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp;&nbsp; xml_string=&quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;ISO-8859-1\&quot;?&gt; \<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;ins_api&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;version&gt;0.1&lt;/version&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;type&gt;&quot; + cmd_type + &quot;&lt;/type&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;chunk&gt;0&lt;/chunk&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;sid&gt;session1&lt;/sid&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;input&gt;&quot; + cmd + &quot;&lt;/input&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;output_format&gt;xml&lt;/output_format&gt; \<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;/ins_api&gt;&quot;</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp;&nbsp; try:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r = requests.post(url, headers=headers, data=xml_string, auth=(username, password))<br />
&nbsp;&nbsp;&nbsp; except requests.exceptions.ConnectionError as e:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Connection Error&quot;<br />
&nbsp;&nbsp;&nbsp; else:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return r.text</span></p>

<p><span style="font-family:courier new,courier,monospace;">def GetNodeDataDom(dom,nodename):<br />
&nbsp;&nbsp;&nbsp; # given a XML document, find an element by name and return it as a string<br />
&nbsp;&nbsp;&nbsp; try:<br />
&nbsp;&nbsp;&nbsp;&nbsp; node=dom.getElementsByTagName(nodename)<br />
&nbsp;&nbsp;&nbsp;&nbsp; return (NodeAsText(node))<br />
&nbsp;&nbsp;&nbsp; except IndexError:<br />
&nbsp;&nbsp;&nbsp;&nbsp; return &quot;__notFound__&quot;</span></p>

<p><span style="font-family:courier new,courier,monospace;">def NodeAsText(node):<br />
&nbsp;&nbsp;&nbsp; # convert a XML element to a string<br />
&nbsp;&nbsp;&nbsp; try:<br />
&nbsp;&nbsp;&nbsp;&nbsp; nodetext=node[0].firstChild.data.strip()<br />
&nbsp;&nbsp;&nbsp;&nbsp; return nodetext<br />
&nbsp;&nbsp;&nbsp; except IndexError:<br />
&nbsp;&nbsp;&nbsp;&nbsp; return &quot;__na__&quot;&nbsp; &nbsp;</span></p>

<p>The challenge of the script is the requirement to know the structure of the returned XML and the corresponding field names. This can be easily solved by using the NX-API Developer Sandbox.</p>

<p>&nbsp;</p>]]></description>
										
											<guid><![CDATA[http://apps.e5link.com/Blog/?e=96679&d=04/04/2019&s=Web%20Portal%20Example%20using%20NXAPI%20%28Part%204%29]]></guid>
										
											<link><![CDATA[http://apps.e5link.com/Blog/?e=96679&d=04/04/2019&s=Web%20Portal%20Example%20using%20NXAPI%20%28Part%204%29]]></link>
										
											<title><![CDATA[Web Portal Example using NXAPI (Part 4)]]></title>
										
											<pubDate>Wed, 03 Apr 2019 07:40:22 GMT</pubDate>
										
						</item>
					
						<item>
							
											<description><![CDATA[<p>Second part of <strong>intf.py</strong>:</p>

<p><span style="font-family:courier new,courier,monospace;">def show_interfaces(IP):</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp; form_str=&quot;&quot;&quot;<br />
&nbsp;&nbsp; &lt;form action=&quot;/cgi-bin/WebMgr.py&quot; method=&quot;post&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Switch IP Address List: &lt;input type=&quot;text&quot; name=&quot;IP&quot; value=%s&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;submit&quot; value=&quot;Show&quot;&gt;<br />
&nbsp;&nbsp; &lt;/form&gt;<br />
&nbsp;&nbsp; &quot;&quot;&quot;%IP_STRING</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp; if intf:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;&lt;h2&gt;Nexus Web Manager - Show Interface&lt;/h2&gt;&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print form_str<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;&quot;&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;table&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;tr&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;th&gt;Interface&lt;/th&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;th&gt;Description&lt;/th&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;th&gt;HW Addr&lt;/th&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;th&gt;Speed&lt;/th&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;th&gt;In Bytes&lt;/th&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;th&gt;Out Bytes&lt;/th&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;th&gt;Duplex&lt;/th&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/tr&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;tr&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp; else:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;&lt;h2&gt;Nexus Web Manager - Interface Management&lt;/h2&gt;&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print form_str<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;&quot;&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;table&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;tr&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;th&gt;Interface&lt;/th&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;th&gt;State&lt;/th&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;th&gt;Vlan&lt;/th&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;th&gt;Port Mode&lt;/th&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;th&gt;Show Interfaces&lt;/th&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/tr&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;tr&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp; url = &#39;http://&#39;+IP+&#39;/ins/&#39;<br />
&nbsp;&nbsp; cookie=GetiAPICookie(url, user, password)</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp; if intf:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dom = minidom.parseString(<strong><span style="color:#008000;">ExecuteiAPICommand</span></strong>(url, cookie, user, password, &quot;cli_show&quot;, &quot;show interface %s&quot;%intf))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfdict=getIntf(dom)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dom = minidom.parseString(ExecuteiAPICommand(url, cookie, user, password, &quot;cli_show_ascii&quot;, &quot;show run interface %s&quot;%intf))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; run_cfg = NodeAsText(dom.getElementsByTagName(&quot;body&quot;))<br />
&nbsp;&nbsp; else:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dom = minidom.parseString(ExecuteiAPICommand(url, cookie, user, password, &quot;cli_show&quot;, &quot;show interface&quot;))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfdict=getIntf(dom)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dom = minidom.parseString(ExecuteiAPICommand(url, cookie, user, password, &quot;cli_show&quot;, &quot;show interface switchport&quot;))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfdict=getSwitchport(dom,intfdict)</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp; for interface in intfdict.keys():<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;&lt;tr&gt;&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if intf:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(&quot;&lt;td&gt;%s &lt;/td&gt;&quot; % (interface))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(&quot;&lt;td&gt;%s &lt;/td&gt;&quot; % (intfdict[interface][&#39;desc&#39;]))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(&quot;&lt;td&gt;%s &lt;/td&gt;&quot; % (intfdict[interface][&#39;HWaddr&#39;]))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(&quot;&lt;td&gt;%s &lt;/td&gt;&quot; % (intfdict[interface][&#39;speed&#39;]))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(&quot;&lt;td&gt;%s &lt;/td&gt;&quot; % (intfdict[interface][&#39;inbytes&#39;]))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(&quot;&lt;td&gt;%s &lt;/td&gt;&quot; % (intfdict[interface][&#39;outbytes&#39;]))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(&quot;&lt;td&gt;%s &lt;/td&gt;&quot; % (intfdict[interface][&#39;duplex&#39;]))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(&quot;&lt;td&gt;%s &lt;/td&gt;&quot; % (interface))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(&quot;&lt;td&gt;%s &lt;/td&gt;&quot; % (intfdict[interface][&#39;state&#39;]))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(&quot;&lt;td&gt;%s &lt;/td&gt;&quot; % (intfdict[interface][&#39;access_vlan&#39;]))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(&quot;&lt;td&gt;%s &lt;/td&gt;&quot; % (intfdict[interface][&#39;mode&#39;]))</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; form_str=&quot;&quot;&quot;&lt;td&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;form action=&quot;/cgi-bin/<strong>Intf.py</strong>&quot; method=&quot;post&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;hidden&quot; name=&quot;Intf&quot; value=%s&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;hidden&quot; name=&quot;IP_LIST&quot; value=%s&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;hidden&quot; name=&quot;IP&quot; value=%s&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;submit&quot; value=&quot;Show&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/form&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/td&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;%(interface,IP_STRING,IP)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print form_str</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(&quot;&lt;/tr&gt;&quot;)</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp; return run_cfg</span></p>

<p><span style="font-family:courier new,courier,monospace;">#################<br />
#&nbsp; MAIN MODULE&nbsp; #<br />
#################</span></p>

<p><span style="font-family:courier new,courier,monospace;"># First things first: credentials. They should be parsed through sys.argv[] ideally ..<br />
form = cgi.FieldStorage()<br />
# Get data from fields<br />
IP = form.getvalue(&#39;IP&#39;)<br />
IP_STRING = form.getvalue(&#39;IP_LIST&#39;)<br />
intf = form.getvalue(&#39;Intf&#39;)<br />
user=&quot;admin&quot;<br />
password=&quot;dummy&quot;</span></p>

<p><span style="font-family:courier new,courier,monospace;">print(&quot;Content-type:text/html&quot;)<br />
print &quot;&quot;&quot;<br />
&lt;head&gt;<br />
&lt;style&gt;<br />
table {<br />
&nbsp; font-family: arial, sans-serif;<br />
&nbsp; border-collapse: collapse;<br />
&nbsp; width: 100%;<br />
}</span></p>

<p><span style="font-family:courier new,courier,monospace;">td, th {<br />
&nbsp; border: 1px solid #dddddd;<br />
&nbsp; text-align: left;<br />
&nbsp; padding: 8px;<br />
}</span></p>

<p><span style="font-family:courier new,courier,monospace;">&lt;/style&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&quot;&quot;&quot;</span></p>

<p><span style="font-family:courier new,courier,monospace;">run_cfg=show_interfaces(IP)</span></p>

<p><span style="font-family:courier new,courier,monospace;">if intf:<br />
&nbsp;&nbsp; print &quot;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&quot;<br />
&nbsp;&nbsp; print run_cfg.replace(&quot;\n&quot;,&quot;&lt;br /&gt;\n&quot;)<br />
&nbsp;&nbsp; print &quot;&lt;/table&gt;&quot;</span></p>

<p><span style="font-family:courier new,courier,monospace;">print &quot;&lt;/table&gt;&quot;</span></p>

<p>Thus actually, depending on whether the interface name is passed to <strong>Intf.py </strong>script or not, the flow is a bit different. When it gets the interface name, it calls &quot;show interface <em>interface_name</em>&quot; and &quot;show run interface <em>interface_name</em> &quot; to get the detail and display the information.</p>

<p><a href="http://apps.e5link.com/Blog/?e=96679&amp;d=04/03/2019&amp;s=Web%20Portal%20Example%20of%20NXAPI%20%28Part%204%29">Click here to continue</a> to the last part.</p>]]></description>
										
											<guid><![CDATA[http://apps.e5link.com/Blog/?e=96678&d=04/04/2019&s=Web%20Portal%20Example%20using%20NXAPI%20%28Part%203%29]]></guid>
										
											<link><![CDATA[http://apps.e5link.com/Blog/?e=96678&d=04/04/2019&s=Web%20Portal%20Example%20using%20NXAPI%20%28Part%203%29]]></link>
										
											<title><![CDATA[Web Portal Example using NXAPI (Part 3)]]></title>
										
											<pubDate>Wed, 03 Apr 2019 07:10:22 GMT</pubDate>
										
						</item>
					
						<item>
							
											<description><![CDATA[<p>Thus actually, depending on whether the interface name is passed to <strong>Intf.py </strong>script or not, the flow is a bit different. When it gets the interface name, it calls &quot;show interface <em>interface_name</em>&quot; and &quot;show run interface <em>interface_name</em> &quot; to get the detail and display the information.</p>

<p><img alt="intf2" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/f16667faba723ed33ef5578ba9d4bdb3.jpg" target="_new" /><br />
Here is the intf.py (as its too long, I will break it down into another blog):</p>

<p><span style="font-family:courier new,courier,monospace;">#!/usr/bin/env python<br />
#<br />
import cgi, cgitb</span></p>

<p><span style="font-family:courier new,courier,monospace;">from xml.dom import minidom<br />
from nxapi_utils import *</span></p>

<p><span style="font-family:courier new,courier,monospace;">def getIntf(xml):<br />
&nbsp;&nbsp;&nbsp; interfaces = xml.<span style="color:#008000;">getElementsByTagName</span>(&quot;ROW_interface&quot;)</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp;&nbsp; # build a dictionary of interface with key = interface<br />
&nbsp;&nbsp;&nbsp; # the format of the dictionary is as follows:<br />
&nbsp;&nbsp;&nbsp; intfdict = {}<br />
&nbsp;&nbsp;&nbsp; for interface in interfaces:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfname&nbsp; =&nbsp; NodeAsText(interface.getElementsByTagName(&quot;interface&quot;))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfstate =&nbsp; NodeAsText(interface.getElementsByTagName(&quot;state&quot;))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfdesc&nbsp; =&nbsp; NodeAsText(interface.getElementsByTagName(&quot;desc&quot;))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfhwaddr =&nbsp; NodeAsText(interface.getElementsByTagName(&quot;eth_hw_addr&quot;))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfspeed =&nbsp; NodeAsText(interface.getElementsByTagName(&quot;eth_speed&quot;))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfduplex =&nbsp; NodeAsText(interface.getElementsByTagName(&quot;eth_duplex&quot;))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfinbytes =&nbsp; NodeAsText(interface.getElementsByTagName(&quot;eth_inbytes&quot;))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfoutbytes =&nbsp; NodeAsText(interface.getElementsByTagName(&quot;eth_outbytes&quot;))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfdict[intfname]={&#39;state&#39;: intfstate, \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;desc&#39;: intfdesc, \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;access_vlan&#39;: &quot;N/A&quot;, \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;mode&#39;: &quot;L3&quot;, \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;speed&#39;: intfspeed, \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;duplex&#39;: intfduplex, \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;inbytes&#39;: intfinbytes, \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;outbytes&#39;: intfoutbytes, \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;HWaddr&#39;: intfhwaddr}<br />
&nbsp;&nbsp;&nbsp; return intfdict</span></p>

<p><span style="font-family:courier new,courier,monospace;">def getSwitchport(xml,intfdict):<br />
&nbsp;&nbsp;&nbsp; interfaces = xml.getElementsByTagName(&quot;ROW_interface&quot;)</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp;&nbsp; # build a dictionary of interface with key = interface<br />
&nbsp;&nbsp;&nbsp; # the format of the dictionary is as follows:<br />
&nbsp;&nbsp;&nbsp; # neighbors = {&#39;intf&#39;: {neighbor: &#39;foo&#39;, remoteport: &#39;x/y&#39;, model: &#39;bar&#39;}}&nbsp;&nbsp; &nbsp;<br />
&nbsp;&nbsp;&nbsp; for interface in interfaces:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfname&nbsp; =&nbsp; NodeAsText(interface.getElementsByTagName(&quot;interface&quot;))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfswitchport =&nbsp; NodeAsText(interface.getElementsByTagName(&quot;switchport&quot;))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfvlan&nbsp; =&nbsp; NodeAsText(interface.getElementsByTagName(&quot;access_vlan&quot;))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfmode =&nbsp; NodeAsText(interface.getElementsByTagName(&quot;oper_mode&quot;))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfdict[intfname][&#39;switchport&#39;]= intfswitchport<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfdict[intfname][&#39;access_vlan&#39;]= intfvlan<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intfdict[intfname][&#39;mode&#39;]= intfmode<br />
&nbsp;&nbsp;&nbsp; return intfdict</span></p>

<p><a href="http://apps.e5link.com/Blog/?e=96678&amp;d=04/03/2019&amp;s=Web%20Portal%20Example%20of%20NXAPI%20%28Part%203%29">Click here</a> to continue.</p>]]></description>
										
											<guid><![CDATA[http://apps.e5link.com/Blog/?e=96677&d=04/04/2019&s=Web%20Portal%20Example%20using%20NXAPI%20%28Part%202%29]]></guid>
										
											<link><![CDATA[http://apps.e5link.com/Blog/?e=96677&d=04/04/2019&s=Web%20Portal%20Example%20using%20NXAPI%20%28Part%202%29]]></link>
										
											<title><![CDATA[Web Portal Example using NXAPI (Part 2)]]></title>
										
											<pubDate>Wed, 03 Apr 2019 07:00:22 GMT</pubDate>
										
						</item>
					
						<item>
							
											<description><![CDATA[<p>In the NX-OS 9K training, I created a sample Webportal (by modifying some code from Github) to demonstrate the usage of the NX-API, here I want to share it.</p>

<p>The purpose of the Webportal is just allow an user enter a list of Nexus 9K Management IP, then it display some version information of them. The user can then select one of the 9K to view the interfaces&#39; information. Finally, can select the interface to view more detail.</p>

<p>The portal is quite straight forward. The first screen just a pure form to prompt user to enter the list of IP addresses. The form action will then call the python script <strong>WebMgr.py</strong> to process the form data (which is just the list of IP addresses).</p>

<p><img alt="indexhtml" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/336dec44c27f2a0008d13f057ffc76b4.jpg" target="_new" /></p>

<p>Here&#39;s the HTML:</p>

<p><span style="font-family:courier new,courier,monospace;">&lt;h2&gt;Nexus Web Manager&lt;/h2&gt;</span></p>

<p><span style="font-family:courier new,courier,monospace;">&lt;form action=&quot;/cgi-bin/<strong>WebMgr.py</strong>&quot; method=&quot;post&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; Switch IP Address List: &lt;input type=&quot;text&quot; name=&quot;IP&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;submit&quot; value=&quot;Show&quot;&gt;<br />
&lt;/form&gt;</span></p>

<p>The <strong>WebMgr.py</strong> python script get back the form data by &nbsp;<strong>form.getvalue(&#39;IP&#39;)</strong>, then connect to each of the IP address (username and password is <strong>HARD CODED </strong>inside the script, as an exercise, reader can modify the form to prompt user to enter them), use the Nexus API to do a &quot;show version&quot; and parse some of the information, then display them one by one in a table. Moreover, on the last table column, create a form button with action to call <strong>Intf.py</strong> by passing the corresponding Nexus 9K management IP to it.</p>

<p><img alt="Webmgr" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/cba5b8e3cb1fe29b558c1ae3b091186a.jpg" target="_new" /><br />
Here is the WebMgr.py:</p>

<p><span style="font-family:courier new,courier,monospace;">#!/usr/bin/env python<br />
#</span></p>

<p><span style="font-family:courier new,courier,monospace;">import cgi, cgitb</span></p>

<p><span style="font-family:courier new,courier,monospace;">from xml.dom import minidom<br />
from nxapi_utils import *</span></p>

<p><span style="font-family:courier new,courier,monospace;">#################<br />
#&nbsp; MAIN MODULE&nbsp; #<br />
#################</span></p>

<p><span style="font-family:courier new,courier,monospace;"># First things first: credentials. They should be parsed through sys.argv[] ideally ..<br />
form = cgi.FieldStorage()<br />
# Get data from fields<br />
IP_STRING = <span style="color:#008000;">form.getvalue</span>(&#39;IP&#39;)<br />
IP_LIST=IP_STRING.split(&quot;,&quot;)<br />
<span style="color:#FF0000;">user=&quot;admin&quot;<br />
password=&quot;dummy&quot;</span></span></p>

<p><span style="font-family:courier new,courier,monospace;">print(&quot;Content-type:text/html&quot;)</span></p>

<p><span style="font-family:courier new,courier,monospace;">print &quot;&quot;&quot;<br />
&lt;head&gt;<br />
&lt;style&gt;<br />
table {<br />
&nbsp; font-family: arial, sans-serif;<br />
&nbsp; border-collapse: collapse;<br />
&nbsp; width: 100%%;<br />
}</span></p>

<p><span style="font-family:courier new,courier,monospace;">td, th {<br />
&nbsp; border: 1px solid #dddddd;<br />
&nbsp; text-align: left;<br />
&nbsp; padding: 8px;<br />
}</span></p>

<p><span style="font-family:courier new,courier,monospace;">&lt;/style&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;</span></p>

<p><span style="font-family:courier new,courier,monospace;">&lt;h2&gt;Nexus Web Manager&lt;/h2&gt;</span></p>

<p><span style="font-family:courier new,courier,monospace;">&lt;form action=&quot;/cgi-bin/WebMgr.py&quot; method=&quot;post&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; Switch IP Address List: &lt;input type=&quot;text&quot; name=&quot;IP&quot; value=%s&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;submit&quot; value=&quot;Show&quot;&gt;<br />
&lt;/form&gt;<br />
&lt;table&gt;<br />
&nbsp; &lt;tr&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;th&gt;IP Address&lt;/th&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;th&gt;Hostname&lt;/th&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;th&gt;Version&lt;/th&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;th&gt;Show Interfaces&lt;/th&gt;<br />
&nbsp; &lt;/tr&gt;<br />
&nbsp; &lt;tr&gt;<br />
&quot;&quot;&quot;%format(IP_STRING)</span></p>

<p><span style="font-family:courier new,courier,monospace;">for IP in IP_LIST:<br />
&nbsp;&nbsp; url = &#39;http://&#39;+IP+&#39;/ins/&#39;<br />
&nbsp;&nbsp; cookie=GetiAPICookie(url, user, password)<br />
&nbsp;&nbsp; dom = minidom.parseString(<strong><span style="color:#00FF00;">ExecuteiAPICommand</span></strong>(url, cookie, user, password, &quot;cli_show&quot;, &quot;show version&quot;))<br />
&nbsp;&nbsp; host_name=GetNodeDataDom(dom,&quot;host_name&quot;)<br />
&nbsp;&nbsp; kickstart_ver_str=GetNodeDataDom(dom,&quot;kickstart_ver_str&quot;)</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp; print &quot;&lt;tr&gt;&quot;<br />
&nbsp;&nbsp; print(&quot;&lt;td&gt;%s &lt;/td&gt;&quot; % (IP))<br />
&nbsp;&nbsp; print(&quot;&lt;td&gt;%s &lt;/td&gt;&quot; % (host_name))<br />
&nbsp;&nbsp; print(&quot;&lt;td&gt;%s &lt;/td&gt;&quot; % (kickstart_ver_str))</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp; form_str=&quot;&quot;&quot;&lt;td&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;form action=&quot;/cgi-bin/<strong>Intf.py</strong>&quot; method=&quot;post&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;hidden&quot; name=&quot;IP_LIST&quot; value=%s&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;hidden&quot; name=&quot;IP&quot; value=%s&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;submit&quot; value=&quot;Manager&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;/form&gt;<br />
&nbsp;&nbsp; &lt;/td&gt;<br />
&nbsp;&nbsp; &quot;&quot;&quot;%(IP_STRING,IP)<br />
&nbsp;&nbsp; print form_str</span></p>

<p><span style="font-family:courier new,courier,monospace;">&nbsp;&nbsp; print(&quot;&lt;/tr&gt;&quot;)</span></p>

<p><span style="font-family:courier new,courier,monospace;">print &quot;&lt;/table&gt;&quot;</span></p>

<p>Inside the <strong>Intf.py </strong>script, just like the <strong>WebMgr.py</strong>, after getting back the form data (IP address), it uses the Nexus API to do a &quot;show interface&quot; and &quot;show interface switchport&quot; commands, to get information such as the status, VLAN about the interfaces. Again, just display as a table, and in the last column, also create a form button to display the detail of that interface. This time the form action calls back the <strong>Intf.py </strong>script with an additional information which is the interface name.</p>

<p><img alt="intf1" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/7f2ee151fd60442e0aedbec16b88a45a.jpg" target="_new" /><br />
&nbsp;</p>

<p>Please <a href="http://apps.e5link.com/Blog/?e=96677&amp;d=04/03/2019&amp;s=Web%20Portal%20Example%20of%20NXAPI%20%28Part%202%29">follow this link</a> to continue with next part.</p>]]></description>
										
											<guid><![CDATA[http://apps.e5link.com/Blog/?e=96676&d=04/04/2019&s=Web%20Portal%20Example%20using%20NXAPI%20%28Part%201%29]]></guid>
										
											<link><![CDATA[http://apps.e5link.com/Blog/?e=96676&d=04/04/2019&s=Web%20Portal%20Example%20using%20NXAPI%20%28Part%201%29]]></link>
										
											<title><![CDATA[Web Portal Example using NXAPI (Part 1)]]></title>
										
											<pubDate>Wed, 03 Apr 2019 05:47:23 GMT</pubDate>
										
						</item>
					
						<item>
							
											<description><![CDATA[<p>As in the previous blog, I want to compare and relate some Cisco network features with the AWS VPC. Here let&#39;s see the NAT feature in the AWS. Here I want to focus the concept and mechanism, please refer to the AWS document for the detail configuration.</p>

<p>If you are familiar with the NAT function in Cisco routers, there are basically 3 different types:</p>

<ol>
	<li>One-to-one (static NAT)</li>
	<li>Many-to-many (dynamic NAT)</li>
	<li>Many-to-one (PAT)</li>
</ol>

<p>Actually you can also have these 3 different kinds of NAT configuration in the VPC of AWS. To understand this, you need to understand the logical layer 3 architecture of the VPC and the address assignment in AWS.</p>

<p>In fact, the routing (logical) structure of the AWS is quite straightforward, after you create the VPC, you have a VPC Router that routes between the internal subnets (with private IP addresses) within the VPC. To go out to Internet, there is another Internet Router that logically connected with the VPC router which has a default route pointing to the Internet router. Like the following diagram:</p>

<p>&nbsp;</p>

<p><img alt="AWSnat" height="272" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/74afb4976ddef209d9267281eb1fffb9.jpg" target="_new" width="495" /><br />
&nbsp;</p>

<p>The Internet Router is also responsible for the NAT.</p>

<p>Obvious to access Internet your instance (VM) requires a global IP address. In AWS, there are 2 kinds of global IP address (the name is a bit confusing):</p>

<ol>
	<li>Elastic IP &ndash; AWS allocate five global Internet IP addresses for every AWS account by default, these IP addresses are owned by your account, so will not be shared with others. You can freely map it to any private IP address in your VPCs. But AWS DO charge the usage of this so called Elastic IP, if you allocate it but not associate with any instance, or even associated but the instance is stopped (please refer to the AWS pricing, as I am not focusing on the price of AWS in this technical blog, but just be aware of it).</li>
	<li>Public IP - allocated from a pool of global IP addresses maintained by Amazon. This address pool is globally shared by all users, and dynamically assigned, that means you may not be able to permanently use it. As AWS may release this IP address from your instance and assign another one to it. If you require a persistence global IP address, you should use the Elastic IP.</li>
</ol>

<p>Now let&#39;s discuss how to implement the 3 different types if NAT in AWS.&nbsp;</p>

<p><span style="font-size:14px;"><span style="color:#0000CD;"><strong>One-to-one</strong></span></span></p>

<p>The usage of one-to-one NAT is usually because your instance is acting as a public server that requires a fix global IP address. According to the above discussion of global IP address types, most likely you already figure out which kind of global IP to be used? Yes, Elastic IP. You need to assign one of the Elastic IP addresses from your account and assign it to interface of the instance.</p>

<p>Note that from the configuration point of view, it seems that the interface right now have 2 IP addresses - one private address of the internal subnet, other is the Elastic IP (like multihome), but actually it is not! The private address to public address translation occurs on the Internet router, just like the normal NAT case of a standard network.</p>

<p><span style="color:#0000CD;"><strong><span style="font-size:14px;">Many-to-many</span></strong></span></p>

<p>You may want to use this kind of NAT if your instance requires to use any application that is not PAT friendly such as application that requires fixed port number. If so, you can either enable the allocation of a public IP (not Elastic) for instance on a subnet, or you can directly enable the allocation on the instance itself. Just like the one-to-one case, this public IP is not actually configured on the interface of the instance (which still only have the private IP address), instead the mapping is implemented in the Internet router.</p>

<p><span style="color:#0000CD;"><span style="font-size:14px;"><strong>Many-to-one</strong></span></span></p>

<p>Actually this is the most common case for those instances that just need to access the Internet as clients. Then they can share a common global IP address using different port numbers when going out to the Internet.</p>

<p>To use this kind of NAT, you need to allocate another NAT Gateway or NAT instance. From functional point of view, NAT Gateway and NAT instance are more or less the same, the only difference is that NAT instance is implemented by a Linux instance which is actually cheaper in the cost (as AWS do charge for NAT Gateway usage). The NAT Gateway (instance) requires to be assigned an Elastic IP address.</p>

<p>The NAT Gateway is just liked a single armed router, its interface is also on a private subnet just like other instance of your VPC, the VPC router will need to change the default route to point to the NAT gateway. For traffic bounded to Internet, the VPC router send the packet to the NAT gateway which will change the source address to itself interface address (which is actually still private IP) using PAT i.e. the port number maybe change. As the NAT gateway has a default route to the Internet Gateway (NAT occurs in there). Therefore, the packet is send to the Internet Gateway which will change the source IP address to the Elastic IP address of the NAT gateway.</p>

<p>&nbsp;</p>

<p><img alt="AWSpat" height="223" src="http://apps.e5link.com/blog/upload/e/5/e5link.com/e897bf3ee01de3bbd63e68904385fbf4.jpg" target="_new" width="496" /><br />
&nbsp;</p>

<p>&nbsp;</p>]]></description>
										
											<guid><![CDATA[http://apps.e5link.com/Blog/?e=96468&d=11/30/2018&s=NAT%20feature%20in%20AWS%20VPC]]></guid>
										
											<link><![CDATA[http://apps.e5link.com/Blog/?e=96468&d=11/30/2018&s=NAT%20feature%20in%20AWS%20VPC]]></link>
										
											<title><![CDATA[NAT feature in AWS VPC]]></title>
										
											<pubDate>Thu, 29 Nov 2018 11:08:06 GMT</pubDate>
										
						</item>
					
				</channel>
			</rss>
		