Network tips

From XennisWiki
Jump to: navigation, search

Network tips for Linux.

Basics

Resolving an IP locally

Open /etc/hosts file and add the line

100.000.000.00 my.example.org

Usage for instance with ping: ping my.example.org.

Get entries from local name resolution

getent hosts

Configuration

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: 127.0.1.1 <hostname>
    • Arch Linux: 127.0.1.1 <hostname>.localdomain <hostname>
  • Restart the hostname service
    • Debian: /etc/init.d/hostname.sh 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:

127.0.0.1    localhost
127.0.0.1    ::1
127.0.1.1    <hostname>.localdomain <hostname>

On Debian:

127.0.0.1    localhost
127.0.1.1    <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