更換IP
版本資訊
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
查看ip
[root@localhost ~]# ip a
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:5b:e7:2e brd ff:ff:ff:ff:ff:ff
inet 192.168.1.132/24 brd 192.168.1.255 scope global noprefixroute dynamic ens33
valid_lft 1597sec preferred_lft 1597sec
inet6 fe80::ba16:18eb:ff2a:62f0/64 scope link noprefixroute
valid_lft forever preferred_lft forever
修改IP為靜態并指定IP
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
原檔案:

修改后:

重啟網路
[root@localhost ~]# systemctl restart network
驗證:
[root@localhost ~]# ip a
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:5b:e7:2e brd ff:ff:ff:ff:ff:ff
inet 192.168.1.60/24 brd 192.168.1.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::ba16:18eb:ff2a:62f0/64 scope link noprefixroute
valid_lft forever preferred_lft forever
聯網問題
我這個是自己創建的VMware虛擬機
已經通過網路連接連接到主機網路
但是依舊不能ping外網
[root@localhost ~]# ping www.baidu.com
ping: www.baidu.com: Name or service not known
修改/etc/resolv.conf檔案
添加:
nameserver 114.114.114.114
nameserver 8.8.8.8
重啟網卡
[root@localhost ~]# systemctl restart network
驗證
[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (110.242.68.4) 56(84) bytes of data.
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=1 ttl=128 time=9.95 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=2 ttl=128 time=11.0 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=3 ttl=128 time=9.81 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=4 ttl=128 time=10.0 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=5 ttl=128 time=10.8 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=6 ttl=128 time=12.1 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=7 ttl=128 time=10.7 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=8 ttl=128 time=10.6 ms
^C
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/233967.html
標籤:其他
上一篇:Linux日志分析與安全

