Tag Info

Hot answers tagged

53

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 ...


52

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 ...


43

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


40

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 ...


38

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


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

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.


16

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


16

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.


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 ...


15

Sorry but I got it myself. I had to flush the device before bringing it up: alix:~# ip addr flush dev eth1


15

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 ...


14

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 ...


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

This is one of those things that surprises people because it goes against what they've been taught. 2 machines with the same hardware mac address on the same broadcast domain can talk to each other just fine as long as they have different IP addresses (and the switching gear plays nice). Lets start with a test setup: VM1 $ ip addr show dev enp0s8 3: ...


12

"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, ...


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

ifconfig is from net-tools, which hasn't been able to fully keep up with the Linux network stack for a long time. 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 ...


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 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


11

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 ...


11

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


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

Starting the process inside a network namespace that can only see the desired IP address can accomplish something similar. For instance, supposed I only wanted localhost available to a particular program. First, I create the network namespace: ip netns add limitednet Namespaces have a loopback interface by default, so next I just need to bring it up: ...


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

You do not need more that one MAC address to have multiple ip addresses on a single network interface. This technique is called ip aliasing. Each operative system has a slightly different syntax but usually, to set different IP addresses on the same interface, you need only to do something like: ifconfig eth0 192.168.100.200 netmask 255.255.255.0 ifconfig ...


8

It seems the most kernels(post v1) do support multicast by default or have CONFIG_IP_MULTICAST enabled while compiling. To check whether the compiled and running kernel subscribes to any multicast group, I would use netstat -g. It seems the most kernels(post v1) do support multicast by default. [root@centos module]# grep CONFIG_IP_MULTICAST ...


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

If you use ip instead of route, you could simply run: ip route del 0/0 I believe that catches all default routes.



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