the IP protocol and IP addresses

learn more… | top users | synonyms

56
votes
16answers
42k views

How can I get my external IP address in bash?

I need to find my external IP address from a bash script. At the moment I use this function: myip () { lwp-request -o text checkip.dyndns.org | awk '{ print $NF }' } But it depends on ...
44
votes
2answers
5k views

How does SSH connection survive a network restart?

From a Linux SSH shell, type /etc/init.d/network restart to restart the network service. I expect my SSH connection to die since the network service goes down. But it doesn't. Very cool. But how does ...
32
votes
2answers
2k views

How is it that missing 0s are automatically added in IP addresses? (`ping 10.5` equivalent to `ping 10.0.0.5`)

I accidentally typed ssh 10.0.05 instead of ssh 10.0.0.5 and was very surprised that it worked. I also tried 10.005 and 10.5 and those also expanded automatically to 10.0.0.5. I also tried ...
20
votes
1answer
5k views

Why doesn't Linux use the IANA Ephemeral port range?

According to Wikipedia The Internet Assigned Numbers Authority (IANA) suggests the range 49152 to 65535 for dynamic or private ports. Many Linux kernels use the port range 32768 to 61000. Even ...
16
votes
6answers
14k views

How to get my own IP address and save it to a variable in a shell script?

How can I get my own IP address and save it to a variable in a shell script?
16
votes
2answers
3k views

Is there an easy way to programmatically extract IP address?

Is there an easy way to programmatically extract IP address, without tedious parsing of ifconfig? I would not mind simple command output processing using sed to do it but not processing multiline ...
12
votes
2answers
2k views

IP to Country console command

Is there a console command that takes an IP address as an input and shows its geographical information like city, country, ISP, etc.?
11
votes
1answer
3k views

Is it better to set -j REJECT or -j DROP in iptables?

There's an example of iptables rules on archlinux wiki: # Generated by iptables-save v1.4.18 on Sun Mar 17 14:21:12 2013 *filter :INPUT DROP [0:0] :FORWARD DROP [0:0] :OUTPUT ACCEPT [0:0] :TCP - ...
10
votes
3answers
2k views

Parsing log files for frequent IP's

So, I hacked this together while undergoing a DDOS attack to pull naughty ips out of my logs. Anyone have any improvements or other suggestions to make it better? Here's the general idea: pull ...
10
votes
3answers
15k views

How to find out if Ubuntu is using DHCP (Ubuntu 12.04 LTS GUI)

How can I find out if my IP address is DHCP, Fixed or Dynamic? I need to tell my network administrator what the IP address is, that my Virtual Machine is using. I know the numbers, but I don't know ...
10
votes
1answer
334 views

Linux: Is there handy way to exec a program binding it to IP-address of choice?

In FreeBSD 4.9 it was very easy to accomplish with just a single command like jail [-u username] path hostname ip-number command if path was / you had running just the same program as usual but ...
10
votes
1answer
5k views

Linux always send ICMP redirect

I have several Debian Squeeze (6.0.6 up to date) used as routers. When a link is down, they send ICMP redirects to local hosts. This is the default behaviour of Debian and several others. So once the ...
9
votes
1answer
20k views

Using ip addr instead of ifconfig reports “RTNETLINK answers: File exists” on Debian

I have a Debian system working as a wireless router with eth0 and wlan0. Now I added an additional network manually on eth1 with ifconfig: alix:~# ifconfig eth1 192.168.0.2 netmask 255.255.255.0 ...
9
votes
3answers
4k views

Can't access select https sites on Linux over PPPoE

My internet connection used to be a direct LAN connection to my provider. Back then, everything would load fine on both Windows and Ubuntu (dual boot). However, a while ago they started needing me to ...
9
votes
3answers
16k views

Why are my two virtual machines getting the same IP address?

I have two virtual machines both running on a Linux host (Fedora 16). I set both adapters as attached to NAT. When I boot them up they both have their default gateway set to 10.0.2.2. They also ...
9
votes
1answer
394 views

Send a packet over the network even when its target is the local host

Under Linux if you send a packet to the address of one of its network interfaces, this packet is routed internally, it is never sent over the network. That's the right thing in 99.99% of the cases. ...
8
votes
2answers
1k views

Measuring internet connection quality

I'm having WLAN trouble on my dualbooting win/linux laptop - the connection on linux side has occasional trouble, and seems somewhat slow and chunky. I would try to fix this issue by fiddling with all ...
8
votes
4answers
15k views

How to find the IP address of a KVM Virtual Machine, that I can SSH into it?

I have follow this guide (Virtualization With KVM On Ubuntu 11.10) to setup my KVM (Virtual Machines Software) on my Ubuntu 11.10 Server. However, I didn't setup my VM's IP address when creating the ...
8
votes
1answer
2k views

Change remote host IP address without losing control (Linux)

How can I change a remote host primary IP address without getting disconnected at all (without being in a "no IP addr" state). The matter is poorly discussed on Internet (according to my research). ...
8
votes
2answers
10k views

How can I block a range of IP addresses with an Amazon EC2 instance?

I know a certain range of IP addresses are causing problem with my server, 172.64.*.* what is the best way to block access to my Amazon EC2 instance? Is there a way to do this using security groups or ...
8
votes
2answers
2k views

How can I disable TCP/IP for an Ethernet adapter?

I have CentOS 6.3 running in a (virtual) machine with two Ethernet adapters. I have eth0 connected to a TCP/IP LAN and eth1 connected to a DSL modem. The system is intended as a dedicated ...
7
votes
3answers
5k views

What's the last number in this ip address?

An IP address like this 223.248.0.0/24 or 223.248.0.0/16 What's the last number mean in the IP address (24 or 16 in the above example)? Is there a simple way to understand how to set the number ...
7
votes
2answers
555 views

Identical MAC address on two different VM, yet I have internet connectivity

I have set up a network as such: Set up host-only networking on VirtualBox. The first adapter is configured with NAT, the second with host-only networking HOST: Windows GUEST: CentOS VM1, CentOS VM2 ...
7
votes
4answers
26k views

How do I know what service is running on a particular port in linux?

I am trying to run weblogic server on my linux machine and I am getting the following error : ERROR: transport error 202: bind failed: Address already in use ERROR: JDWP Transport dt_socket failed to ...
7
votes
7answers
2k views

Assigning IP address to environment variable [duplicate]

How can I assign the IP address of eth0 to an environment variable, say $ip, as easily as possible? Update: Distro is Ubuntu Server 12.04 LTS.
7
votes
2answers
526 views

SSH session through OpenVPN cuts off / locks up after a few lines

I have a large number of identical fanless PCs running debian 6 (ARM). Most of these are connected via comcast and work ok. There are some that are connected to 'WiMax' modems and are having ...
6
votes
3answers
2k views

Difference between 'ifconfig' and 'ip' commands

I read some articles/tutorials on 'ifconfig' command, most of them included a common statement - "ifconfig is deprecated by ip command" and suggested to learn ip command. But none of them ...
6
votes
4answers
22k views

How to remove all default gateways

I'm running a custom built linux machine, so not all linux commands are available. I execute network related commands, so I need to set a default gateway right before I run my command, then remove ...
6
votes
2answers
14k views

show gateway IP address when performing ifconfig command

Currently, when using the ifconfig command, the following IP addresses are shown: own IP, broadcast and mask. Is there a way to show the related gateway IP address as well (on the same screen with ...
6
votes
3answers
767 views

What are the benefits of using several IP addresses on a server?

With ifconfig, I am able to configure multiple IP addresses on a single network interface card. Why would I want to do that and how would I later utilize several addresses, e.g. how does software know ...
6
votes
3answers
36k views

How can I know if IP Multicast is enabled

I have scripts that run IP multicast tests; however, my scripts are failing on a particular linux machine. I know that I can look at CONFIG_IP_MULTICAST in the kernel configuration file to determine ...
6
votes
1answer
11k views

What is kernel ip forwarding?

I have seen on many blogs, using this command to enable IP forwarding while using many network security/sniffing tools on linux echo 1 > /proc/sys/net/ipv4/ip_forward Can anyone explain me in ...
6
votes
4answers
2k views

History of IP addresses that accesed a server via ssh

It has come to my attention that a server of mine has been hacked and infected with a known chinese botnet. It was a prototype/testing virtual machine with its own static IP(US address) so no harm ...
6
votes
2answers
4k views

How to build a gateway from my Linux OS

I want to configure my Linux so that it will be used as a network router (gateway). Can anybody give me some hints on this? (links are welcome!)
6
votes
2answers
541 views

Static IP for 2 PCs on crossover cable in interfaces(5) file?

I've got 2 PCs connected on an Ethernet crossover cable. On PC1 I run: sudo ip addr add 192.168.2.1 peer 192.168.2.2 dev eth0 sudo ip link set dev eth0 up On PC2 I run: sudo ip addr add ...
6
votes
3answers
704 views

How does one capture traffic on virtual interfaces?

I would like to capture traffic on Linux virtual interfaces, for debugging purposes. I have been experimenting with veth, tun and dummy interface types; on all three, I am having trouble getting ...
6
votes
1answer
630 views

Load Balancer Solution with linux

I need a suggestion to realize a proper solution to this problem: As you can see in the image above, I have 2 application servers that need to talk with and external third party provider over the ...
6
votes
3answers
378 views

SpamAssassin Under Linux VPS

I am getting bald with this guys: On a Linux VPS (CentOS), I have setup a mail server (Exim+Dovecot+Clamav+SpamAssassin) but scanning mail for spam using SpamAssassin is proving to be a challenge. I ...
5
votes
3answers
1k views

How can I get the netmask from an IP address?

How do I get a netmask from the IP address? Is there a command to get it?
5
votes
3answers
6k views

How can I restart a network interface?

How can I restart a network interface? I have a vm that doesn't update its IP address correctly when switching between home and work. The vm runs Ubuntu server and uses a bridged network adapter.
5
votes
2answers
3k views

Can't ping broadcast

We're running four computers connected to a hub (yes a hub not a switch) on Fedora 13. They were installed using images from a colleague that has recently left us to go back to school, they may have ...
5
votes
5answers
11k views

How to route specific adresses through a tunnel?

There are certain websites/services which I can only access from the subnet on which my server is located (think of the typical intranet scenario). Is there a way to transparently route traffic that ...
5
votes
1answer
155 views

bash_completion rule for resolving ip into hostnames

I am trying to create a bash_completion rule for my script rmpxe. This script takes <hostname> as its only argument. It then resolves this hostname into <ip_address> and removes the ...
5
votes
1answer
2k views

avoid IPv6 link local address on interface

I have a setup with virtual Xen hosts connected to a set of VLAN-s. On Dom0, I have set up a bridge for each of my VLAN-s to connect DomU-s to. Bridges are set up in /etc/network/interfaces like ...
5
votes
3answers
3k views

How to filter IPv4 and IPv6 addresses?

echo "1.1.1.1" | awk '/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/ {print $1}' How can I filter IPv4 addresses in a script, and how can I filter IPv6 addresses. I mean more precisely then this so the oneliner ...
5
votes
2answers
2k views

Routing for multiple uplinks/providers

I have a PC with two internet connections. The first one is an Ethernet interface to connect to my local network and access internet via my router. The second one use a GSM modem to connect with ppp. ...
4
votes
6answers
780 views

Find my computer on a LAN network

Let's say that I have a computer plugged in to a local network using a dhcp connection, so it will get a different IP every time. Is there a way to find this computer (so the IP) from a different ...
4
votes
2answers
2k views

SSH to a remote computer having only the public IP

Is it possible to connect to a computer behind a router via SSH knowing only the public IP address (of the router)?
4
votes
2answers
2k views

How to know if a network interface is tap, tun, bridge or physical?

As far as i know, there are 4 main types of network interfaces in linux: tun, tap, bridge and physical. When i'm doing sys admin on machines running KVM, i usually come accross tap, bridge and ...
4
votes
1answer
84 views

Create map network_iface_name <--> IPv4 address

I'd like to implement a bash script that creates a mapping between the network cards (or interfaces) names in my computer and their IP address (in CIDR format, if possible). The goal is having ...