Tuesday, May 14, 2013

วิธีเปลี่ยน IP จากแบบ DHCP เป็น static IP

1) เปิดไฟล์ /etc/network/interfaces ขึ้นมา
sudo vi /etc/network/interfaces

2) มองหาบรรทัด
auto eth0
iface eth0 inet dhcp
ให้เราแก้จาก dhcp เป็น static แล้วใส่รายละเอียดต่างๆ เกี่ยวกับ network ที่เราใช้งานอยู่ ตัวอย่างเช่น
auto eth0
iface eth0 inet static
        address 192.168.1.100
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
        dns-nameservers 192.168.10.9 129.168.20.103

3) ลบ configuration ไฟล์ที่ใช้สำหรับสร้าง resolv.conf
sudo rm /run/resolvconf/interface/eth0.dhclient
sudo rm /run/resolvconf/interface/original.resolvconf

4) Uninstall DHCP client
sudo apt-get remove isc-dhcp-client

5) ทำการ restart network
sudo nohup sh -c "ifdown eth0 && ifup eth0"

6) ตรวจสอบ IP
ifconfig eth0 | grep 'inet addr'

No comments:

Post a Comment