interesting network commands

Dipesh Majumdar
5 min readJan 9, 2024

--

## about network info

curl ifconfig.me
curl ipinfo.io
traceroute <domain_name>

Example:

traceroute to google.com (172.217.168.206), 64 hops max, 52 byte packets

This line indicates the start of the traceroute to google.com. The IP address 172.217.168.206 is the resolved address for google.com. "64 hops max" means it will trace the route up to a maximum of 64 network devices (routers, switches, etc.) along the path. "52 byte packets" refers to the size of the test packets being sent.

Each subsequent line represents a “hop” along the path from your computer to the destination.

Asterisks * * * indicate that a hop did not respond within a certain time frame. This could be due to various reasons, such as firewalls blocking ICMP (the protocol used by traceroute), or packet loss.

— — — — — — — —

Suppose you have an ec2 instance that is installed in a private subnet. now if you want to know how other external services will see it’s public ip then the command you need to run is:

dig +short myip.opendns.com @resolver1.opendns.com

Try this command as well…

curl http://checkip.amazonaws.com

The result might be one of the nat-gateway ip that is mapped with the private subnet.

And if you want to do same from a pod, then you have to install a deplyment.yaml as given below and the exec into it with bash and then run same command.

apiVersion: apps/v1
kind: Deployment
metadata:
name: curl-test
labels:
app: curl-test
spec:
replicas: 1
selector:
matchLabels:
app: curl-test
template:
metadata:
labels:
app: curl-test
spec:
containers:
- name: curl-container
image: curlimages/curl
command: ["/bin/sh"]
args: ["-c", "while true; do sleep 30; ech hello; done"]
apt-get -y install dnsutils
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
bind9-dnsutils bind9-host bind9-libs krb5-locales libbsd0 libedit2 libgssapi-krb5-2 libicu74 libjson-c5 libk5crypto3 libkeyutils1
libkrb5-3 libkrb5support0 liblmdb0 libmaxminddb0 libnghttp2-14 libuv1t64 libxml2
Suggested packages:
krb5-doc krb5-user mmdb-bin
The following NEW packages will be installed:
bind9-dnsutils bind9-host bind9-libs dnsutils krb5-locales libbsd0 libedit2 libgssapi-krb5-2 libicu74 libjson-c5 libk5crypto3
libkeyutils1 libkrb5-3 libkrb5support0 liblmdb0 libmaxminddb0 libnghttp2-14 libuv1t64 libxml2
0 upgraded, 19 newly installed, 0 to remove and 0 not upgraded.
Need to get 14.1 MB of archives.
After this operation, 46.3 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu noble/main amd64 krb5-locales all 1.20.1-6ubuntu2 [13.8 kB]
Get:2 http://archive.ubuntu.com/ubuntu noble/main amd64 libbsd0 amd64 0.12.1-1build1 [41.2 kB]
Get:3 http://archive.ubuntu.com/ubuntu noble/main amd64 libkrb5support0 amd64 1.20.1-6ubuntu2 [33.5 kB]
Get:4 http://archive.ubuntu.com/ubuntu noble/main amd64 libk5crypto3 amd64 1.20.1-6ubuntu2 [81.7 kB]
Get:5 http://archive.ubuntu.com/ubuntu noble/main amd64 libkeyutils1 amd64 1.6.3-3build1 [9490 B]
Get:6 http://archive.ubuntu.com/ubuntu noble/main amd64 libkrb5-3 amd64 1.20.1-6ubuntu2 [347 kB]
Get:7 http://archive.ubuntu.com/ubuntu noble/main amd64 libgssapi-krb5-2 amd64 1.20.1-6ubuntu2 [142 kB]
Get:8 http://archive.ubuntu.com/ubuntu noble/main amd64 libicu74 amd64 74.2-1ubuntu3 [10.9 MB]
Get:9 http://archive.ubuntu.com/ubuntu noble/main amd64 libjson-c5 amd64 0.17-1build1 [35.3 kB]
Get:10 http://archive.ubuntu.com/ubuntu noble/main amd64 libxml2 amd64 2.9.14+dfsg-1.3ubuntu3 [762 kB]
Get:11 http://archive.ubuntu.com/ubuntu noble/main amd64 libuv1t64 amd64 1.48.0-1.1build1 [97.3 kB]
Get:12 http://archive.ubuntu.com/ubuntu noble/main amd64 liblmdb0 amd64 0.9.31-1build1 [48.1 kB]
Get:13 http://archive.ubuntu.com/ubuntu noble/main amd64 libmaxminddb0 amd64 1.9.1-1build1 [24.4 kB]
Get:14 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 libnghttp2-14 amd64 1.59.0-1ubuntu0.1 [74.3 kB]
Get:15 http://archive.ubuntu.com/ubuntu noble/main amd64 bind9-libs amd64 1:9.18.24-0ubuntu5 [1239 kB]
Get:16 http://archive.ubuntu.com/ubuntu noble/main amd64 bind9-host amd64 1:9.18.24-0ubuntu5 [50.4 kB]
Get:17 http://archive.ubuntu.com/ubuntu noble/main amd64 libedit2 amd64 3.1-20230828-1build1 [97.6 kB]
Get:18 http://archive.ubuntu.com/ubuntu noble/main amd64 bind9-dnsutils amd64 1:9.18.24-0ubuntu5 [155 kB]
Get:19 http://archive.ubuntu.com/ubuntu noble/universe amd64 dnsutils all 1:9.18.24-0ubuntu5 [3676 B]
Fetched 14.1 MB in 2s (8917 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package krb5-locales.
(Reading database ... 4368 files and directories currently installed.)
Preparing to unpack .../00-krb5-locales_1.20.1-6ubuntu2_all.deb ...
Unpacking krb5-locales (1.20.1-6ubuntu2) ...
Selecting previously unselected package libbsd0:amd64.
Preparing to unpack .../01-libbsd0_0.12.1-1build1_amd64.deb ...
Unpacking libbsd0:amd64 (0.12.1-1build1) ...
Selecting previously unselected package libkrb5support0:amd64.
Preparing to unpack .../02-libkrb5support0_1.20.1-6ubuntu2_amd64.deb ...
Unpacking libkrb5support0:amd64 (1.20.1-6ubuntu2) ...
Selecting previously unselected package libk5crypto3:amd64.
Preparing to unpack .../03-libk5crypto3_1.20.1-6ubuntu2_amd64.deb ...
Unpacking libk5crypto3:amd64 (1.20.1-6ubuntu2) ...
Selecting previously unselected package libkeyutils1:amd64.
Preparing to unpack .../04-libkeyutils1_1.6.3-3build1_amd64.deb ...
Unpacking libkeyutils1:amd64 (1.6.3-3build1) ...
Selecting previously unselected package libkrb5-3:amd64.
Preparing to unpack .../05-libkrb5-3_1.20.1-6ubuntu2_amd64.deb ...
Unpacking libkrb5-3:amd64 (1.20.1-6ubuntu2) ...
Selecting previously unselected package libgssapi-krb5-2:amd64.
Preparing to unpack .../06-libgssapi-krb5-2_1.20.1-6ubuntu2_amd64.deb ...
Unpacking libgssapi-krb5-2:amd64 (1.20.1-6ubuntu2) ...
Selecting previously unselected package libicu74:amd64.
Preparing to unpack .../07-libicu74_74.2-1ubuntu3_amd64.deb ...
Unpacking libicu74:amd64 (74.2-1ubuntu3) ...
Selecting previously unselected package libjson-c5:amd64.
Preparing to unpack .../08-libjson-c5_0.17-1build1_amd64.deb ...
Unpacking libjson-c5:amd64 (0.17-1build1) ...
Selecting previously unselected package libxml2:amd64.
Preparing to unpack .../09-libxml2_2.9.14+dfsg-1.3ubuntu3_amd64.deb ...
Unpacking libxml2:amd64 (2.9.14+dfsg-1.3ubuntu3) ...
Selecting previously unselected package libuv1t64:amd64.
Preparing to unpack .../10-libuv1t64_1.48.0-1.1build1_amd64.deb ...
Unpacking libuv1t64:amd64 (1.48.0-1.1build1) ...
Selecting previously unselected package liblmdb0:amd64.
Preparing to unpack .../11-liblmdb0_0.9.31-1build1_amd64.deb ...
Unpacking liblmdb0:amd64 (0.9.31-1build1) ...
Selecting previously unselected package libmaxminddb0:amd64.
Preparing to unpack .../12-libmaxminddb0_1.9.1-1build1_amd64.deb ...
Unpacking libmaxminddb0:amd64 (1.9.1-1build1) ...
Selecting previously unselected package libnghttp2-14:amd64.
Preparing to unpack .../13-libnghttp2-14_1.59.0-1ubuntu0.1_amd64.deb ...
Unpacking libnghttp2-14:amd64 (1.59.0-1ubuntu0.1) ...
Selecting previously unselected package bind9-libs:amd64.
Preparing to unpack .../14-bind9-libs_1%3a9.18.24-0ubuntu5_amd64.deb ...
Unpacking bind9-libs:amd64 (1:9.18.24-0ubuntu5) ...
Selecting previously unselected package bind9-host.
Preparing to unpack .../15-bind9-host_1%3a9.18.24-0ubuntu5_amd64.deb ...
Unpacking bind9-host (1:9.18.24-0ubuntu5) ...
Selecting previously unselected package libedit2:amd64.
Preparing to unpack .../16-libedit2_3.1-20230828-1build1_amd64.deb ...
Unpacking libedit2:amd64 (3.1-20230828-1build1) ...
Selecting previously unselected package bind9-dnsutils.
Preparing to unpack .../17-bind9-dnsutils_1%3a9.18.24-0ubuntu5_amd64.deb ...
Unpacking bind9-dnsutils (1:9.18.24-0ubuntu5) ...
Selecting previously unselected package dnsutils.
Preparing to unpack .../18-dnsutils_1%3a9.18.24-0ubuntu5_all.deb ...
Unpacking dnsutils (1:9.18.24-0ubuntu5) ...
Setting up liblmdb0:amd64 (0.9.31-1build1) ...
Setting up libkeyutils1:amd64 (1.6.3-3build1) ...
Setting up libmaxminddb0:amd64 (1.9.1-1build1) ...
Setting up libuv1t64:amd64 (1.48.0-1.1build1) ...
Setting up libnghttp2-14:amd64 (1.59.0-1ubuntu0.1) ...
Setting up krb5-locales (1.20.1-6ubuntu2) ...
Setting up libkrb5support0:amd64 (1.20.1-6ubuntu2) ...
Setting up libk5crypto3:amd64 (1.20.1-6ubuntu2) ...
Setting up libicu74:amd64 (74.2-1ubuntu3) ...
Setting up libkrb5-3:amd64 (1.20.1-6ubuntu2) ...
Setting up libbsd0:amd64 (0.12.1-1build1) ...
Setting up libjson-c5:amd64 (0.17-1build1) ...
Setting up libxml2:amd64 (2.9.14+dfsg-1.3ubuntu3) ...
Setting up libedit2:amd64 (3.1-20230828-1build1) ...
Setting up libgssapi-krb5-2:amd64 (1.20.1-6ubuntu2) ...
Setting up bind9-libs:amd64 (1:9.18.24-0ubuntu5) ...
Setting up bind9-host (1:9.18.24-0ubuntu5) ...
Setting up bind9-dnsutils (1:9.18.24-0ubuntu5) ...
Setting up dnsutils (1:9.18.24-0ubuntu5) ...
Processing triggers for libc-bin (2.39-0ubuntu8.1) ...
root@ubuntu-deployment-79fbbfdc6c-8k7dk:/# dig +short myip.opendns.com @resolver1.opendns.com
3.xxx.***.@@@

--

--