<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.ampr.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=KE2A</id>
	<title>44Net Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.ampr.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=KE2A"/>
	<link rel="alternate" type="text/html" href="https://wiki.ampr.org/wiki/Special:Contributions/KE2A"/>
	<updated>2026-04-21T03:11:30Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=886</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=886"/>
		<updated>2020-03-23T00:22:07Z</updated>

		<summary type="html">&lt;p&gt;KE2A: removed reference to specific AMPRNet subnet&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Option 1: Secondary IP on WAN interface ==&lt;br /&gt;
&lt;br /&gt;
To create a gateway using Cisco equipment you must have a Cisco Router (preferred from series 2600 and above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two Ethernet ports (but can be done also with one Ethernet port)&lt;br /&gt;
&lt;br /&gt;
Pre requirement to the setup to work are as follows:&lt;br /&gt;
&lt;br /&gt;
You have already registered with AMPRNet and got your 44.x.x.x/y allocation and it is showing in the encap.txt file (see &amp;quot;If you are looking to get an IP allocation within the AMPRNet please read the Portal page.&amp;quot;) info on the main page .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You have registered some hosts of your allocated network in the AMPRNet DNS like &amp;lt;your call sign&amp;gt;.ampr.org&lt;br /&gt;
&lt;br /&gt;
The example given here here is of one Ethernet port.&lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet port the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The commands are:&lt;br /&gt;
&lt;br /&gt;
 enable&lt;br /&gt;
 configure terminal&lt;br /&gt;
 interface ethernet0&lt;br /&gt;
 ip address &amp;lt;and here you give the ip of the commercial isp the router is connected to&amp;gt; (it can also be the IP of a network the router is on  (as long as this IP is accessible to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depending on your router type, it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc.  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet port name.)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the AMPRNet 44.x.x.x IP .&lt;br /&gt;
&lt;br /&gt;
For a router with one port any additional network IP has to be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0&lt;br /&gt;
 ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the AMPRNet))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)&lt;br /&gt;
&lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0 mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router :  &amp;quot;pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands necessary  to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses (excluding the AMPRnet that needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels&lt;br /&gt;
&lt;br /&gt;
== Option 2: VLAN and zone-based firewall ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;re familiar with zone-based policy firewalls in IOS, it&#039;s possible to combine that feature with VTI and policy-based routing in a way that doesn&#039;t require multiple route-maps and won&#039;t impact non-44net traffic on the router.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;!&lt;br /&gt;
! Define security zones for the tunnel interface and 44net vlan&lt;br /&gt;
!&lt;br /&gt;
zone security AMPRNet&lt;br /&gt;
zone security AMPRAlloc&lt;br /&gt;
!&lt;br /&gt;
! An ACL for source traffic on the 44net vlan&lt;br /&gt;
!&lt;br /&gt;
ip access-list standard Vlan44&lt;br /&gt;
 permit &amp;lt;your_44net_allocation&amp;gt; &amp;lt;your_allocation_mask&amp;gt;&lt;br /&gt;
 deny   any log&lt;br /&gt;
!&lt;br /&gt;
! Send all traffic coming from the 44net vlan through the tunnel.&lt;br /&gt;
!&lt;br /&gt;
route-map ampr-tunnel permit 10&lt;br /&gt;
 set interface Tunnel44&lt;br /&gt;
!&lt;br /&gt;
interface GigabitEthernet0/0/0.44&lt;br /&gt;
 description AMPRNet allocation&lt;br /&gt;
 encapsulation dot1Q 44&lt;br /&gt;
 ip address &amp;lt;your_44net_allocation&amp;gt; &amp;lt;your_subnet_mask&amp;gt;&lt;br /&gt;
 zone-member security AMPRAlloc&lt;br /&gt;
 ip policy route-map ampr-tunnel&lt;br /&gt;
!&lt;br /&gt;
interface Tunnel44&lt;br /&gt;
 description AMPRNet&lt;br /&gt;
 ip unnumbered GigabitEthernet0/0/0.44&lt;br /&gt;
 zone-member security AMPRNet&lt;br /&gt;
 tunnel source GigabitEthernet0/0/1&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 tunnel destination 169.228.34.84&lt;br /&gt;
!&lt;br /&gt;
! Now we get into the zone-based firewall configuration&lt;br /&gt;
! Access lists for class-maps&lt;br /&gt;
!&lt;br /&gt;
ip access-list extended Ping&lt;br /&gt;
 permit icmp any any echo&lt;br /&gt;
ip access-list extended Traceroute&lt;br /&gt;
 permit icmp any any time-exceeded&lt;br /&gt;
 permit icmp any any unreachable&lt;br /&gt;
!&lt;br /&gt;
! Classify traffic for the zone-based firewall&lt;br /&gt;
!&lt;br /&gt;
class-map type inspect match-all Traceroute&lt;br /&gt;
 match access-group name Traceroute&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
class-map type inspect match-all Ping&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
 match access-group name Ping&lt;br /&gt;
class-map type inspect match-any Generic&lt;br /&gt;
 match protocol tcp&lt;br /&gt;
 match protocol udp&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
!&lt;br /&gt;
! Define policies for the classes above.&lt;br /&gt;
! Here we will only allow ping and traceroute in, and have no restrictions on outbound traffic.&lt;br /&gt;
! Customize to your needs, of course.&lt;br /&gt;
!&lt;br /&gt;
policy-map type inspect AMPRNetIn&lt;br /&gt;
 class type inspect Traceroute&lt;br /&gt;
  pass&lt;br /&gt;
 class type inspect Ping&lt;br /&gt;
  inspect&lt;br /&gt;
 class class-default&lt;br /&gt;
  drop&lt;br /&gt;
policy-map type inspect AllowAllOut&lt;br /&gt;
 class type inspect Generic&lt;br /&gt;
  inspect&lt;br /&gt;
 class class-default&lt;br /&gt;
  drop&lt;br /&gt;
!&lt;br /&gt;
! Apply policy-maps to traffic flows between zones.&lt;br /&gt;
!&lt;br /&gt;
zone-pair security AMPRNet_to_AMPRAlloc source AMPRNet destination AMPRAlloc&lt;br /&gt;
 service-policy type inspect AMPRNetIn&lt;br /&gt;
zone-pair security AMPRAlloc_to_AMPRNet source AMPRAlloc destination AMPRNet&lt;br /&gt;
 service-policy type inspect AllowAllOut&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Routing to other 44net gateways ==&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;interface Tunnel0&lt;br /&gt;
ip unnumbered Ethernet0&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
tunnel source Ethernet0&lt;br /&gt;
tunnel destination 169.228.34.84&lt;br /&gt;
tunnel mode ipip&lt;br /&gt;
!&lt;br /&gt;
interface Tunnel741916672&lt;br /&gt;
description Link to 44.56.192.0&lt;br /&gt;
ip unnumbered Ethernet0&lt;br /&gt;
ip access-group acl_44 in&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
tunnel source 10.0.0.180&lt;br /&gt;
tunnel destination 24.229.88.253&lt;br /&gt;
tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
interface Ethernet0&lt;br /&gt;
description connected to EthernetLAN_HAIFA&lt;br /&gt;
ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
ip classless&lt;br /&gt;
ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.34.84&lt;br /&gt;
ip route 169.228.34.84 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Making the route commands automatically ==&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because a lot of gateway sits on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available , one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>KE2A</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=885</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=885"/>
		<updated>2020-03-23T00:20:11Z</updated>

		<summary type="html">&lt;p&gt;KE2A: Changed VLAN config to subinterfaces&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Option 1: Secondary IP on WAN interface ==&lt;br /&gt;
&lt;br /&gt;
To create a gateway using Cisco equipment you must have a Cisco Router (preferred from series 2600 and above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two Ethernet ports (but can be done also with one Ethernet port)&lt;br /&gt;
&lt;br /&gt;
Pre requirement to the setup to work are as follows:&lt;br /&gt;
&lt;br /&gt;
You have already registered with AMPRNet and got your 44.x.x.x/y allocation and it is showing in the encap.txt file (see &amp;quot;If you are looking to get an IP allocation within the AMPRNet please read the Portal page.&amp;quot;) info on the main page .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You have registered some hosts of your allocated network in the AMPRNet DNS like &amp;lt;your call sign&amp;gt;.ampr.org&lt;br /&gt;
&lt;br /&gt;
The example given here here is of one Ethernet port.&lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet port the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The commands are:&lt;br /&gt;
&lt;br /&gt;
 enable&lt;br /&gt;
 configure terminal&lt;br /&gt;
 interface ethernet0&lt;br /&gt;
 ip address &amp;lt;and here you give the ip of the commercial isp the router is connected to&amp;gt; (it can also be the IP of a network the router is on  (as long as this IP is accessible to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depending on your router type, it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc.  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet port name.)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the AMPRNet 44.x.x.x IP .&lt;br /&gt;
&lt;br /&gt;
For a router with one port any additional network IP has to be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0&lt;br /&gt;
 ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the AMPRNet))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)&lt;br /&gt;
&lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0 mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router :  &amp;quot;pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands necessary  to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses (excluding the AMPRnet that needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels&lt;br /&gt;
&lt;br /&gt;
== Option 2: VLAN and zone-based firewall ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;re familiar with zone-based policy firewalls in IOS, it&#039;s possible to combine that feature with VTI and policy-based routing in a way that doesn&#039;t require multiple route-maps and won&#039;t impact non-44net traffic on the router.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;!&lt;br /&gt;
! Define security zones for the tunnel interface and 44net vlan&lt;br /&gt;
!&lt;br /&gt;
zone security AMPRNet&lt;br /&gt;
zone security AMPRAlloc&lt;br /&gt;
!&lt;br /&gt;
! An ACL for source traffic on the 44net vlan&lt;br /&gt;
!&lt;br /&gt;
ip access-list standard Vlan44&lt;br /&gt;
 permit &amp;lt;your_44net_allocation&amp;gt; &amp;lt;your_allocation_mask&amp;gt;&lt;br /&gt;
 deny   any log&lt;br /&gt;
!&lt;br /&gt;
! Send all traffic coming from the 44net vlan through the tunnel.&lt;br /&gt;
!&lt;br /&gt;
route-map ampr-tunnel permit 10&lt;br /&gt;
 set interface Tunnel44&lt;br /&gt;
!&lt;br /&gt;
interface GigabitEthernet0/0/0.44&lt;br /&gt;
 description AMPRNet allocation&lt;br /&gt;
 encapsulation dot1Q 44&lt;br /&gt;
 ip address 44.68.54.1 255.255.255.248&lt;br /&gt;
 zone-member security AMPRAlloc&lt;br /&gt;
 ip policy route-map ampr-tunnel&lt;br /&gt;
!&lt;br /&gt;
interface Tunnel44&lt;br /&gt;
 description AMPRNet&lt;br /&gt;
 ip unnumbered GigabitEthernet0/0/0.44&lt;br /&gt;
 zone-member security AMPRNet&lt;br /&gt;
 tunnel source GigabitEthernet0/0/1&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 tunnel destination 169.228.34.84&lt;br /&gt;
!&lt;br /&gt;
! Now we get into the zone-based firewall configuration&lt;br /&gt;
! Access lists for class-maps&lt;br /&gt;
!&lt;br /&gt;
ip access-list extended Ping&lt;br /&gt;
 permit icmp any any echo&lt;br /&gt;
ip access-list extended Traceroute&lt;br /&gt;
 permit icmp any any time-exceeded&lt;br /&gt;
 permit icmp any any unreachable&lt;br /&gt;
!&lt;br /&gt;
! Classify traffic for the zone-based firewall&lt;br /&gt;
!&lt;br /&gt;
class-map type inspect match-all Traceroute&lt;br /&gt;
 match access-group name Traceroute&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
class-map type inspect match-all Ping&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
 match access-group name Ping&lt;br /&gt;
class-map type inspect match-any Generic&lt;br /&gt;
 match protocol tcp&lt;br /&gt;
 match protocol udp&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
!&lt;br /&gt;
! Define policies for the classes above.&lt;br /&gt;
! Here we will only allow ping and traceroute in, and have no restrictions on outbound traffic.&lt;br /&gt;
! Customize to your needs, of course.&lt;br /&gt;
!&lt;br /&gt;
policy-map type inspect AMPRNetIn&lt;br /&gt;
 class type inspect Traceroute&lt;br /&gt;
  pass&lt;br /&gt;
 class type inspect Ping&lt;br /&gt;
  inspect&lt;br /&gt;
 class class-default&lt;br /&gt;
  drop&lt;br /&gt;
policy-map type inspect AllowAllOut&lt;br /&gt;
 class type inspect Generic&lt;br /&gt;
  inspect&lt;br /&gt;
 class class-default&lt;br /&gt;
  drop&lt;br /&gt;
!&lt;br /&gt;
! Apply policy-maps to traffic flows between zones.&lt;br /&gt;
!&lt;br /&gt;
zone-pair security AMPRNet_to_AMPRAlloc source AMPRNet destination AMPRAlloc&lt;br /&gt;
 service-policy type inspect AMPRNetIn&lt;br /&gt;
zone-pair security AMPRAlloc_to_AMPRNet source AMPRAlloc destination AMPRNet&lt;br /&gt;
 service-policy type inspect AllowAllOut&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Routing to other 44net gateways ==&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;interface Tunnel0&lt;br /&gt;
ip unnumbered Ethernet0&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
tunnel source Ethernet0&lt;br /&gt;
tunnel destination 169.228.34.84&lt;br /&gt;
tunnel mode ipip&lt;br /&gt;
!&lt;br /&gt;
interface Tunnel741916672&lt;br /&gt;
description Link to 44.56.192.0&lt;br /&gt;
ip unnumbered Ethernet0&lt;br /&gt;
ip access-group acl_44 in&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
tunnel source 10.0.0.180&lt;br /&gt;
tunnel destination 24.229.88.253&lt;br /&gt;
tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
interface Ethernet0&lt;br /&gt;
description connected to EthernetLAN_HAIFA&lt;br /&gt;
ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
ip classless&lt;br /&gt;
ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.34.84&lt;br /&gt;
ip route 169.228.34.84 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Making the route commands automatically ==&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because a lot of gateway sits on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available , one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>KE2A</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=879</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=879"/>
		<updated>2020-01-16T11:27:11Z</updated>

		<summary type="html">&lt;p&gt;KE2A: Tried to clarify variables in Option 2 config&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Option 1: Secondary IP on WAN interface ==&lt;br /&gt;
&lt;br /&gt;
To create a gateway using Cisco equipment you must have a Cisco Router (preferred from series 2600 and above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two Ethernet ports (but can be done also with one Ethernet port)&lt;br /&gt;
&lt;br /&gt;
Pre requirement to the setup to work are as follows:&lt;br /&gt;
&lt;br /&gt;
You have already registered with AMPRNet and got your 44.x.x.x/y allocation and it is showing in the encap.txt file (see &amp;quot;If you are looking to get an IP allocation within the AMPRNet please read the Portal page.&amp;quot;) info on the main page .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You have registered some hosts of your allocated network in the AMPRNet DNS like &amp;lt;your call sign&amp;gt;.ampr.org&lt;br /&gt;
&lt;br /&gt;
The example given here here is of one Ethernet port.&lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet port the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The commands are:&lt;br /&gt;
&lt;br /&gt;
 enable&lt;br /&gt;
 configure terminal&lt;br /&gt;
 interface ethernet0&lt;br /&gt;
 ip address &amp;lt;and here you give the ip of the commercial isp the router is connected to&amp;gt; (it can also be the IP of a network the router is on  (as long as this IP is accessible to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depending on your router type, it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc.  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet port name.)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the AMPRNet 44.x.x.x IP .&lt;br /&gt;
&lt;br /&gt;
For a router with one port any additional network IP has to be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0&lt;br /&gt;
 ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the AMPRNet))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)&lt;br /&gt;
&lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0 mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router :  &amp;quot;pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands necessary  to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses (excluding the AMPRnet that needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels&lt;br /&gt;
&lt;br /&gt;
== Option 2: VLAN and zone-based firewall ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;re familiar with zone-based policy firewalls in IOS, it&#039;s possible to combine that feature with VTI and policy-based routing in a way that doesn&#039;t require multiple route-maps and won&#039;t impact non-44net traffic on the router.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;!&lt;br /&gt;
! Define security zones for the tunnel interface and 44net vlan&lt;br /&gt;
!&lt;br /&gt;
zone security AMPRNet&lt;br /&gt;
zone security AMPRAlloc&lt;br /&gt;
!&lt;br /&gt;
! An ACL for source traffic on the 44net vlan&lt;br /&gt;
!&lt;br /&gt;
ip access-list standard Vlan44&lt;br /&gt;
 permit &amp;lt;your_44net_allocation&amp;gt; &amp;lt;your_allocation_mask&amp;gt;&lt;br /&gt;
 deny   any log&lt;br /&gt;
!&lt;br /&gt;
! Send all traffic coming from the 44net vlan through the tunnel.&lt;br /&gt;
!&lt;br /&gt;
route-map ampr-tunnel permit 10&lt;br /&gt;
 set interface Tunnel44&lt;br /&gt;
!&lt;br /&gt;
interface Vlan44&lt;br /&gt;
 description AMPRNet allocation&lt;br /&gt;
 ip address &amp;lt;first_ip_from_your_allocation&amp;gt; &amp;lt;allocation_subnet_mask&amp;gt;&lt;br /&gt;
 ip access-group Vlan44 in&lt;br /&gt;
 zone-member security AMPRAlloc&lt;br /&gt;
 ip policy route-map ampr-tunnel&lt;br /&gt;
!&lt;br /&gt;
interface Tunnel44&lt;br /&gt;
 description AMPRNet&lt;br /&gt;
 ip unnumbered Vlan44&lt;br /&gt;
 zone-member security AMPRNet&lt;br /&gt;
 tunnel source GigabitEthernet0/0/1&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 tunnel destination 169.228.34.84&lt;br /&gt;
!&lt;br /&gt;
! Now we get into the zone-based firewall configuration&lt;br /&gt;
! Access lists for class-maps&lt;br /&gt;
!&lt;br /&gt;
ip access-list extended Ping&lt;br /&gt;
 permit icmp any any echo&lt;br /&gt;
ip access-list extended Traceroute&lt;br /&gt;
 permit icmp any any time-exceeded&lt;br /&gt;
 permit icmp any any unreachable&lt;br /&gt;
!&lt;br /&gt;
! Classify traffic for the zone-based firewall&lt;br /&gt;
!&lt;br /&gt;
class-map type inspect match-all Traceroute&lt;br /&gt;
 match access-group name Traceroute&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
class-map type inspect match-all Ping&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
 match access-group name Ping&lt;br /&gt;
class-map type inspect match-any Generic&lt;br /&gt;
 match protocol tcp&lt;br /&gt;
 match protocol udp&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
!&lt;br /&gt;
! Define policies for the classes above.&lt;br /&gt;
! Here we will only allow ping and traceroute in, and have no restrictions on outbound traffic.&lt;br /&gt;
! Customize to your needs, of course.&lt;br /&gt;
!&lt;br /&gt;
policy-map type inspect AMPRNetIn&lt;br /&gt;
 class type inspect Traceroute&lt;br /&gt;
  pass&lt;br /&gt;
 class type inspect Ping&lt;br /&gt;
  inspect&lt;br /&gt;
 class class-default&lt;br /&gt;
  drop&lt;br /&gt;
policy-map type inspect AllowAllOut&lt;br /&gt;
 class type inspect Generic&lt;br /&gt;
  inspect&lt;br /&gt;
 class class-default&lt;br /&gt;
  drop&lt;br /&gt;
!&lt;br /&gt;
! Apply policy-maps to traffic flows between zones.&lt;br /&gt;
!&lt;br /&gt;
zone-pair security AMPRNet_to_AMPRAlloc source AMPRNet destination AMPRAlloc&lt;br /&gt;
 service-policy type inspect AMPRNetIn&lt;br /&gt;
zone-pair security AMPRAlloc_to_AMPRNet source AMPRAlloc destination AMPRNet&lt;br /&gt;
 service-policy type inspect AllowAllOut&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Routing to other 44net gateways ==&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;interface Tunnel0&lt;br /&gt;
ip unnumbered Ethernet0&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
tunnel source Ethernet0&lt;br /&gt;
tunnel destination 169.228.34.84&lt;br /&gt;
tunnel mode ipip&lt;br /&gt;
!&lt;br /&gt;
interface Tunnel741916672&lt;br /&gt;
description Link to 44.56.192.0&lt;br /&gt;
ip unnumbered Ethernet0&lt;br /&gt;
ip access-group acl_44 in&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
tunnel source 10.0.0.180&lt;br /&gt;
tunnel destination 24.229.88.253&lt;br /&gt;
tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
interface Ethernet0&lt;br /&gt;
description connected to EthernetLAN_HAIFA&lt;br /&gt;
ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
ip classless&lt;br /&gt;
ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.34.84&lt;br /&gt;
ip route 169.228.34.84 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Making the route commands automatically ==&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because a lot of gateway sits on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available , one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>KE2A</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=878</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=878"/>
		<updated>2020-01-16T11:07:31Z</updated>

		<summary type="html">&lt;p&gt;KE2A: Changes to section titles and removed subjective language in description of Option 2&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Option 1: Secondary IP on WAN interface ==&lt;br /&gt;
&lt;br /&gt;
To create a gateway using Cisco equipment you must have a Cisco Router (preferred from series 2600 and above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two Ethernet ports (but can be done also with one Ethernet port)&lt;br /&gt;
&lt;br /&gt;
Pre requirement to the setup to work are as follows:&lt;br /&gt;
&lt;br /&gt;
You have already registered with AMPRNet and got your 44.x.x.x/y allocation and it is showing in the encap.txt file (see &amp;quot;If you are looking to get an IP allocation within the AMPRNet please read the Portal page.&amp;quot;) info on the main page .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You have registered some hosts of your allocated network in the AMPRNet DNS like &amp;lt;your call sign&amp;gt;.ampr.org&lt;br /&gt;
&lt;br /&gt;
The example given here here is of one Ethernet port.&lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet port the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The commands are:&lt;br /&gt;
&lt;br /&gt;
 enable&lt;br /&gt;
 configure terminal&lt;br /&gt;
 interface ethernet0&lt;br /&gt;
 ip address &amp;lt;and here you give the ip of the commercial isp the router is connected to&amp;gt; (it can also be the IP of a network the router is on  (as long as this IP is accessible to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depending on your router type, it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc.  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet port name.)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the AMPRNet 44.x.x.x IP .&lt;br /&gt;
&lt;br /&gt;
For a router with one port any additional network IP has to be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0&lt;br /&gt;
 ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the AMPRNet))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)&lt;br /&gt;
&lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0 mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router :  &amp;quot;pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands necessary  to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses (excluding the AMPRnet that needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels&lt;br /&gt;
&lt;br /&gt;
== Option 2: VLAN and zone-based firewall ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;re familiar with zone-based policy firewalls in IOS, it&#039;s possible to combine that feature with VTI and policy-based routing in a way that doesn&#039;t require multiple route-maps and won&#039;t impact non-44net traffic on the router.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;!&lt;br /&gt;
! Define security zones for the tunnel interface and 44net vlan&lt;br /&gt;
!&lt;br /&gt;
zone security AMPRNet&lt;br /&gt;
zone security AMPRAlloc&lt;br /&gt;
!&lt;br /&gt;
! An ACL for source traffic on the 44net vlan&lt;br /&gt;
!&lt;br /&gt;
ip access-list standard Vlan44&lt;br /&gt;
 permit &amp;lt;your_44net_allocation&amp;gt; &amp;lt;your_mask&amp;gt;&lt;br /&gt;
 deny   any log&lt;br /&gt;
!&lt;br /&gt;
! Send all traffic coming from the 44net vlan through the tunnel.&lt;br /&gt;
!&lt;br /&gt;
route-map ampr-tunnel permit 10&lt;br /&gt;
 set interface Tunnel44&lt;br /&gt;
!&lt;br /&gt;
interface Vlan44&lt;br /&gt;
 description AMPRNet allocation&lt;br /&gt;
 ip address &amp;lt;gateway_ip_from_your_allocation&amp;gt; &amp;lt;allocation_subnet_mask&amp;gt;&lt;br /&gt;
 ip access-group Vlan44 in&lt;br /&gt;
 zone-member security AMPRAlloc&lt;br /&gt;
 ip policy route-map ampr-tunnel&lt;br /&gt;
!&lt;br /&gt;
interface Tunnel44&lt;br /&gt;
 description AMPRNet&lt;br /&gt;
 ip unnumbered Vlan44&lt;br /&gt;
 zone-member security AMPRNet&lt;br /&gt;
 tunnel source GigabitEthernet0/0/1&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 tunnel destination 169.228.34.84&lt;br /&gt;
!&lt;br /&gt;
! Now we get into the zone-based firewall configuration&lt;br /&gt;
! Access lists for class-maps&lt;br /&gt;
!&lt;br /&gt;
ip access-list extended Ping&lt;br /&gt;
 permit icmp any any echo&lt;br /&gt;
ip access-list extended Traceroute&lt;br /&gt;
 permit icmp any any time-exceeded&lt;br /&gt;
 permit icmp any any unreachable&lt;br /&gt;
!&lt;br /&gt;
! Classify traffic for the zone-based firewall&lt;br /&gt;
!&lt;br /&gt;
class-map type inspect match-all Traceroute&lt;br /&gt;
 match access-group name Traceroute&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
class-map type inspect match-all Ping&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
 match access-group name Ping&lt;br /&gt;
class-map type inspect match-any Generic&lt;br /&gt;
 match protocol tcp&lt;br /&gt;
 match protocol udp&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
!&lt;br /&gt;
! Define policies for the classes above.&lt;br /&gt;
! Here we will only allow ping and traceroute in, and have no restrictions on outbound traffic.&lt;br /&gt;
! Customize to your needs, of course.&lt;br /&gt;
!&lt;br /&gt;
policy-map type inspect AMPRNetIn&lt;br /&gt;
 class type inspect Traceroute&lt;br /&gt;
  pass&lt;br /&gt;
 class type inspect Ping&lt;br /&gt;
  inspect&lt;br /&gt;
 class class-default&lt;br /&gt;
  drop&lt;br /&gt;
policy-map type inspect AllowAllOut&lt;br /&gt;
 class type inspect Generic&lt;br /&gt;
  inspect&lt;br /&gt;
 class class-default&lt;br /&gt;
  drop&lt;br /&gt;
!&lt;br /&gt;
! Apply policy-maps to traffic flows between zones.&lt;br /&gt;
!&lt;br /&gt;
zone-pair security AMPRNet_to_AMPRAlloc source AMPRNet destination AMPRAlloc&lt;br /&gt;
 service-policy type inspect AMPRNetIn&lt;br /&gt;
zone-pair security AMPRAlloc_to_AMPRNet source AMPRAlloc destination AMPRNet&lt;br /&gt;
 service-policy type inspect AllowAllOut&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Routing to other 44net gateways ==&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;interface Tunnel0&lt;br /&gt;
ip unnumbered Ethernet0&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
tunnel source Ethernet0&lt;br /&gt;
tunnel destination 169.228.34.84&lt;br /&gt;
tunnel mode ipip&lt;br /&gt;
!&lt;br /&gt;
interface Tunnel741916672&lt;br /&gt;
description Link to 44.56.192.0&lt;br /&gt;
ip unnumbered Ethernet0&lt;br /&gt;
ip access-group acl_44 in&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
tunnel source 10.0.0.180&lt;br /&gt;
tunnel destination 24.229.88.253&lt;br /&gt;
tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
interface Ethernet0&lt;br /&gt;
description connected to EthernetLAN_HAIFA&lt;br /&gt;
ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
ip classless&lt;br /&gt;
ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.34.84&lt;br /&gt;
ip route 169.228.34.84 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Making the route commands automatically ==&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because a lot of gateway sits on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available , one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>KE2A</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=877</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=877"/>
		<updated>2020-01-16T10:57:25Z</updated>

		<summary type="html">&lt;p&gt;KE2A: Slight config change in Approach #2 and change to last sentence of the intro to that section.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Approach #1 ==&lt;br /&gt;
&lt;br /&gt;
To create a gateway using Cisco equipment you must have a Cisco Router (preferred from series 2600 and above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two Ethernet ports (but can be done also with one Ethernet port)&lt;br /&gt;
&lt;br /&gt;
Pre requirement to the setup to work are as follows:&lt;br /&gt;
&lt;br /&gt;
You have already registered with AMPRNet and got your 44.x.x.x/y allocation and it is showing in the encap.txt file (see &amp;quot;If you are looking to get an IP allocation within the AMPRNet please read the Portal page.&amp;quot;) info on the main page .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You have registered some hosts of your allocated network in the AMPRNet DNS like &amp;lt;your call sign&amp;gt;.ampr.org&lt;br /&gt;
&lt;br /&gt;
The example given here here is of one Ethernet port.&lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet port the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The commands are:&lt;br /&gt;
&lt;br /&gt;
 enable&lt;br /&gt;
 configure terminal&lt;br /&gt;
 interface ethernet0&lt;br /&gt;
 ip address &amp;lt;and here you give the ip of the commercial isp the router is connected to&amp;gt; (it can also be the IP of a network the router is on  (as long as this IP is accessible to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depending on your router type, it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc.  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet port name.)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the AMPRNet 44.x.x.x IP .&lt;br /&gt;
&lt;br /&gt;
For a router with one port any additional network IP has to be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0&lt;br /&gt;
 ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the AMPRNet))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)&lt;br /&gt;
&lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0 mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router :  &amp;quot;pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands necessary  to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses (excluding the AMPRnet that needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels&lt;br /&gt;
&lt;br /&gt;
== Approach #2 ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;re familiar with zone-based policy firewalls in IOS, it&#039;s possible to combine that feature with VTI and policy-based routing in a more straightforward way that doesn&#039;t require multiple route-maps and won&#039;t impact non-44net traffic on the router.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;!&lt;br /&gt;
! Define security zones for the tunnel interface and 44net vlan&lt;br /&gt;
!&lt;br /&gt;
zone security AMPRNet&lt;br /&gt;
zone security AMPRAlloc&lt;br /&gt;
!&lt;br /&gt;
! An ACL for source traffic on the 44net vlan&lt;br /&gt;
!&lt;br /&gt;
ip access-list standard Vlan44&lt;br /&gt;
 permit &amp;lt;your_44net_allocation&amp;gt; &amp;lt;your_mask&amp;gt;&lt;br /&gt;
 deny   any log&lt;br /&gt;
!&lt;br /&gt;
! Send all traffic coming from the 44net vlan through the tunnel.&lt;br /&gt;
!&lt;br /&gt;
route-map ampr-tunnel permit 10&lt;br /&gt;
 set interface Tunnel44&lt;br /&gt;
!&lt;br /&gt;
interface Vlan44&lt;br /&gt;
 description AMPRNet allocation&lt;br /&gt;
 ip address &amp;lt;gateway_ip_from_your_allocation&amp;gt; &amp;lt;allocation_subnet_mask&amp;gt;&lt;br /&gt;
 ip access-group Vlan44 in&lt;br /&gt;
 zone-member security AMPRAlloc&lt;br /&gt;
 ip policy route-map ampr-tunnel&lt;br /&gt;
!&lt;br /&gt;
interface Tunnel44&lt;br /&gt;
 description AMPRNet&lt;br /&gt;
 ip unnumbered Vlan44&lt;br /&gt;
 zone-member security AMPRNet&lt;br /&gt;
 tunnel source GigabitEthernet0/0/1&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 tunnel destination 169.228.34.84&lt;br /&gt;
!&lt;br /&gt;
! Now we get into the zone-based firewall configuration&lt;br /&gt;
! Access lists for class-maps&lt;br /&gt;
!&lt;br /&gt;
ip access-list extended Ping&lt;br /&gt;
 permit icmp any any echo&lt;br /&gt;
ip access-list extended Traceroute&lt;br /&gt;
 permit icmp any any time-exceeded&lt;br /&gt;
 permit icmp any any unreachable&lt;br /&gt;
!&lt;br /&gt;
! Classify traffic for the zone-based firewall&lt;br /&gt;
!&lt;br /&gt;
class-map type inspect match-all Traceroute&lt;br /&gt;
 match access-group name Traceroute&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
class-map type inspect match-all Ping&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
 match access-group name Ping&lt;br /&gt;
class-map type inspect match-any Generic&lt;br /&gt;
 match protocol tcp&lt;br /&gt;
 match protocol udp&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
!&lt;br /&gt;
! Define policies for the classes above.&lt;br /&gt;
! Here we will only allow ping and traceroute in, and have no restrictions on outbound traffic.&lt;br /&gt;
! Customize to your needs, of course.&lt;br /&gt;
!&lt;br /&gt;
policy-map type inspect AMPRNetIn&lt;br /&gt;
 class type inspect Traceroute&lt;br /&gt;
  pass&lt;br /&gt;
 class type inspect Ping&lt;br /&gt;
  inspect&lt;br /&gt;
 class class-default&lt;br /&gt;
  drop&lt;br /&gt;
policy-map type inspect AllowAllOut&lt;br /&gt;
 class type inspect Generic&lt;br /&gt;
  inspect&lt;br /&gt;
 class class-default&lt;br /&gt;
  drop&lt;br /&gt;
!&lt;br /&gt;
! Apply policy-maps to traffic flows between zones.&lt;br /&gt;
!&lt;br /&gt;
zone-pair security AMPRNet_to_AMPRAlloc source AMPRNet destination AMPRAlloc&lt;br /&gt;
 service-policy type inspect AMPRNetIn&lt;br /&gt;
zone-pair security AMPRAlloc_to_AMPRNet source AMPRAlloc destination AMPRNet&lt;br /&gt;
 service-policy type inspect AllowAllOut&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Routing to other 44net gateways ==&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;interface Tunnel0&lt;br /&gt;
ip unnumbered Ethernet0&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
tunnel source Ethernet0&lt;br /&gt;
tunnel destination 169.228.34.84&lt;br /&gt;
tunnel mode ipip&lt;br /&gt;
!&lt;br /&gt;
interface Tunnel741916672&lt;br /&gt;
description Link to 44.56.192.0&lt;br /&gt;
ip unnumbered Ethernet0&lt;br /&gt;
ip access-group acl_44 in&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
tunnel source 10.0.0.180&lt;br /&gt;
tunnel destination 24.229.88.253&lt;br /&gt;
tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
interface Ethernet0&lt;br /&gt;
description connected to EthernetLAN_HAIFA&lt;br /&gt;
ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
ip classless&lt;br /&gt;
ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.34.84&lt;br /&gt;
ip route 169.228.34.84 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Making the route commands automatically ==&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because a lot of gateway sits on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available , one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>KE2A</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=876</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=876"/>
		<updated>2020-01-16T02:45:33Z</updated>

		<summary type="html">&lt;p&gt;KE2A: Added sectin headings and table of contents, and a zone-based firewall configuration option&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Approach #1 ==&lt;br /&gt;
&lt;br /&gt;
To create a gateway using Cisco equipment you must have a Cisco Router (preferred from series 2600 and above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two Ethernet ports (but can be done also with one Ethernet port)&lt;br /&gt;
&lt;br /&gt;
Pre requirement to the setup to work are as follows:&lt;br /&gt;
&lt;br /&gt;
You have already registered with AMPRNet and got your 44.x.x.x/y allocation and it is showing in the encap.txt file (see &amp;quot;If you are looking to get an IP allocation within the AMPRNet please read the Portal page.&amp;quot;) info on the main page .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You have registered some hosts of your allocated network in the AMPRNet DNS like &amp;lt;your call sign&amp;gt;.ampr.org&lt;br /&gt;
&lt;br /&gt;
The example given here here is of one Ethernet port.&lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet port the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The commands are:&lt;br /&gt;
&lt;br /&gt;
 enable&lt;br /&gt;
 configure terminal&lt;br /&gt;
 interface ethernet0&lt;br /&gt;
 ip address &amp;lt;and here you give the ip of the commercial isp the router is connected to&amp;gt; (it can also be the IP of a network the router is on  (as long as this IP is accessible to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depending on your router type, it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc.  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet port name.)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the AMPRNet 44.x.x.x IP .&lt;br /&gt;
&lt;br /&gt;
For a router with one port any additional network IP has to be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0&lt;br /&gt;
 ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the AMPRNet))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)&lt;br /&gt;
&lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0 mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router :  &amp;quot;pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands necessary  to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses (excluding the AMPRnet that needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels&lt;br /&gt;
&lt;br /&gt;
== Approach #2 ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;re familiar with zone-based policy firewalls in IOS, it&#039;s possible to combine that feature with VTI and policy-based routing in a more straightforward way that doesn&#039;t require multiple route-maps.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;!&lt;br /&gt;
! Define security zones for the tunnel interface and 44net vlan&lt;br /&gt;
!&lt;br /&gt;
zone security AMPRNet&lt;br /&gt;
zone security AMPRAlloc&lt;br /&gt;
!&lt;br /&gt;
! An ACL for source traffic on the 44net vlan&lt;br /&gt;
!&lt;br /&gt;
ip access-list standard Vlan44&lt;br /&gt;
 permit &amp;lt;your_44net_allocation&amp;gt; &amp;lt;your_mask&amp;gt;&lt;br /&gt;
 deny   any log&lt;br /&gt;
!&lt;br /&gt;
! Send all traffic coming from the 44net vlan through the tunnel.&lt;br /&gt;
!&lt;br /&gt;
route-map ampr-tunnel permit 10&lt;br /&gt;
 set ip next-hop 169.228.34.84&lt;br /&gt;
!&lt;br /&gt;
interface Vlan44&lt;br /&gt;
 description AMPRNet allocation&lt;br /&gt;
 ip address &amp;lt;gateway_ip_from_your_allocation&amp;gt; &amp;lt;allocation_subnet_mask&amp;gt;&lt;br /&gt;
 ip access-group Vlan44 in&lt;br /&gt;
 zone-member security AMPRAlloc&lt;br /&gt;
 ip policy route-map ampr-tunnel&lt;br /&gt;
!&lt;br /&gt;
interface Tunnel44&lt;br /&gt;
 description AMPRNet&lt;br /&gt;
 ip unnumbered Vlan44&lt;br /&gt;
 zone-member security AMPRNet&lt;br /&gt;
 tunnel source GigabitEthernet0/0/1&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 tunnel destination 169.228.34.84&lt;br /&gt;
!&lt;br /&gt;
! Now we get into the zone-based firewall configuration&lt;br /&gt;
! Access lists for class-maps&lt;br /&gt;
!&lt;br /&gt;
ip access-list extended Ping&lt;br /&gt;
 permit icmp any any echo&lt;br /&gt;
ip access-list extended Traceroute&lt;br /&gt;
 permit icmp any any time-exceeded&lt;br /&gt;
 permit icmp any any unreachable&lt;br /&gt;
!&lt;br /&gt;
! Classify traffic for the zone-based firewall&lt;br /&gt;
!&lt;br /&gt;
class-map type inspect match-all Traceroute&lt;br /&gt;
 match access-group name Traceroute&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
class-map type inspect match-all Ping&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
 match access-group name Ping&lt;br /&gt;
class-map type inspect match-any Generic&lt;br /&gt;
 match protocol tcp&lt;br /&gt;
 match protocol udp&lt;br /&gt;
 match protocol icmp&lt;br /&gt;
!&lt;br /&gt;
! Define policies for the classes above.&lt;br /&gt;
! Here we will only allow ping and traceroute in, and have no restrictions on outbound traffic.&lt;br /&gt;
! Customize to your needs, of course.&lt;br /&gt;
!&lt;br /&gt;
policy-map type inspect AMPRNetIn&lt;br /&gt;
 class type inspect Traceroute&lt;br /&gt;
  pass&lt;br /&gt;
 class type inspect Ping&lt;br /&gt;
  inspect&lt;br /&gt;
 class class-default&lt;br /&gt;
  drop&lt;br /&gt;
policy-map type inspect AllowAllOut&lt;br /&gt;
 class type inspect Generic&lt;br /&gt;
  inspect&lt;br /&gt;
 class class-default&lt;br /&gt;
  drop&lt;br /&gt;
!&lt;br /&gt;
! Apply policy-maps to traffic flows between zones.&lt;br /&gt;
!&lt;br /&gt;
zone-pair security AMPRNet_to_AMPRAlloc source AMPRNet destination AMPRAlloc&lt;br /&gt;
 service-policy type inspect AMPRNetIn&lt;br /&gt;
zone-pair security AMPRAlloc_to_AMPRNet source AMPRAlloc destination AMPRNet&lt;br /&gt;
 service-policy type inspect AllowAllOut&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Routing to other 44net gateways ==&lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;interface Tunnel0&lt;br /&gt;
ip unnumbered Ethernet0&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
tunnel source Ethernet0&lt;br /&gt;
tunnel destination 169.228.34.84&lt;br /&gt;
tunnel mode ipip&lt;br /&gt;
!&lt;br /&gt;
interface Tunnel741916672&lt;br /&gt;
description Link to 44.56.192.0&lt;br /&gt;
ip unnumbered Ethernet0&lt;br /&gt;
ip access-group acl_44 in&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
tunnel source 10.0.0.180&lt;br /&gt;
tunnel destination 24.229.88.253&lt;br /&gt;
tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
interface Ethernet0&lt;br /&gt;
description connected to EthernetLAN_HAIFA&lt;br /&gt;
ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
ip classless&lt;br /&gt;
ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.34.84&lt;br /&gt;
ip route 169.228.34.84 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Making the route commands automatically ==&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because a lot of gateway sits on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available , one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>KE2A</name></author>
	</entry>
	<entry>
		<id>https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=875</id>
		<title>Setting up a gateway on Cisco Routers</title>
		<link rel="alternate" type="text/html" href="https://wiki.ampr.org/w/index.php?title=Setting_up_a_gateway_on_Cisco_Routers&amp;diff=875"/>
		<updated>2020-01-16T01:11:43Z</updated>

		<summary type="html">&lt;p&gt;KE2A: Changed a preformatted text block to &amp;lt;nowiki&amp;gt; for easier reading&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To create a gateway using Cisco equipment you must have a Cisco Router (preferred from series 2600 and above)&lt;br /&gt;
&lt;br /&gt;
Preferred with two Ethernet ports (but can be done also with one Ethernet port)&lt;br /&gt;
&lt;br /&gt;
Pre requirement to the setup to work are as follows:&lt;br /&gt;
&lt;br /&gt;
You have already registered with AMPRNet and got your 44.x.x.x/y allocation and it is showing in the encap.txt file (see &amp;quot;If you are looking to get an IP allocation within the AMPRNet please read the Portal page.&amp;quot;) info on the main page .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You have registered some hosts of your allocated network in the AMPRNet DNS like &amp;lt;your call sign&amp;gt;.ampr.org&lt;br /&gt;
&lt;br /&gt;
The example given here here is of one Ethernet port.&lt;br /&gt;
&lt;br /&gt;
You have to assign the router Ethernet port the Commercial IP  &lt;br /&gt;
&lt;br /&gt;
The commands are:&lt;br /&gt;
&lt;br /&gt;
 enable&lt;br /&gt;
 configure terminal&lt;br /&gt;
 interface ethernet0&lt;br /&gt;
 ip address &amp;lt;and here you give the ip of the commercial isp the router is connected to&amp;gt; (it can also be the IP of a network the router is on  (as long as this IP is accessible to the outside world))&amp;gt; &amp;lt;The NetMask of the network&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface name can vary depending on your router type, it can be  Ethernet0  FastEthernet0 GigabitEthernet0/0 etc.  &lt;br /&gt;
&lt;br /&gt;
(To see what interfaces you have in order to assign them the address  use the command Show interface and identify the Ethernet port name.)&lt;br /&gt;
&lt;br /&gt;
Then you have to assign the AMPRNet 44.x.x.x IP .&lt;br /&gt;
&lt;br /&gt;
For a router with one port any additional network IP has to be secondary and the command is:&lt;br /&gt;
&lt;br /&gt;
 int eth0&lt;br /&gt;
 ip add &amp;lt;the AMPR IP &amp;gt; &amp;lt;the netmask of the network &amp;gt; secondary&lt;br /&gt;
  &lt;br /&gt;
Now  some  tunneling commands have to be added to redirect your outgoing  traffic  (via tunnel) to  the main  AMPRNET router , you do it because every ISP  block  outgoing IP&#039;s which is not a part of their network  (and 44 net is not belong to any  ISP) so in order to allow the 44 net IP traffic  to gain  access to the outside world  you need to do a tunnel to the AMPR.ORG router  to the  outgoing  traffic (traffic that intend to reach the internet (all other IP&#039;s that are not part of the AMPRNet))&lt;br /&gt;
&lt;br /&gt;
To open a tunnel channel you have to specify the tunnel source address (from where the tunnel is established) and tunnel destination (to where the tunnel establish to)&lt;br /&gt;
&lt;br /&gt;
This is done by a few commands  here they are&lt;br /&gt;
&lt;br /&gt;
 interface tunnel0&lt;br /&gt;
 tunnel source &amp;lt;here you put the router commercial IP&amp;gt;&lt;br /&gt;
 tunnel destination &amp;lt;here you put  the AMPR.ORG main tunnel router IP&amp;gt;&lt;br /&gt;
 tunnel mode ipip (this command is to tell the tunnel (cisco support lot of tunneling types) which  mode to use)&lt;br /&gt;
&lt;br /&gt;
In addition the router has to be  notified to pass all the  outgoing 44 Net Traffic to the tunnel interface and not to route it just like that to the  Internet  (because as explained  they will be probably  blocked by the  closest ISP you are connected  to ) &lt;br /&gt;
&lt;br /&gt;
The command to do it is  &lt;br /&gt;
&lt;br /&gt;
 ip route 0.0.0.0 0.0.0.0 Tunnel0 &amp;lt;the ip address of the AMPR.ORG main tunnel router &amp;gt;&lt;br /&gt;
 &lt;br /&gt;
(0.0.0.0 0.0.0.0 mean &amp;quot;any IP&amp;quot;)  (will be explained latter)&lt;br /&gt;
&lt;br /&gt;
Another important command is a command to route  the tunneled traffic from the router  to the main ampr.org router  not via a tunnel (this important to establish  tunnel)  &lt;br /&gt;
&lt;br /&gt;
This command is more specific then the &amp;quot;any IP&amp;quot; route command  described before and say to the router :  &amp;quot;pass the tunneled traffic  belong to the other side of the tunnel direct and not via tunnel&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Command is : &lt;br /&gt;
&lt;br /&gt;
 ip route &amp;lt;the ampr.org main tunnel IP &amp;gt; 255.255.255.255 Ethernet0 &amp;lt;your  router commercial IP&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This  are the minimum  commands necessary  to be able to route your  inside 44  net IP to the outside world (but not to any  other 44 net  networks worldwide) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method  will redirect any  outgoing traffic (no matter what local IP  is  used ) to the tunnel and since the AMPR.ORG tunnel deal with tunneling from only  44 Net IP  it mean  that if the router local  Lan is sharing 44 and non 44 IP machines the non 44 Net machines  will have no connectivity  to the world&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem a route policy will have to  be used (with the command route-map) because regular route command deal with route  for destination  IP  without  looking at the source (local net)  and   route policy  can do it ...&lt;br /&gt;
&lt;br /&gt;
So two policy  have to be created  one for all addresses (excluding the AMPRnet that needed to be routed direct to the internet (without tunnel) and second one specifically for the 44 net hosts that needed to redirect their  outgoing traffic to the tunnels &lt;br /&gt;
&lt;br /&gt;
In order to route your traffic  to other 44 net gateways  you need to build  a tunnel interface to every gateway  (unlike JNOS that one tunnel deal with all  tunnels)&lt;br /&gt;
and the tunnel  have to have a tunnel source  tunnel destination  (as explained above ) and tunnel  mode&lt;br /&gt;
&lt;br /&gt;
In addition two route lines have to  be added  &lt;br /&gt;
&lt;br /&gt;
One is route command to route the specific 44 network of the gateway  this tunnel deal into this   tunnel  &lt;br /&gt;
&lt;br /&gt;
And another is to allow the tunnel traffic to go thorough  the internet  &lt;br /&gt;
&lt;br /&gt;
Enclosed is example from   router that is doing tunnel to the main  AMPR router and to  one gateway  somewhere in the world&lt;br /&gt;
&lt;br /&gt;
The tunnel0 interface is the Main AMPR.ORG  router  and the tunnel with 741916672 is one tunnel to a gateway &lt;br /&gt;
&lt;br /&gt;
The section  of tunnel74xxx have to duplicated to every 44 net gateway  (of course with the corresponding ip of the specific gateway) (currently about 400 times)&lt;br /&gt;
&lt;br /&gt;
TIP: If you  are not familiar with Cisco Commands you can use the GUI  Software  called Cisco Configuration Professional (CCP)&lt;br /&gt;
&lt;br /&gt;
to config  the router with it &lt;br /&gt;
&lt;br /&gt;
Later on we will deal of how to create these tunnels  lines configuration  using a script &lt;br /&gt;
that takes the info from the ENCAP.TXT  file and convert it to  Cisco config&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;interface Tunnel0&lt;br /&gt;
ip unnumbered Ethernet0&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
tunnel source Ethernet0&lt;br /&gt;
tunnel destination 169.228.34.84&lt;br /&gt;
tunnel mode ipip&lt;br /&gt;
!&lt;br /&gt;
interface Tunnel741916672&lt;br /&gt;
description Link to 44.56.192.0&lt;br /&gt;
ip unnumbered Ethernet0&lt;br /&gt;
ip access-group acl_44 in&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
tunnel source 10.0.0.180&lt;br /&gt;
tunnel destination 24.229.88.253&lt;br /&gt;
tunnel mode ipip&lt;br /&gt;
&lt;br /&gt;
interface Ethernet0&lt;br /&gt;
description connected to EthernetLAN_HAIFA&lt;br /&gt;
ip address 44.138.1.1 255.255.255.0 secondary&lt;br /&gt;
ip address 10.0.0.180 255.255.255.0&lt;br /&gt;
no ip directed-broadcast&lt;br /&gt;
&lt;br /&gt;
ip classless&lt;br /&gt;
ip route 0.0.0.0 0.0.0.0 Tunnel0 169.228.34.84&lt;br /&gt;
ip route 169.228.34.84 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
ip route 44.56.192.0 255.255.255.0 Tunnel741916672&lt;br /&gt;
ip route 24.229.88.253 255.255.255.255 Ethernet0 10.0.0.138&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Making the route  commands  automatically&lt;br /&gt;
&lt;br /&gt;
Because  the route info of the gateways (the encap file) changes  periodically&lt;br /&gt;
mainly because a lot of gateway sits on dynamic ip &lt;br /&gt;
&lt;br /&gt;
and because the  tunnel ip as a result  change you may loose the tunnel to these gateways &lt;br /&gt;
&lt;br /&gt;
In order to be &amp;quot;updated&amp;quot; it is needed to take the new encap file periodically and put it into the cisco router&lt;br /&gt;
&lt;br /&gt;
Because the encap file lines are not a format of commands that  Cisco &amp;quot;understand&amp;quot;  a fomat conversion need to  be made  in order to convert route info in the encap file to commands that cisco  can &amp;quot;understand&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So a Script that take the encap file and make a new file of Cisco commands  must  be run&lt;br /&gt;
&lt;br /&gt;
There are two scripts that do it   available , one is Perl  and other is VBS&lt;br /&gt;
&lt;br /&gt;
The example will give the results of the  Perl Script&lt;br /&gt;
&lt;br /&gt;
The Perl  Script for the Cisco  enclosed &lt;br /&gt;
&lt;br /&gt;
  #!/usr/bin/perl&lt;br /&gt;
 #encapconvert.pl V0.1 10-31-12&lt;br /&gt;
 #Script created by Jason Begley KY9J ky9j.com ky9j@arrl.net&lt;br /&gt;
 #This script is used for converting the encap.txt file from the AMPR net&lt;br /&gt;
 #into a loadable config file for use on cisco routers. It is advised to use&lt;br /&gt;
 #this on a 2600 or better router due to interface limits.&lt;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
 my ($line);&lt;br /&gt;
 my %nets = ();&lt;br /&gt;
 my $net = undef;&lt;br /&gt;
 my $mask = undef;&lt;br /&gt;
&lt;br /&gt;
 #####&lt;br /&gt;
 #Below are user defined varibles&lt;br /&gt;
&lt;br /&gt;
 my $loop = &amp;quot;Ethernet0&amp;quot;; #LOOPBACK INT CHANGE IF ALREADY IN USE&lt;br /&gt;
 my $outip = &amp;quot;10.0.0.180&amp;quot;; #YOUR PUBLIC IP ADDRESS&lt;br /&gt;
 my $loopip = &amp;quot;44.138.1.1&amp;quot;; #YOUR AMPR IP ADDRESS&lt;br /&gt;
 #EO user defined varibles&lt;br /&gt;
 #####&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my $file = $ARGV[0];&lt;br /&gt;
 my $debug = $ARGV[1];&lt;br /&gt;
 if(!$file) { usage(); exit; } &lt;br /&gt;
 if($file =~ /--help/) { usage(); exit; } &lt;br /&gt;
&lt;br /&gt;
 open (MYFILE, &#039;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
 print MYFILE &amp;quot;!\ninterface $loop\nip address $loopip 255.255.255.255\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
 open(ENCAP, $file);&lt;br /&gt;
 @line = &amp;lt;ENCAP&amp;gt;;&lt;br /&gt;
 close (ENCAP);&lt;br /&gt;
 @line = grep (!/^\s*$/,@line);&lt;br /&gt;
 @line = grep (!/^#/,@line);&lt;br /&gt;
 chomp(@line);&lt;br /&gt;
&lt;br /&gt;
 foreach $line(@line)&lt;br /&gt;
 {&lt;br /&gt;
        $n1 = $n2 = $n3 = $n4 = undef;&lt;br /&gt;
        @ln = (split(/ +/, $line));&lt;br /&gt;
        ($n, $s) = (split(/\//, $ln[2]));&lt;br /&gt;
        ($n1, $n2, $n3, $n4) = split(/\./, $n);&lt;br /&gt;
        $gw = $ln[4];&lt;br /&gt;
        $gw =~ s/\s*$//;&lt;br /&gt;
 &lt;br /&gt;
        if      ($n1 == &#039;&#039;)  {  $n1=&#039;0&#039;};&lt;br /&gt;
        if      ($n2 == &#039;&#039;)  {  $n2=&#039;0&#039;};&lt;br /&gt;
        if      ($n3 == &#039;&#039;)  {  $n3=&#039;0&#039;};&lt;br /&gt;
        if      ($n4 == &#039;&#039;)  {  $n4=&#039;0&#039;};&lt;br /&gt;
&lt;br /&gt;
        if ($s == &#039;1&#039;)  { $mask=&#039;128.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;2&#039;)  { $mask=&#039;192.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;3&#039;)  { $mask=&#039;224.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;4&#039;)  { $mask=&#039;240.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;5&#039;)  { $mask=&#039;248.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;6&#039;)  { $mask=&#039;252.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;7&#039;)  { $mask=&#039;254.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;8&#039;)  { $mask=&#039;255.0.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;9&#039;)  { $mask=&#039;255.128.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;10&#039;) { $mask=&#039;255.192.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;11&#039;) { $mask=&#039;255.224.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;12&#039;) { $mask=&#039;255.240.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;13&#039;) { $mask=&#039;255.248.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;14&#039;) { $mask=&#039;255.252.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;15&#039;) { $mask=&#039;255.254.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;16&#039;) { $mask=&#039;255.255.0.0&#039;};&lt;br /&gt;
        if ($s == &#039;17&#039;) { $mask=&#039;255.255.128.0&#039;};&lt;br /&gt;
        if ($s == &#039;18&#039;) { $mask=&#039;255.255.192.0&#039;};&lt;br /&gt;
        if ($s == &#039;19&#039;) { $mask=&#039;255.255.224.0&#039;};&lt;br /&gt;
        if ($s == &#039;20&#039;) { $mask=&#039;255.255.240.0&#039;};&lt;br /&gt;
        if ($s == &#039;21&#039;) { $mask=&#039;255.255.248.0&#039;};&lt;br /&gt;
        if ($s == &#039;22&#039;) { $mask=&#039;255.255.252.0&#039;};&lt;br /&gt;
        if ($s == &#039;23&#039;) { $mask=&#039;255.255.254.0&#039;};&lt;br /&gt;
        if ($s == &#039;24&#039;) { $mask=&#039;255.255.255.0&#039;};&lt;br /&gt;
        if ($s == &#039;25&#039;) { $mask=&#039;255.255.255.128&#039;};&lt;br /&gt;
        if ($s == &#039;26&#039;) { $mask=&#039;255.255.255.192&#039;};&lt;br /&gt;
        if ($s == &#039;27&#039;) { $mask=&#039;255.255.255.224&#039;};&lt;br /&gt;
        if ($s == &#039;28&#039;) { $mask=&#039;255.255.255.240&#039;};&lt;br /&gt;
        if ($s == &#039;29&#039;) { $mask=&#039;255.255.255.248&#039;};&lt;br /&gt;
        if ($s == &#039;30&#039;) { $mask=&#039;255.255.255.252&#039;};&lt;br /&gt;
        if ($s == &#039;31&#039;) { $mask=&#039;255.255.255.254&#039;};&lt;br /&gt;
        if ($s == &#039;32&#039;) { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
        if ($s == &#039;&#039;)   { $mask=&#039;255.255.255.255&#039;};&lt;br /&gt;
&lt;br /&gt;
  $net = &amp;quot;$n1.$n2.$n3.$n4&amp;quot;;&lt;br /&gt;
  $ifid = cipdec(1, $net);&lt;br /&gt;
  $wmask = do_subtract($mask);&lt;br /&gt;
  print &amp;quot;*ip info*\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;NET:$n\nBITS:$s MASK:$mask-$wmask\nGW:$gw\nIF:$ifid\n\n&amp;quot;;&lt;br /&gt;
  open (MYFILE, &#039;&amp;gt;&amp;gt;cisco-config.txt&#039;);&lt;br /&gt;
&lt;br /&gt;
 if ($debug != NULL) {&lt;br /&gt;
  print &amp;quot;LINE:$line&amp;quot;;&lt;br /&gt;
  print &amp;quot;\n!\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if ($gw != $outip) {&lt;br /&gt;
&lt;br /&gt;
  print MYFILE &amp;quot;!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;interface tunnel $ifid\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;description Link to $net\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip unnumbered $loop\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel source $outip\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel destination $gw\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip tcp adjust-mss 1436\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip access-group acl_44 in\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;tunnel mode ipip\n!\n&amp;quot;;&lt;br /&gt;
  print MYFILE &amp;quot;ip route $net $mask tunnel$ifid\n!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
  print MYFILE &amp;quot;ip route  $gw 255.255.255.255 Eth0 10.0.0.138\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 print MYFILE &amp;quot;!\nend\n!\n&amp;quot;;&lt;br /&gt;
 close (MYFILE);&lt;br /&gt;
&lt;br /&gt;
 sub usage&lt;br /&gt;
  {&lt;br /&gt;
  print &amp;lt;&amp;lt; &amp;quot;EOT&amp;quot;;&lt;br /&gt;
 *** This script is for creating a loadable config (copy tftp run) for cisco routers ***&lt;br /&gt;
 *** Please note that this was tested to work on 2651XM or better, expect poor resp- ***&lt;br /&gt;
 *** -onse on smaller/slower platforms.                                              ***&lt;br /&gt;
 *** Edit this file and change varibles as noted to your values.                     ***&lt;br /&gt;
 *** File \&amp;quot;cisco-config.txt\&amp;quot; will be generated in this directory for tftp upload     ***&lt;br /&gt;
 *** Run as follows:                                                                 ***&lt;br /&gt;
 *** perl encapconvert.pl encap.txt                                                  ***&lt;br /&gt;
 EOT&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 ########################################################&lt;br /&gt;
 # Sub cipdec&lt;br /&gt;
 # USAGE: For converting IP to DEC values and reverse&lt;br /&gt;
 #&lt;br /&gt;
 # my ($err, $ret) = cipdec(1, $ip);  #1 =from ip to dec, 2 = from dec to ip &lt;br /&gt;
 # if($err != 0) { print &amp;quot;MAIN: ERR ON \&amp;quot;$ret\&amp;quot;\n&amp;quot;; next; }  &lt;br /&gt;
 #&lt;br /&gt;
 sub cipdec&lt;br /&gt;
   {&lt;br /&gt;
  my $debug = 0;&lt;br /&gt;
  my (@oct, $opt, $var, $err, $ret, $errmsg);&lt;br /&gt;
  my ($oct1, $oct2, $oct3, $oct4);&lt;br /&gt;
  my ($dec1, $dec2, $dec3);&lt;br /&gt;
  $opt = shift(@_); #1 =from ip to dec, 2 = from dec to ip&lt;br /&gt;
  $var = shift(@_); # IP or a DEC &lt;br /&gt;
  $err = 0;&lt;br /&gt;
  $ret = 0;&lt;br /&gt;
  if($debug == 1) &lt;br /&gt;
    { &lt;br /&gt;
    print &amp;quot;SUB TEST: OPT=\&amp;quot;$opt\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    print &amp;quot;SUB TEST: VAR=\&amp;quot;$var\&amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  if($opt == 1) #1 =from ip to dec&lt;br /&gt;
    {&lt;br /&gt;
    my $ip = $var;&lt;br /&gt;
&lt;br /&gt;
    if(!($ip) || ($ip eq &amp;quot;&amp;quot;) || !($ip =~ /\./))&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;NO . in IP.. Next\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: IP WITH NO \&amp;quot;.\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    @oct = split(/\./, $ip);&lt;br /&gt;
    my $numoct = @oct;&lt;br /&gt;
    if($numoct != 4)&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: OCT CT \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      }&lt;br /&gt;
    foreach my $val (@oct)&lt;br /&gt;
      {&lt;br /&gt;
      if(!(defined $val) || ($val eq &amp;quot;&amp;quot;) || ($val =~ /\D/) || ($val &amp;gt; 255) || ($val &amp;lt; 0))&lt;br /&gt;
        { &lt;br /&gt;
        if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
        $err = 1;&lt;br /&gt;
        $ret = &amp;quot;ERR: OCT SIZE \&amp;quot;$ip:$val\&amp;quot;&amp;quot;;&lt;br /&gt;
        return($err, $ret);&lt;br /&gt;
        } # EO IF oct container&lt;br /&gt;
      } #EO FOREACH OCT&lt;br /&gt;
    $ret += ($oct[0] * (256**3)); #Convert 1st octet to decimal and add&lt;br /&gt;
    $ret += ($oct[1] * (256**2)); #Convert 2nd octet to decimal and add&lt;br /&gt;
    $ret += $oct[2] * 256; #Convert 3rd octet to decimal and add&lt;br /&gt;
    $ret += $oct[3]; #Add the 4th octet to decimal&lt;br /&gt;
    if(($ret &amp;lt; 0) || ($ret &amp;gt; 4294967296)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID IP: \&amp;quot;$ip\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$ip\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size&lt;br /&gt;
    &lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO OPT == 1&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  if($opt == 2) #1 = dec to ip&lt;br /&gt;
    {&lt;br /&gt;
    $oct1 = 0; $oct2 = 0; $oct3 = 0; $oct4 = 0;&lt;br /&gt;
    my $dec = $var;&lt;br /&gt;
    if($debug == 1) { print &amp;quot;SUB TEST: DEC=\&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    if(!(defined $dec) || ($dec eq &amp;quot;&amp;quot;) || ($dec &amp;lt; 1) || ($dec &amp;gt; 4294967295)) #0.0.0.0 or 255.255.255.255 = Err&lt;br /&gt;
      {&lt;br /&gt;
      if($debug == 1) { print &amp;quot;--INVALID DEC: \&amp;quot;$dec\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $err = 1;&lt;br /&gt;
      $ret = &amp;quot;ERR: DEC SIZE \&amp;quot;$dec\&amp;quot;&amp;quot;;&lt;br /&gt;
      return($err, $ret);&lt;br /&gt;
      } #EO DEC Size   &lt;br /&gt;
   &lt;br /&gt;
    if($dec &amp;gt;= 256**3)&lt;br /&gt;
      {&lt;br /&gt;
      $oct1 = ($dec / 256**3);&lt;br /&gt;
      my @num = split(/\./, $oct1);&lt;br /&gt;
      $oct1 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT1: \&amp;quot;$oct1\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec1 = ($oct1 * 256**3);&lt;br /&gt;
      $dec = $dec - $dec1;&lt;br /&gt;
      }&lt;br /&gt;
    if($dec &amp;gt;= 256**2)&lt;br /&gt;
      {&lt;br /&gt;
      $oct2 = ($dec / 256**2);&lt;br /&gt;
      my @num = split(/\./, $oct2);&lt;br /&gt;
      $oct2 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT2: \&amp;quot;$oct2\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec2 = ($oct2 * 256**2);&lt;br /&gt;
      $dec = $dec - $dec2;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
    if($dec &amp;gt;= 256)&lt;br /&gt;
      {&lt;br /&gt;
      $oct3 = ($dec / 256);&lt;br /&gt;
      my @num = split(/\./, $oct3);&lt;br /&gt;
      $oct3 = $num[0];&lt;br /&gt;
      if($debug == 1) { print &amp;quot;OCT3: \&amp;quot;$oct3\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
      $dec3 = $oct3 * 256;&lt;br /&gt;
      $dec = $dec - $dec3;&lt;br /&gt;
      }&lt;br /&gt;
  &lt;br /&gt;
    $oct4 = $dec;  &lt;br /&gt;
    if($debug == 1) { print &amp;quot;OCT4: \&amp;quot;$oct4\&amp;quot;\n&amp;quot;; }&lt;br /&gt;
    $ret = &amp;quot;$oct1.$oct2.$oct3.$oct4&amp;quot;;&lt;br /&gt;
    return($err, $ret);&lt;br /&gt;
    } #EO If $opt == 2  &lt;br /&gt;
  &lt;br /&gt;
  $err = 1;&lt;br /&gt;
  $ret = &amp;quot;I&#039;m lost and sent to leftovers&amp;quot;;  &lt;br /&gt;
  return($err, $ret);&lt;br /&gt;
  }&lt;br /&gt;
 ################### EO SUB CIPDEC#################################&lt;br /&gt;
&lt;br /&gt;
 ### wildcard sub ###&lt;br /&gt;
 sub do_subtract(  ) {&lt;br /&gt;
  local($ip) = @_;&lt;br /&gt;
&lt;br /&gt;
  # break up the bytes of the incoming IP address&lt;br /&gt;
  $_ = $ip;&lt;br /&gt;
  ($a, $b, $c, $d) = split(/\./);&lt;br /&gt;
&lt;br /&gt;
  if ($a &amp;gt; 255 || $b &amp;gt; 255 || $c &amp;gt; 255 || $d &amp;gt; 255 || /[^0-9.]/) {&lt;br /&gt;
     print &amp;quot;invalid input mask or wildcard\n&amp;quot;;&lt;br /&gt;
     exit(  );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  $a = 255 - $a;&lt;br /&gt;
  $b = 255 - $b;&lt;br /&gt;
  $c = 255 - $c;&lt;br /&gt;
  $d = 255 - $d;&lt;br /&gt;
&lt;br /&gt;
  return ($a . &amp;quot;.&amp;quot; . $b . &amp;quot;.&amp;quot; . $c . &amp;quot;.&amp;quot; . $d);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 ### EO wildcard sub ### &amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before you run the script make sure to take out the line of your gateway  from the encap file &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The result of the script is set of  commands  that look like that &lt;br /&gt;
&lt;br /&gt;
 interface tunnel 748306432&lt;br /&gt;
 description Link to 44.154.64.0&lt;br /&gt;
 ip unnumbered Ethernet0&lt;br /&gt;
 tunnel source 10.0.0.180&lt;br /&gt;
 tunnel destination 79.107.164.191&lt;br /&gt;
 ip tcp adjust-mss 1436&lt;br /&gt;
 ip access-group acl_44 in&lt;br /&gt;
 !&lt;br /&gt;
 tunnel mode ipip&lt;br /&gt;
 !&lt;br /&gt;
 ip route 44.154.64.0 255.255.255.0 tunnel748306432&lt;br /&gt;
 !&lt;br /&gt;
 ip route  79.107.164.191 255.255.255.255 Ethernet0 10.0.0.138&lt;br /&gt;
 !&lt;br /&gt;
&lt;br /&gt;
This section return on itself (with different IP , destination and route  IPs&#039;s ) as the amount of lines in the encap file&lt;br /&gt;
&lt;br /&gt;
When the file  is ready  (after running the perl script)  you can  copy it with editor and send it to the cisco or by terminal  (with the config t  command) or by  TFTP &lt;br /&gt;
&lt;br /&gt;
The Encap file can be taken automatically from the Portal using the API&lt;br /&gt;
and  you can  push  the  commands to the cisco (after the encap   convert to cisco commands after running perl) with  TFTP&lt;br /&gt;
&lt;br /&gt;
So with a small software work   the whole  procedure can be done fully automatic&lt;/div&gt;</summary>
		<author><name>KE2A</name></author>
	</entry>
</feed>