1. VM網(wǎng)絡(luò)設(shè)置
點(diǎn)擊NAT設(shè)置
記住網(wǎng)關(guān)和子網(wǎng)ip秽荞,后面會(huì)用
2. CentOs網(wǎng)絡(luò)設(shè)置
[root@localhost download]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-ens33 ifdown-eth ifdown-post ifdown-Team ifup-aliases ifup-ipv6 ifup-post ifup-Team init.ipv6-global
ifcfg-lo ifdown-ippp ifdown-ppp ifdown-TeamPort ifup-bnep ifup-isdn ifup-ppp ifup-TeamPort network-functions
ifdown ifdown-ipv6 ifdown-routes ifdown-tunnel ifup-eth ifup-plip ifup-routes ifup-tunnel network-functions-ipv6
ifdown-bnep ifdown-isdn ifdown-sit ifup ifup-ippp ifup-plusb ifup-sit ifup-wireless
用vim打開 ifcfg-ens33
修改我圈中的這幾項(xiàng)寝杖,網(wǎng)關(guān)和子網(wǎng)ip與之前一一對(duì)應(yīng)起來。
重啟網(wǎng)絡(luò)模塊
service network restart
3. 檢測(cè)網(wǎng)絡(luò)是否配置成功
ping百度
[root@localhost network-scripts]# ping baidu.com
PING baidu.com (220.181.57.216) 56(84) bytes of data.
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=1 ttl=128 time=18.5 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=2 ttl=128 time=18.7 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=3 ttl=128 time=17.7 ms
查看ip
此命令需要先安裝net工具包yum install net-tools -y
[root@localhost network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.27.132 netmask 255.255.255.0 broadcast 192.168.27.255
inet6 fe80::99b3:c79:5377:c3fe prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:7b:59:07 txqueuelen 1000 (Ethernet)
RX packets 288077 bytes 405462136 (386.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14968 bytes 2189388 (2.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 83 bytes 8297 (8.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 83 bytes 8297 (8.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
更換yum源
安裝vim
yum install vim -y
4. SSH工具連接
安裝openssh-server
yum install openssh-server -y
開放22端口或者關(guān)閉防火墻(二選一)
開放端口
firewall-cmd --zone=public --add-port=22/tcp --permanent
其中:
–zone #作用域
–add-port=80/tcp #添加端口,格式為:端口/通訊協(xié)議
–permanent #永久生效萄传,沒有此參數(shù)重啟后失效
關(guān)閉防火墻
//臨時(shí)關(guān)閉
systemctl stop firewalld
//禁止開機(jī)啟動(dòng)
systemctl disable firewalld
關(guān)閉SELinux
#臨時(shí)關(guān)閉
setenforce 0
#永久關(guān)閉
vi /etc/selinux/config
開始連接
我用的是XShell工具
什么?ssh還連接不上?
在VM里還原默認(rèn)網(wǎng)絡(luò)配置龄句,然后注意把NAT模式的子網(wǎng)ip也對(duì)應(yīng)做修改。