java技术--Linux(Ubuntu)设置静态IP地址

1.通常安装完Ubuntu系统后,通过命令ifconfig获取到的IP都是动态的

(1)动态IP,重新启动系统后IP会变
(2)通过设置静态IP,从而保证每次登陆IP固定
(3)和windows相似
     <1>windows如果设置为自动获取,就是动态IP
     <2>windows如果人为设置一个IP,就不会改变

2.Ubuntu修改静态IP过程如下

(1)先获取网卡名称,输入ifconfig,我的网卡名称为 ens33
(2)修改网卡配置文件:sudo  vim /etc/network/interfaces
(3)修改内容如下
       auto ens33  #网卡名称
       iface ens33 inet static #设置为静态
       address 192.168.0.121 #静态IP地址
       netmask 255.255.255.0 #子网掩码
       gateway 192.168.0.1 #网关
       dns-nameserver 8.8.8.8 #修改DNS配置
(4)wq! 保存退出 root状态下可以不用 ' !  '
(5)重启网络:sudo /etc/init.d/networking restart     
    <1>到此为止就设置好静态IP了
    <2>如果CRT连接报错The remote system refused the connection.  
    <3>可能是没有安装ssh 服务,输入下面命令即可
       命令:$ sudo apt-get install openssh-server
(6)输入 ifconfig 查看ip
    <1>第一次查看是发现IP没有改变
    <2>此时只需要重新启动Ubuntu系统,再次查看就回成功       
发布了178 篇原创文章 · 获赞 11 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq591009234/article/details/104836745