สำนักวิทยบริการและเทคโนโลยีสารสนเทศ (สวส.)

Office of Academic Resources and Information Technology

 

การตั้งค่า IP Address ของเครื่อง บน Debian

The network interface with the static IP

The network interface served by the static IP is configured by creating the configuration entry in the "/etc/network/interfaces" file as the following.
allow-hotplug eth0
iface eth0 inet static
 address 192.168.11.100
 netmask 255.255.255.0
 gateway 192.168.11.1
 dns-domain example.com
 dns-nameservers 192.168.11.1
When the Linux kernel detects the physical interface eth0, the allow-hotplug stanza causes ifup to bring up the interface and the iface stanza causes ifup to use the static IP to configure the interface.
Here, I assumed the following.
  • IP address range of the LAN network: 192.168.11.0 - 192.168.11.255
  • IP address of the gateway: 192.168.11.1
  • IP address of the PC: 192.168.11.100
  • The resolvconf package: installed
  • The domain name: "example.com"
  • IP address of the DNS server: 192.168.11.1
When the resolvconf package is not installed, DNS related configuration needs to be done manually by editing the "/etc/resolv.conf" as the following.
nameserver 192.168.11.1
domain example.com
[Caution] Caution
The IP addresses used in the above example are not meant to be copied literally. You have to adjust IP numbers to your actual network configuration.

The loopback network interface

The following configuration entry in the "/etc/network/interfaces" file brings up the loopback network interface lo upon booting the system (via auto stanza).
auto lo
iface lo inet loopback
This one always exists in the "/etc/network/interfaces" file.

The DHCP connection with the Ethernet

The typical modern home and small business network, i.e. LAN, are connected to the WAN (Internet) using some consumer grade broadband router. The LAN behind this router is usually served by the dynamic host configuration protocol (DHCP) server running on the router.
 
Just install the isc-dhcp-client package for the Ethernet served by the dynamic host configuration protocol (DHCP).

The network interface served by the DHCP

After preparing the system  The DHCP connection with the Ethernet,  the network interface served by the DHCP is configured by creating the configuration entry in the "/etc/network/interfaces" file as the following.
allow-hotplug eth0
iface eth0 inet dhcp
When the Linux kernel detects the physical interface eth0, the allow-hotplug stanza causes ifup to bring up the interface and the iface stanza causes ifup to use DHCP to configure the interface.
 
ที่มา http://www.debian.org/doc/manuals/debian-reference/ch05.en.html