Meniu

Network config files in Linux

In most cases, the DNS configuration is stored within /etc/resolv.conf. To add a DNS server, you can simply add a line “namespace 123.123.123.123? in /etc/resolv.conf (assuming you want to use 123.123.123.123 as your DNS Server):

nameserver 123.123.123.123

However, some distributions use a dynamic DNS configuration (dynamic resolv.conf). When this is the case, /etc/resolv.conf is overwritten automatically by a deamon at boot time. A comment in /etc/resolv.conf indicates:

DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTENIf you change the content of /etc/resolv.conf it will be lost next time your reboot. If this is the case, edit the file /etc/resolvconf/resolv.conf.d/base instead of /etc/resolv.conf. At boot time, the deamon will append the file

/etc/resolvconf/resolv.conf.d/base to the newly generated /etc/resolv.conf and it will contain your configuration.
/etc/hosts

In /etc/hosts you can give nicknames to some IP addresses. Your network tools and applications will check this file before querying the DNS servers configured in /etc/resolv.conf. Here is a typical /etc/hosts file:

127.0.0.1 localhost
192.168.1.4 something
192.168.1.5 stuff

Thanks to this file things like “telnet something” are equivalent to “telnet 192.168.1.4?. You don’t have to remember any IP address on your network anymore.

/etc/hostname

This file contains the hostname of your computer.

/etc/network/interfaces

This is probably the most important file of all when it comes to configuring the network. It contains the list of network interfaces and their configuration. Here is an example:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 192.168.1.4
netmask 255.255.255.0
gateway 192.168.1.1
wireless-essid galaxy

A lot of things can be configured within /etc/network/interfaces. If you’re looking for specific settings you can have a look at the man pages:

man interfaces

The most common settings are as follow:

auto, followed by the name of an interface, indicates that Linux should connect this device at startup.

iface, followed by the name of an interface, indicates the configuration of the interface. After iface, we find the type of addressing (dhcp or static). If the type of addressing is static, then further details are required, such as address (the IP address used by the interface) and netmask. The address of the router can also be given if it acts as a default gateway by specifying gateway.

If the interface is wireless (i.e. it appears in iwconfig), you can specify the essid with wireless-essid, the type of network (for instance “managed“) with wireless-mode and the WEP key (if any) with wireless-key.

Mirela

Zona de mobile
  • | 34 articole

Nici un comentariu inca. Fii primul!
  • powered by Verysign