New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Comments
IPv4: ip -4 addr show venet0 | grep inet | awk '{print $2}' | awk -F/ '{print $1}'
IPv6: ip -6 addr show venet0 | grep inet6 | awk '{print $2}' | awk -F/ '{print $1}'
If he's using IPTables, that might very well be useless in a NAT situation.
True, assuming he's using NAT.
Also try
hostname -i
.The output of that shows two IP's
[root@tx1 ~]# ip -4 addr show venet0 | grep inet | awk '{print $2}' | awk -F/ '{print $1}'
127.0.0.1
192.XXX.XXX.XX
[root@tx1 ~]# curl getipaddr.net -s | head -n 1
192.XXX.XXX.XX
That works perfectly, thanks!
Then pipe it into grep -v ' 127' (watch the space)
Some time ago I found the way with python (cant remember where):
import socket
print([(s.connect(('8.8.8.8', 80)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1])
for ipv6 i changed it like this:
import socket
print([(s.connect(('ipv6.google.com', 80)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)]][0][1])
needs a network connection to setup rules so I use this: