2010년 2월 2일 화요일

Debian networkng setup -

debian administration 에서 찾은 내용임


An introduction to Debian networking setup

Posted by Steve on Sun 25 Sep 2005 at 13:32

Under Debian networking is pretty comparable to other distributions of GNU/Linux, especially in areas such as DNS setup. However if you're new to the distribution you might not know where things are set. This brief introduction to networking will show you how it works.

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.

As an user you can see your current hostname with:

skx@lappy:~$ /bin/hostname 
lappy

To set the hostname directly you can become root and run:

/bin/hostname newname

When 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.

Setting up DNS

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.

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)

Setting up your IP address.

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:

man interfaces

A 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.255

Here 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:

/etc/init.d/networking restart
Setting your default gateway.

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 eth0

Alternatively 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.1

Once 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

댓글 없음:

댓글 쓰기