Tag Info

Hot answers tagged

46

It does this by doing nothing special. The network restarts in less time than the TCP connection takes to time out, so the TCP connection survives the "outage" the same way it would survive any transient network outage. The only reason Windows doesn't do the same thing is because Windows specifically resets TCP connections when a network interface goes ...


41

curl -s http://whatismyip.org/ Update: whatismyip.com removed the free service to check the IP address and this no longer works.


39

Quoting from man 3 inet_aton: a.b.c.d Each of the four numeric parts specifies a byte of the address; the bytes are assigned in left-to-right order to produce the binary address. a.b.c Parts a and b specify the first two bytes of the binary address. Part c is interpreted as a 16-bit value that ...


31

Since whatsmyip.org and ifconfig.me have already been mentioned: curl -s icanhazip.com


25

I'd recommend getting it directly from a DNS server. Most of the answers here all go over HTTP to a remote server. Some of them require parsing of the output, or rely on the User-Agent header to make the server respond in plain text. They also change quite frequently (go down, change their name, put up ads, might change output format etc.). The DNS ...


21

You can do it with AWK. There are nicer ways to do it, but this is the simplest, I think. echo '192.168.1.1' | awk 'BEGIN{FS="."}{print $4"."$3"."$2"."$1".in-addr.arpa"}' This will reverse the order of the IP address. Just to save a few keystrokes, as Mikel suggested, we can further shorten the upper statement: echo '192.168.1.1' | awk -F . '{print ...


21

Just for curiosity value... using tac from GNU coreutils: given a variable ip in the form 192.168.1.1 then $(printf %s "$ip." | tac -s.)in-addr.arpa i.e. $ ip=192.168.1.1 $ rr=$(printf %s "$ip." | tac -s.)in-addr.arpa $ echo "$rr" 1.1.168.192.in-addr.arpa


20

Adding to @devnull's fine answer, IPv4 addresses can be represented in the following ways. Example This domain name, google.com, can be represented in the following ways: 74.125.226.4  (dotted decimal) 1249763844  (flat decimal) 0112.0175.0342.0004  (dotted octal) 011237361004  (flat octal) 0x4A.0x7D.0xE2.0x04  (dotted hex) 0x4A7DE204  (flat hex) ...


16

wget -O - -q http://whatismyip.org/


15

NOTES NIC device handles The examples below assume that the network interface is a wireless card named wlan0. Adjust this bit in the examples for your particular situation. For example if it's a wired NIC card, then it's likely eth0. IPv4 - (Internet Protocol version 4) Also these examples are returning the IPv4 address. the "dotted quad" that most ...


14

I believe the "modern tools" way to get your ipv4 address is to parse 'ip' rather than 'ifconfig', so it'd be something like: ip=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) or something like that.


14

You can use ifconfig.me as alternative to whatismyip.org. curl -s http://ifconfig.me Also ifconfig.me has some additional functional. To find out what else information you can receive visit the website.


13

This is not possible. If it were possible there would be no reason to have a netmask at all as it could be automatically determined. The netmask is used to specify the IP range a 'network' starts and stops at. This range is arbitrary. For example, with the IP address 192.168.0.140: With the netmask of 255.255.255.0 (/24 in cidr notation) the IP range would ...


13

What do the three rules do? Those 3 rules seem pretty self-explanatory: Reject incoming UDP packets with an ICMP message "port unreachable" Reject incoming TCP packets with "tcp reset" Reject incoming packets (of any other protocol) with ICMP message "protocol unreachable" If you're looking for more detail (about UDP/TCP packets, ICMP), you need to ...


13

If you want to use only shell (zsh, ksh93, bash), here's another way: IFS=. read w x y z <<<'192.168.1.1' printf '%d.%d.%d.%d.in-addr.arpa.' "$z" "$y" "$x" "$w" Or in plain old shell: echo '192.168.1.1' | { IFS=. read w x y z; echo "$z.$y.$w.$x.in-addr.arpa."; }


12

An IP address is just a number. One that - as I'm sure you know - uniquely identifies a computer on a network. But still just a number, which we will get back to. Let's take an example: 192.168.1.105 You'll notice that the IP address is broken up into four parts: {192, 168, 1, 105}. And you probably also know that each of those parts can have a value from ...


12

There was a time when IANA only assigned ports up to 1023. See RFC1700. At one time this was a standard. Most of the time I have no trouble finding when things change in the stream of RFC's but for the question of changing ports from 1024 to 49152 from registered to assigned I came up short. In terms of Linux history, there was a question raised about the ...


12

Some (but not all) reasons: In order to host multiple SSL sites as already mentioned Because you may be consolidating services from multiple hosts and you need to preserve the addresses In order to use an IP address that can later be transferred to another host To compensate for a host that's down at that moment by adding its IP address to another one If ...


11

You have the symptoms of an MTU problem: some TCP connections freeze, more or less reproducibly for a given command or URL but with no easily discernible overall pattern. A telltale symptom is that interactive ssh sessions work well but file transfers almost always fail. Furthermore pppoe is the number one bringer of MTU problem for home users. So I ...


10

The command is the easy part, the difficult part is having access to a database. For example, Ubuntu has a free database with a command line query tool (geoiplookup) in the geoip-bin package. But it only shows country information, and uses a static (hence out-of-date) database. This tool can also query the MaxMind GeoIP database, if you have a subscription ...


10

"IP forwarding" is a synonym for "routing." It is called "kernel IP forwarding" because it is a feature of the Linux kernel. A router has multiple network interfaces. If traffic comes in on one interface that matches a subnet of another network interface, a router then forwards that traffic to the other network interface. So, let's say you have two NICs, ...


10

ifconfig is from net-tools, which stopped being developed in '99, though some distros still patch it internally. It also still uses ioctl for network configuration, which is an ugly and less powerful way of interacting with the kernel. A lot of changes in Linux networking code, and a lot of new features aren't accessible using net-tools: multipath routing, ...


9

You can with the ip command, and given that ifconfig is in the process of being deprecated by most distributions it's now the preferred tool. An example: $ ip route show 212.13.197.0/28 dev eth0 proto kernel scope link src 212.13.197.13 default via 212.13.197.1 dev eth0


9

Right click on the Network Manager icon on Ubuntu top panel and select edit. Go to Wired Network or Wireless Network tab and select the network name. Click on the edit button and go to IPv4 settings tab on the new window. If the method is Automatic (DHCP) you are using dhcp. Other method is cat /var/log/syslog and check for some thing like below ...


8

Maybe setup smokeping on the Linux side, and point it at your AP? Smokeping will periodically (configurable) send -20 pings at the same time, and then graph how how many returned and the range of times that they returned in. If you have a lot of dropped packets, or the really wide range, then you should be concerned. If you want to run smokeping you ...


8

There is ip route get 74.125.137.100 but it doesn't do hostname resolution (which I think is a good thing). The command is usually available from iproute or iproute2 packages.


8

You can use netstat's -p option. You're already issuing it, but to get process information, you need to be the superuser: $ sudo netstat -nlp | grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 125004/nginx


8

The host utility explicitly queries DNS servers, and does not consult the /etc/hosts file. If you were to traceroute or ping that address, you would see it correctly resolve. You do not want to change localhost to map to anything other than 127.0.0.1, this can have strange and subtle effects on many things. I think that /etc/hosts is parsed in the order ...


8

Easily with Perl, thusly: $ echo 192.168.1.1|perl -nle 'print join ".",reverse(split /\./,$_)' 1.1.168.192


7

netcat icanhazip.com 80 <<< $'GET / HTTP/1.1\nHost: icanhazip.com\n\n' | tail -n1



Only top voted, non community-wiki answers of a minimum length are eligible