-
Notifications
You must be signed in to change notification settings - Fork 0
Network
Prayag edited this page Apr 11, 2023
·
2 revisions
- https://www.geeksforgeeks.org/routing-tables-in-computer-network/
- A Router is a networking device that forwards data packets between computer network.
- A router operates on layer 3 and layer 4 of the OSI model.
- A routing table is a set of rules, often viewed in table format, that is used to determine where data packets traveling over an Internet Protocol (IP) network will be directed.
- All IP-enabled devices, including routers and switches, use routing tables.
on linuxkit
linuxkit-025000000001:~# ip route list
default via 192.168.65.1 dev eth0
127.0.0.0/8 dev lo scope host
172.17.0.0/16 dev docker0 scope link src 172.17.0.1
172.18.0.0/16 dev br-74b9ee2e5ff1 scope link src 172.18.0.1
172.19.0.0/16 dev br-68bbbd3073dc scope link src 172.19.0.1
172.20.0.0/16 dev br-60c8c94e9351 scope link src 172.20.0.1
172.21.0.0/16 dev br-938072492b97 scope link src 172.21.0.1
172.22.0.0/16 dev br-3fda54d04842 scope link src 172.22.0.1
172.23.0.0/16 dev br-d51afd7f6f08 scope link src 172.23.0.1
192.168.65.0/24 dev eth0 scope link src 192.168.65.3
linuxkit-025000000001:~# cat /etc/resolv.conf
# This file is included on the metadata iso
nameserver 192.168.65.1
domain updupd.wa.comcast.net.prayag@prayag:~$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.201 0.0.0.0 UG 0 0 0 eth1
link-local * 255.255.0.0 U 1000 0 0 eth1
192.168.1.0 * 255.255.255.0 U 2 0 0 eth1
prayag@prayag:~$ sudo route del default gw 192.168.1.201
prayag@prayag:~$ sudo route add default gw 192.168.1.1
prayag@prayag:~$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=50 time=449 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=49 time=140 ms
64 bytes from 8.8.8.8: icmp_req=3 ttl=50 time=141 ms
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 140.759/243.873/449.118/145.131 ms
prayag@prayag:~$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=49 time=144 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=49 time=148 ms
64 bytes from 8.8.8.8: icmp_req=3 ttl=49 time=137 ms
64 bytes from 8.8.8.8: icmp_req=4 ttl=49 time=149 ms
prayag@prayag:~$ sudo vi /etc/resolv.conf
prayag@prayag:~$ nmcli con list
NAME UUID TYPE TIMESTAMP-REAL
OEC1 d404a53a-7c3d-4591-aea1-0148878d90a2 802-11-wireless Sat 11 May 2013 02:45:27 AM CDT
eSewa_Nepal fe7bf889-fd1e-4397-aafb-e60f57a01979 802-11-wireless Mon 29 Jul 2013 07:27:40 AM CDT
Ojasvi 3e5abf4c-6fce-4ee0-8e57-37ec01f55d3d 802-11-wireless Wed 04 Sep 2013 10:17:02 AM CDT
WIRED c9111fb2-7fa2-45cf-8f5c-9ab60d6d7b2b 802-3-ethernet Wed 04 Sep 2013 09:52:03 AM CDT
YIPLHQ ff801255-06f5-4c09-8ff1-d3d765b436c1 802-11-wireless Sat 11 Aug 2012 12:21:37 AM CDT
YIPLHQ2 afcb5a51-8a73-4657-ae0a-d58d1fe7a73e 802-11-wireless Sat 06 Apr 2013 08:04:18 AM CDT
SattyaGUEST f8f1a4b4-1307-4159-b23e-482d7e151511 802-11-wireless Sat 21 Jul 2012 06:51:08 AM CDT
m2workhackathon 187eaf22-e3ad-4617-a403-ebd311843449 802-11-wireless Sun 16 Sep 2012 02:36:35 AM CDT
Mero Mobile Default 998b070b-9d04-4e53-bd2b-9e3742a45b71 gsm Tue 03 Sep 2013 04:23:10 PM CDT
DevFestKtm f6f1be00-09ad-4e0a-b4d6-be0f45315c1e 802-11-wireless Sat 06 Oct 2012 12:52:26 AM CDT
PivotNepal2 3c644227-4364-4398-b4bf-265c0bce09ae 802-11-wireless Fri 26 Apr 2013 07:50:56 AM CDT
PivotNepal1 94f990cd-4b12-4286-a110-47c03bb586ec 802-11-wireless Fri 26 Apr 2013 04:40:16 AM CDT
OurNetwork 7b3ebc89-4b42-4768-b542-f7f2e6a25b8e 802-11-wireless Tue 30 Apr 2013 01:27:34 PM CDT
OurNetwork 1 a4522896-328c-4fb9-87d0-5ddedc2c55ea 802-11-wireless never
Gorato 6c9a7e7d-6f0d-48dc-be07-67d21b0c9549 802-11-wireless Mon 06 May 2013 09:54:10 AM CDT
TRENDnet4366 8346838d-e466-418e-953f-55ffbd2655cf 802-11-wireless Sun 18 Aug 2013 04:00:54 AM CDT
NETROUTE 4ff2ac33-8d17-464d-9b02-71a70fb064cd 802-11-wireless Sat 10 Aug 2013 04:35:56 AM CDT
$ netstat -nr
Routing tables
Internet:
Destination Gateway Flags Refs Use Netif Expire
default link#10 UCS 141 0 utun0
default 192.168.1.1 UGScI 24 0 en0
8.8.8.8 link#10 UHWIi 1 4 utun0
8.20.172.40 link#10 UHWIi 1 1309 utun0
10.1.81.71 link#10 UHWIi 1 4 utun0
...
17.249.12.17 link#10 UHWIi 1 953 utun0
Internet6:
Destination Gateway Flags Netif Expire
default link#10 UGCS utun0
::1 ::1 UHL lo0
2001:428:4c02:585::201a link#10 UGHWIi utun0
2001:428:4c02:58a::201a link#10 UGHWIi utun0
2001:4860:4860::8888 link#10 UGHWIi utun02.. Default Gateway vs Router (intra-network gateway)
- https://www.geeksforgeeks.org/introduction-of-gateways/
- A default gateway is a piece of networking hardware or software used in telecommunications networks that allows data to flow from one discrete network to another.
- A gateway operates upto layer 5 of the OSI model.
- https://www.cisco.com/c/en/us/products/routers/what-is-a-network-gateway.html
- A gateway connects networks, while a router typically delivers data within a network.
$ netstat -rn | grep 'default'
default link#10 UCS 141 0 utun0
default 192.168.1.1 UGScI 24 0 en0
default link#10 UGCS utun0$ route -n get www.ubuntu.com
route to: 91.189.89.115
destination: default
mask: default
interface: utun0 //en0 on macos, there is gateway as well
flags: <UP,DONE,CLONING,STATIC>
recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
0 0 0 0 0 0 1406 0 $ dig ubuntu.archive.com
; <<>> DiG 9.8.3-P1 <<>> ubuntu.archive.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27102
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;ubuntu.archive.com. IN A
;; ANSWER SECTION:
ubuntu.archive.com. 300 IN A 69.172.201.153
;; Query time: 185 msec
;; SERVER: 10.12.138.20#53(10.12.138.20)
;; WHEN: Sat Mar 25 19:46:31 2017
;; MSG SIZE rcvd: 52
$ dig +trace ubuntu.archive.com
; <<>> DiG 9.8.3-P1 <<>> +trace ubuntu.archive.com
;; global options: +cmd
. 53 IN NS d.root-servers.net.
. 53 IN NS c.root-servers.net.
. 53 IN NS j.root-servers.net.
. 53 IN NS i.root-servers.net.
. 53 IN NS b.root-servers.net.
. 53 IN NS h.root-servers.net.
. 53 IN NS e.root-servers.net.
. 53 IN NS f.root-servers.net.
. 53 IN NS m.root-servers.net.
. 53 IN NS a.root-servers.net.
. 53 IN NS l.root-servers.net.
. 53 IN NS g.root-servers.net.
. 53 IN NS k.root-servers.net.
;; Received 505 bytes from 10.12.138.20#53(10.12.138.20) in 81 ms
print the route packets take to network host (man traceroute) -d Enable socket level debugging. See A sample use in man traceroute
$ traceroute -d 10.18.188.88
traceroute to 10.18.188.88 (10.18.188.88), 64 hops max, 52 byte packets
1 10.11.208.1 (10.11.208.1) 6.467 ms 1.895 ms 1.429 ms
2 10.12.254.85 (10.12.254.85) 1.566 ms 1.429 ms 1.565 ms
3 cr319-3a-to-864-5a.net.company.net (10.31.255.229) 29.854 ms 29.838 ms 32.693 ms
4 mls319-4a-to-3a.net.company.net (10.17.101.25) 30.787 ms 29.946 ms 30.114 ms
5 p001 (10.18.188.88) 31.179 ms 29.607 ms 30.084 ms
##routing table
$ netstat -nr
Routing tables
Internet:
Destination Gateway Flags Refs Use Netif Expire
default 10.11.208.1 UGSc 46 179 en0
10.11.208/23 link#4 UCS 2 0 en0-
10.11.208.1is the default gateway -
"over a maximum of 30 hops or 64." All this means is that the diameter of the Internet is roughly 30 or 64 hops. Therefore, many trace routes will only go that far out in trying to reach a destination.
-
The first column is the hop number, which is the Time-To-Live (TTL) value set in the packet.
-
The second column is the host name (if it was resolved) and IP address of the responding system.
-
The last three columns contain the round-trip times in milliseconds for an attempt to reach the destination with the TTL value.
Another use case,
traceroute -d -v dev.shaharma.com
traceroute to dev.shaharma.com (172.30.144.113), 64 hops max, 52 byte packets
1 10.27.253.41 (10.27.253.41) 36 bytes to 10.27.253.186 5.341 ms 1.173 ms 1.169 ms
2 168.94.53.213 (168.94.53.213) 36 bytes to 10.27.253.186 27.782 ms 27.916 ms 29.133 ms
3 hnr2core-e1_18 (168.94.223.125) 36 bytes to 10.27.253.186 28.395 ms 28.328 ms 28.422 ms
4 pnr2core-e1_6_3777 (172.16.227.21) 36 bytes to 10.27.253.186 61.075 ms 61.044 ms 61.110 ms
5 pnr2agg-e2_4 (168.94.80.230) 36 bytes to 10.27.253.186 61.162 ms 61.085 ms 61.112 ms
6 * * *
7 * * *
8 * * *
9 * * *
## see routing table
$ netstat -nr
Routing tables
Internet:
Destination Gateway Flags Refs Use Netif Expire
default 10.27.253.41 UGSc 28 0 en0
[ec2-user@ip-10-0-0-129 ~]$ netstat -nputw
(No info could be read for "-p": geteuid()=501 but you should be root.)
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 11.1.1.31:37446 51.99.222.222:443 TIME_WAIT -
tcp 0 340 11.1.1.31:22 197.11.111.111:64732 ESTABLISHED -
tcp 0 0 11.1.1.31:50216 51.66.666.66:443 TIME_WAIT -
tcp 0 0 11.1.1.31:22 196.22.133.666:60808 ESTABLISHED - ## brew install nmap
yum install -y nmap
nmap -p 8125 my-graphite.domain.com
Starting Nmap 6.40 ( http://nmap.org ) at 2020-05-11 23:49 UTC
Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn
Nmap done: 1 IP address (0 hosts up) scanned in 3.17 secondsnmap -p 8125 172.0.0.0
Starting Nmap 7.70 ( https://nmap.org ) at 2021-04-23 17:14 UTC
Nmap scan report for ip-172-0-0-0.ec2.internal (172.0.0.0)
Host is up (0.00091s latency).
PORT STATE SERVICE
8125/tcp closed unknown
Nmap done: 1 IP address (1 host up) scanned in 0.59 seconds