http://dsin.blogspot.com/2008/10/ubuntu-fix-ip.html
แก้ไฟล์ /etc/network/interfaces
จะยัดกี่ ip ลงในเครื่องก็ยัดไป [ เราสามารถใช้ eth0:0, eth0:1, eth0:2, eth0:N (ได้มากสุด 254). ( ref ) ]
NOTE : gateway คือ IP address ของ router เช่น ถ้าเป็น linksys default คือ 192.168.1.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| auto loiface lo inet loopbackauto eth0iface eth0 inet staticaddress 192.41.170.105netmask 255.255.255.0dns 192.41.170.15gateway 192.41.170.23auto eth0:1iface eth0:1 inet staticaddress 192.41.170.101netmask 255.255.255.0auto eth0:2... |
หลังจากนั้น
1
| $ sudo /etc/init.d/networking restart |
ถ้าเป็น DHCP, ดูตัวอย่างข้างล่าง
1
2
3
4
5
6
7
8
9
10
| auto loiface lo inet loopback# primary network interfaceauto eth0iface eth0 inet dhcp# address 192.168.122.2# netmask 255.255.255.0# network 192.168.122.0 |
ถ้าเป็น printer หรืออะไร ที่มันต้อง fix ip
ก็ fix ip ที่ไม่อยู่ในช่วง DHCP
แต่ต้อง Subnet Mask และ Default Gateway เดียวกัน
เช่น ถ้าของ linksys ก็ใส่เป็น 192.168.1.2, 192.168.1.3, ... ต่อจาก 192.168.1.1 ซึ่งเป็น ip ของ router ได้เลย
ถ้า fix ip แล้วมีปัญหา แบบว่า เข้าทาง dns ไม่ได้ แต่เข้าทาง ip ได้
error ประมาณนี้
1
| ping: unknown host |
ให้ลองเข้าไปเช็ค ไฟล์ /etc/resolv.conf ซึ่งเป็นที่เก็บ dns ว่า มันชี้ไปที่ router หรือไม่
ถ้าไม่มี ก็ใส่ลงไปซะ
/etc/resolv.conf
NOTE : ถ้า เป็น DHCP เจ้าตัว NetworkManager จะเป็นคนเขียนไฟล์นี้ขึ้นมาเอง โดยไปเอามาจาก DNSServer ของ router น้ะจ้ะ
ref : watchingthenet
ถ้าไม่มี ก็ใส่ลงไปซะ
/etc/resolv.conf
1
2
| # Generated by NetworkManagernameserver 192.168.1.1 |
NOTE : ถ้า เป็น DHCP เจ้าตัว NetworkManager จะเป็นคนเขียนไฟล์นี้ขึ้นมาเอง โดยไปเอามาจาก DNSServer ของ router น้ะจ้ะ
ref : watchingthenet