本文记录了Linux中静态ip设置,并使用xshell进行远程访问,建议先看完全文再按步骤操作

一、 首先修改VM网络配置

1. 打开VMware,找到虚拟网络编辑器

xshell 修改nginx配置_tcp/ip

2. 找到VMnet8

xshell 修改nginx配置_hadoop_02

3. 点击右下角更改设置,再次选择VMnet8

xshell 修改nginx配置_tcp/ip_03

4. 子网ip改为10

xshell 修改nginx配置_tcp/ip_04

5. 点击NAT设置,将网关设为10

xshell 修改nginx配置_tcp/ip_05

xshell 修改nginx配置_xshell 修改nginx配置_06

修改完毕,点击确定

二、修改windows系统网络配置

1. 找到网络适配器设置,找到VMnet8,右键,属性

xshell 修改nginx配置_网络_07

2. 选择ipv4

xshell 修改nginx配置_tcp/ip_08

3. 更改地址

xshell 修改nginx配置_xshell 修改nginx配置_09

三、更改Linux网络设置

1. 首先要确保是在root用户下进行操作,如果不是root用户,可以用命令su root切换为root用户

xshell 修改nginx配置_hadoop_10

2. 编辑网络配置文件

命令vim /etc/sysconfig/network-scripts/ifcfg-ens33

xshell 修改nginx配置_linux_11

3. 将动态ip改为静态ip

xshell 修改nginx配置_linux_12


红框是要修改的内容,蓝框是新添加的内容

staticIPADDR=192.168.10.101

GATEWAY=192.168.10.2

DNS1=192.168.10.2

保存退出

4. 修改主机名称vim /etc/hostname

xshell 修改nginx配置_hadoop_13

保存退出

5. 更改主机名称映射vim /etc/hosts

xshell 修改nginx配置_xshell 修改nginx配置_14

添加以下内容

192.168.10.101 hadoop101
192.168.10.102 hadoop102
192.168.10.103 hadoop103
192.168.10.104 hadoop104
192.168.10.105 hadoop105
192.168.10.106 hadoop106
192.168.10.107 hadoop107
192.168.10.108 hadoop108
192.168.10.109 hadoop109

保存退出

6. reboot重启

启动过程中需要敲回车 ,等待一会儿

7. 选择root用户登录

8. 打开终端,验证一下IP地址和主机名称

xshell 修改nginx配置_hadoop_15


使用ping www.baidu.com看是否能ping通

xshell 修改nginx配置_tcp/ip_16


使用hostname查看主机名称

xshell 修改nginx配置_tcp/ip_17

至此网络配置已经完成,下一步进行远程连接

四、打开xshell

1. 点击文件,新建会话,输入名称

xshell 修改nginx配置_网络_18

2. 点击用户身份验证

xshell 修改nginx配置_xshell 修改nginx配置_19

3. 可自由设置外观

xshell 修改nginx配置_tcp/ip_20

4. 双击会话

xshell 修改nginx配置_hadoop_21

5. 接受并保存

6. 测试一下

xshell 修改nginx配置_linux_22

连接成功

五、修改Windows主机映射

1. 找到C:\Windows\System32\drivers\etc路径

2. 将hosts文件copy到桌面,在里边添加

192.168.10.101 hadoop101
192.168.10.102 hadoop102
192.168.10.103 hadoop103
192.168.10.104 hadoop104
192.168.10.105 hadoop105
192.168.10.106 hadoop106
192.168.10.107 hadoop107
192.168.10.108 hadoop108
192.168.10.109 hadoop109

xshell 修改nginx配置_tcp/ip_23

3. 将修改后的hosts文件与原来的hosts文件进行替换

这样做的原因是我们以后新建会话,可以直接输入主机名创建,不需要输入ip地址

xshell 修改nginx配置_网络_24

xshell 修改nginx配置_网络_25