Sunday, June 11, 2017

Lesson 02: IP Addressing and NAT

Lesson 02: IP Addressing and NAT


Network FundamentalWAN/LAN IPGateway, DNS & Default routeNATWinbox IntroductionIP Addressing Study



Network Fundamental

A computer network or data network is a telecommunications network which allows computers to
exchange data. In computer networks, networked computing devices exchange data with each other
using a data link. The connections between nodes are established using either cable media or wireless
media. The best-known computer network is the Internet.




WAN/LAN IP:

WAN (Wide Area Network): Public IP or Real IP
LAN (Local Area Network): Private IP






Gateway, DNS & Default route

Gateway: Gateway is the forwarding routers IP address.DNS: DNS is used for name resolving.Default Route: Set route where destination address is IPv4/IIPv6 all address.


NAT: Network Address Translation
1) Source NAT (src-nat)
2) Destination Nat (dst-nat)




Configuration:

/system identity
set name=MKT-01
/ip address
add address=195.168.137.2/24 comment=
WAN interface=ether1
add address=192.168.1.1/24 comment=
LAN interface=ether2
/ip route
add check-gateway=ping distance=1
gateway=195.168.137.1
/ip
dnsset servers=8.8.8.8
/ip firewall nat
add action=masquerade chain=srcnat out-interface=ether1 src-address=192.168.1.0/24
Verification:root@box:~# ifconfig eth0 192.168.1.2 netmask 255.255.255.0
root@box:~# route add default gw 192.168.1.1
root@box:~# ping 8.8.8.8 -c 5
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=42 time=90.214 ms
64 bytes from 8.8.8.8: seq=1 ttl=42 time=128.141 ms
64 bytes from 8.8.8.8: seq=2 ttl=42 time=79.949 ms
64 bytes from 8.8.8.8: seq=3 ttl=42 time=88.193 ms
64 bytes from 8.8.8.8: seq=4 ttl=42 time=127.961 ms
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 79.949/102.891/128.141 ms
root@box:~# vi /etc/resolv.conf
nameserver 8.8.8.8
:x
root@box:~# ping www.google.com -c 5
PING www.google.com (103.16.152.157): 56 data bytes
64 bytes from 103.16.152.157: seq=0 ttl=53 time=17.557 ms
64 bytes from 103.16.152.157: seq=1 ttl=53 time=79.561 ms
64 bytes from 103.16.152.157: seq=2 ttl=53 time=29.734 ms
64 bytes from 103.16.152.157: seq=3 ttl=53 time=34.630 ms
64 bytes from 103.16.152.157: seq=4 ttl=53 time=9.522 ms
--- www.google.com ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 9.522/34.200/79.561 ms

IP Addressing Study

VLSM – Variable Length Subnet Mask







Step 1: For Host 220 & 200 -> Reference Network = 172.16.0.0/16
Required CIDR (R1) = 24
Reference CIDR (R2) = 16
So, No. of network = 2
(R1-R2) = 2 (24-16) = 28 = 256
And, per network increment = 2
Required octet last bit number – Required CIDR= 2 24 – 24 = 20 =11st Network Address = 172.16.0.0/24
2
nd Network Address = 172.16.1.0/243rd Network Address = 172.16.2.0/24
Last Network Address = 172.16.255.0/24




Step 2: For Host 2 -> Reference Network = 172.16.2.0/24
Required CIDR (R1) = 30
Reference CIDR (R2) = 24
So, No. of network = 2
(R1-R2) = 2 (30-24) = 26 = 64
And, per network increment = 2
Required octet last bit number – Required CIDR= 2 32 – 30 = 22=41st Network Address = 172.16.2.0/30
2
nd Network Address = 172.16.2.4/30
3
rd Network Address = 172.16.2.8/30
4
th Network Address = 172.16.2.12/30Last Network Address = 172.16.2.252/30

No comments:

Post a Comment