Most likely there are only four things you will care about:
- Setting up your hostname
- Setting up DNS.
- Setting up your IP address.
- Setting your default gateway.
Setting your hostname
Setting up your hostname upon a Debian installation is very straightforward. You can directly query, or set, the hostname with the hostname command.Setting up DNS
As an user you can see your current hostname with:
skx@lappy:~$ /bin/hostname lappyTo set the hostname directly you can become root and run:
/bin/hostname newnameWhen your system boots it will automatically read the hostname from the file /etc/hostname - so if you wish to make a permanent change then you should edit that file, and your change will then be made at bootup time automatically.
When it comes to DNS setup Debian doesn't differ from other distributions. You can add hostname and IP addresses to the file /etc/hosts for static lokups.Setting up your IP address.
To cause your machine to consult with a particular server for name lookups you simply add their addresses to /etc/resolv.conf.
For example a machine which should perform lookups from the DNS server at IP address 192.168.1.1 would have a resolv.conf file looking like this:
search my.flat nameserver 192.168.1.1(Here the search my.flat causes lookups of hostnames to have my.flat appended to them. So lappy would be looked up as lappy.my.flat)
The IP addresses associated with any network cards you might have are read from the file /etc/network/interfaces. This file has documentation you can read with:Setting your default gateway.
man interfacesA sample entry for a machine with a static address would look something like this:
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 192.168.1.90 gateway 192.168.1.1 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255Here we've setup the IP addresss (192.168.1.90), the default gateway (192.168.1.1), and the netmask.
For a machine running DHCP the setup would look much simpler:
# The loopback network interface auto lo iface lo inet loopback # The primary network interface - use DHCP to find our address auto eth0 iface eth0 inet dhcp(If you're using a DHCP based setup you must have a DHCP client package installed - usually one of pump or dhcp-client.)
If you make changes to this file you can cause them to take effect by running:
If you read the previous section then you'll see that the default route for a host with a static IP address can be set in /etc/network/interfaces.
If you wish to view your current default route/gateway then you can run:
lappy:~# netstat -nr Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0Alternatively you can use the route command:
lappy:~# /sbin/route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 * 255.255.255.0 U 0 0 0 eth0 default router 0.0.0.0 UG 0 0 0 eth0(Here the see the hostname router instead of the IP address 192.168.1.1 - to avoid that run "/sbin/route -n").
To change your default route you must first remove the current one:
/sbin/route del default gw 192.168.1.1Once this has done you'll have no gateway and be unable to talk to non-local hosts.
Add the new route with :
/sbin/route add default gw 192.168.1.100