:::

10. 修改網卡及ip等資訊

如果主機要換IP,或者這是做好的虛擬機檔案,想要複製在開另一臺機器,那必然會遇到改IP的需求。

先找出有啟動的網卡,如 eth0

ifconfig -a

修改網卡及ip等資訊

vi /etc/network/interfaces

底下的IP、閘道器、DNS...等請自行視情況修改

auto lo eth0
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
        address 120.115.2.90
        netmask 255.255.255.0
        network 120.115.2.0
        broadcast 120.115.2.255
        gateway 120.115.2.253
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 163.26.1.1
        dns-search tn.edu.tw
iface eth0 inet6 static
        address 2001:288:7201:2::90
        netmask 64
        gateway 2001:288:7201:2::fffe

更簡易的寫法:

auto lo eth0
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
        address 120.115.2.90/24
        gateway 120.115.2.253
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 163.26.1.1
        dns-search tn.edu.tw
iface eth0 inet6 static
        address 2001:288:7201:2::90
        netmask 64
        gateway 2001:288:7201:2::fffe

修改 /etc/hosts(一樣請自行修改IP及網址)

vi /etc/hosts
127.0.0.1       localhost
120.115.2.90    campus-xoops.tn.edu.tw  

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

修改hostname

vi /etc/hostname

將內容改為主機名稱,如:campus-xoops,接著在手動改一下(立即呈現)

hostname  campus-xoops

查詢主機版本以及hostname

uname -a

修改DNS設定

vi /etc/resolv.conf
search campus-xoops.tn.edu.tw
nameserver 163.26.1.1

重啟網路

service networking restart

這樣IP就改好了!


:::

書籍目錄

展開 | 闔起

http%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D15%26tbdsn%3D225

計數器

今天: 732732732
昨天: 2262226222622262
總計: 7519768751976875197687519768751976875197687519768