第一種:臨時修改ip,重啟失效!
[root@localhost ~]# ifconfig eth0 192.168.1.108
第二種:永久修改ip
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
下面是進入了ifcfg-eth0 的內容
device=eth0
hwaddr=00:0c:29:23:85:67
type=ethernet
uuid=2c0fcf68-5842-44a8-a1ad-b5d2723cceab
onboot=yes 這個要啟動
nm_controlled=yes
bootproto=none 動態dhcp 靜態static 我習慣打none
ipaddr=192.168.1.108 設定ip就以192.168.1.108為例子
netmask=255.255.255.0 掩碼
gateway=192.168.1.1 閘道器.
退出儲存
[root@localhost ~]# service network restart
正在關閉介面 eth0: [確定]
關閉環迴介面: [確定]
彈出環迴介面: [確定]
彈出介面 eth0: determining if ip address 192.168.1.108 is already in use for device eth0...
[確定]
重啟網絡卡成功
[root@localhost ~]# ifconfig
eth0 link encap:ethernet hwaddr 00:0c:29:23:85:67
inet addr:192.168.1.108 bcast:192.168.1.255 mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe23:8567/64 scope:link
up broadcast running multicast mtu:1500 metric:1
rx packets:1806 errors:0 dropped:0 overruns:0 frame:0
tx packets:1674 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
rx bytes:169776 (165.7 kib) tx bytes:288114 (281.3 kib)
lo link encap:local loopback
inet addr:127.0.0.1 mask:255.0.0.0
inet6 addr: ::1/128 scope:host
up loopback running mtu:16436 metric:1
rx packets:40 errors:0 dropped:0 overruns:0 frame:0
tx packets:40 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
rx bytes:4776 (4.6 kib) tx bytes:4776 (4.6 kib)
下面就是設定dns了
[root@localhost ~]# vi /etc/resolv.conf
打上 nameserver dns的ip位址
儲存完成!
關於Centos轉殖之後的修改網路和ip
解決虛擬機器的網路問題 需要注意的地方 需要在 vim etc udev rules.d 70 persistent net.rules 用vim開啟70 persistent net.rules檔案,可以看到有兩個網絡卡的配置檔案,eth0和eth1。eth0的就是源虛擬機器的配置,eth1的是轉...
linux下修改ip位址,預設閘道器以及DNS
修改ip位址 即時生效 ifconfig eth0 192.168.1.100 netmask 255.255.255.0 重啟生效 vim etc sysconfig network scripts ifcfg eth0 增加或者修改下面幾行 bootproto static ipaddr 192...
centos7臨時修改IP 永久修改IP
ifconfig eno16777736 192.168.1.101 注意 eno16777736 是預設第乙個網路介面名稱 第一步 檢視網路介面 ifconfig 第二步 去對應的網路介面配置檔案修改配置,注意檔名稱是 ifcfg 預設第乙個網路介面名稱 檔案路徑是 etc sysconfig n...