Bila anda sering gonta-ganti VPN, komputer tetapi karena kebutuhan untuk debugging dengan tcpdump atau ss perlu mendapatkan IP baik dari ISP anda ataupun dari VPN, bisa menggunakan bantuan curl.

Fungsi yang mirip dengan curl ada di wget dengan menambahkan --bind-address=ADDRESS sayangnya untuk kasus saya tidak bisa digunakan. Tetapi cara diatas bisa digunakan untuk mengecek IP dari dua atau lebih ISP yang dihubungkan ke NIC fisik yang berbeda.

Di server yang saya gunakan eth0 NIC fisik yang terhubung ke LAN. tun0 koneksi VPN.

$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.3  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::9daa:197e:348c:7fbc  prefixlen 64  scopeid 0x20<link>
        ether 02:81:99:be:5f:36  txqueuelen 1000  (Ethernet)
        RX packets 1323154  bytes 1849306099 (1.7 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 631572  bytes 140294217 (133.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 40  
 
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 275  bytes 47022 (45.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 275  bytes 47022 (45.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 
tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet 10.8.0.2  netmask 255.255.255.0  destination 10.8.0.2
        inet6 fe80::3659:cf47:dadf:f2b3  prefixlen 64  scopeid 0x20<link>
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 100  (UNSPEC)
        RX packets 1306493  bytes 1762151636 (1.6 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 620216  bytes 98403705 (93.8 MiB)
        TX errors 0  dropped 1775 overruns 0  carrier 0  collisions 0

untuk mengetahui IP public yang digunakan, bukan IP dari VPN, jalankan perintah

curl --interface eth0 https://icanhazip.com/s
# contoh output
139.194.128.2

untuk mendapatkan IP public VPN gunakan

curl --interface tun0 https://icanhazip.com/s
# contoh output
72.44.32.45

Leave a comment

Your email address will not be published. Required fields are marked *