Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Allow a remote IP for incoming connection in UFW (Uncomplicated firewall)

Answer:

To allow a remote IP for incoming connection in Ubuntu's UFW (Uncomplicated firewall), you can use the following command:

# sudo ufw allow from x.x.x.x

Of course you need to reload the firewall.

# sudo ufw reload

Send ARP REQUEST to a neighbour host in Linux

Answer:

The arping command allow you to Ping destination on device interface by ARP packets, using source address source.

E.g.

# arping -U 192.168.1.5

The above command send an Unsolicited ARP request to update neighbours' ARP caches.

What is the difference between ip address 0.0.0.0 and 127.0.0.1?

Answer:

Sometimes when using the netstat command, which print out something like

# netstat -ntpl
(No info could be read for "-p": geteuid()=1001 but you should be root.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      -
...

What is the real meaning of 0.0.0.0?

In fact, this special IP means "all the IP addresses on the local machine". So if you have seen a service listening on 0.0.0.0, it means you can connect to the service using any IP addresses of the machine.

Simple file encryption with OpenSSL

Answer:

You have a single file (input.txt), and you want to encrypt it with a password, it is easy with OpenSSL.

# openssl aes-128-cbc -salt -in input.txt-out input.aes

Enter the password twice.

When you want to decrypt it, use the command.

# openssl aes-128-cbc -d -salt -in input.aes -out output.txt

How to transfer your identity.pub to the remote machine’s authorized_keys?

Answer:

While you can ssh into the remote machine and edit the authorized_keys file, it is easier with the following command.

# ssh-copy-id -i identity-rsa-dsa.pub user@remote-server