Network tips

From XennisWiki
Jump to: navigation, search

Network tips for Linux.


Resolving an IP locally

Open /etc/hosts file and add the line

Usage for instance with ping: ping

Get entries from local name resolution

getent hosts


Set the hostname

  • The hostname is defined in the /etc/hostname file. The files contains only a single line with the hostname. Add or change the name here.
  • Alternatively use hostnamectl set-hostname <hostname> to change the hostname.

Local hostname name resolution

  • Change the /etc/hosts accordingly your hostname by adding the line
    • Debian: <hostname>
    • Arch Linux: <hostname>.localdomain <hostname>
  • Restart the hostname service
    • Debian: /etc/init.d/ restart
  • Check the changes by getting the entries from local name resolution

Set the local name resolution

The name resolution is set in /etc/hosts.

On Arch Linux:    localhost    ::1    <hostname>.localdomain <hostname>

On Debian:    localhost    <hostname>

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

See also