Debian Networking Basic
Hostname
mydebian2:~# cat /etc/hostname
mydebian2
Name Resolution
mydebian2:~# cat /etc/hosts
|
127.0.0.1 localhost 10.10.10.2 mydebian2.mydomain.int mydebian2
# 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 ff02::3 ip6-allhosts
|
mydebian2:~# cat /etc/resolv.conf
|
search mydomain.int nameserver 203.144.255.71 nameserver 203.144.255.72
|
Network Interfaces
mydebian2:~# nano /etc/network/interfaces
|
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5).
# The loopback network interface auto lo iface lo inet loopback
# The primary network interface
# Comment บรรทัดด้านล่าง ไม่ใช้ hotplug # allow-hotplug eth0
# เพิ่มบรรทัดด้านล่าง เพื่อให้สามารถใช้คำสั่ง /etc/init.d/networking จัดการได้ auto eth0 iface eth0 inet static address 10.10.10.2 netmask 255.0.0.0 # ในความคิดผม 2 บรรทัดด้านล่างนี้ (networkและ broadcast)ไม่น่าจะต้องใช้ก็ได้ network 10.0.0.0 broadcast 10.255.255.255 gateway 10.0.0.2 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 203.144.255.71 dns-search mydomain.int
|
หลังจากที่มีการแก้ไขค่าใน /etc/network/interfaces เสร็จแล้ว ใช้คำสั่ง
mydebian2:~# /etc/init.d/networking restart
ถ้าใช้ DHCP จะมีการกำหนดดังนี้
# 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
|
ถ้าต้องการกำหนดหมายเลขไอพีเพิ่มให้กับให้กับการ์ดแลนอันเดียวกัน
auto eth0:1
iface eth0:1 inet static
address 10.10.10.11
netmask 255.0.0.0
|
ติดตั้ง iproute
สำหรับท่านที่ต้องการจัดการค่ากำหนดทางด้านเครือข่ายโดยใช้ คำสั่ง ip ท่านต้องติดตั้ง iproute
mydebian2:~# aptitude install -y iproute
ปิดการใช้งาน IPv6
ถ้าท่านต้องการปิดการใช้งาน IPv6 (ซึ่งปกติตอนนี้ก็ยังไม่ได้ใช้อยู่แล้ว) ให้ท่านแก้ไขไฟล์ /etc/modprobe.d/blacklist แล้วเพิ่มบรรทัด
blacklist ipv6
|
mydebian2:~# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:BF:57:98 inet addr:10.10.10.2 Bcast:10.255.255.255 Mask:255.0.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:141 errors:0 dropped:0 overruns:0 frame:0 TX packets:127 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:12963 (12.6 KiB) TX bytes:30701 (29.9 KiB) Interrupt:185 Base address:0×1400
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:BF:57:98 inet addr:10.10.10.11 Bcast:10.255.255.255 Mask:255.0.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:185 Base address:0×1400
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
|
ข้อมูลเพิ่มเติม
man interfaces
man ifconfig
man ip