Ubuntu里面设置静态IP地址
来源:互联网 发布:屏幕放大镜软件 编辑:程序博客网 时间:2024/06/06 02:44
由于最近在假设一台GIT server, 所以想把服务器的IP地址设为静态IP。 下面是在ubuntu 13.10的系统下面设为动态和静态IP的方法。
1.设置为静态IP:
如果配置的网卡为 eth0, 则我们打开 /etc/network/interface 文件, 编辑:
$ vim /etc/network/interfaces
auto lo
iface lo inet loopback
#加入下面的eth0的静态IP配置
#Add static IP address for eth0
auto eth0
iface eth0 inet static
address 192.168.1.41
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.2
2.设置为动态IP:
如果配置的网卡为eth0, 则我们打开/etc/network/interface 文件, 编辑:
$ vim /etc/network/interfaces
auto lo
iface lo inet loopback
#加入下面的eth0的动态IP配置
auto eth0
iface eth0 inet dhcp
3. 设置完成后需重启eth0:
方法一:
$ ifconfig eth0 down
$ ifconfig eth0 up
方法二:
$ sudo /etc/init.d/networking restart
如果运行以上这个命令出现下面的提示, 请试方法二:
* Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
* Reconfiguring network interfaces...
或者:
$ sudo service networking restart
4. 配置DNS。注: Ubuntu的系统, dns的配置最多只能有三个, 超过三个的不会生效。
4-1. 如果只需要修改一次, 在/etc/resolv.conf 中加入 nameserver xxx.xxx.xxx.xxx, 配置立即可以生效。 但是由于该文件是动态生成的, 所以系统重启后,新加入的dns就会被覆盖掉。 具体方法如下:
$ vim /etc/resolv.conf
==================================================================
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx
===================================================================
然后保存wq退出即可。
4-2. 需要永久修改的话, 在 /etc/network/interface 中加入dns-nameservices xxx.xxx.xxx.xxx , 然后重启resovlconf就可以了。 然后可以查看 /etc/resolv.conf 是否已经在里面了。 (参看1, 配置静态IP 中的dns-nameservices 部分)
4-3. 修改后让配置生效:
$ sudo /etc/init.d/resolvconf restart
或者
$ sudo resolvconf -u
- Ubuntu里面设置静态IP地址
- ubuntu设置静态ip地址
- ubuntu设置静态ip地址
- ubuntu设置静态IP地址
- ubuntu静态、动态设置ip地址
- Ubuntu下设置静态IP地址
- Ubuntu 虚拟机设置静态IP地址
- ubuntu设置静态IP地址方法
- ubuntu 15.10下设置静态IP地址
- ubuntu修改静态IP、设置dns地址
- ubuntu静态、动态设置ip地址
- Ubuntu 16.04 静态IP地址的设置
- 设置静态IP地址
- ubuntu中设置静态IP和MAC地址,重启不影响
- ubuntu下配置静态IP地址,设置DNS和主机名
- ubuntu环境下静态ip地址设置--重启后仍然有效
- Ubuntu 16.04设置静态IP地址(NAT方式)
- ubuntu 16.04下静态IP地址的设置
- FPGA图像处理项目(四)--二维FFT RapidIO
- Linux与grub下查看各分区设备名称
- 【ORACLE RAC】维护:开机 关机顺序,流程
- 你家我家
- java学习笔记 IO学习笔记1 文件
- Ubuntu里面设置静态IP地址
- apache的默认页如何修改
- 分布式系统设计准则
- Effective C++读书笔记(13)
- Connection reset by peer的常见原因
- static作用(修饰函数、局部变量、全局变量)
- jQuery UI Dialog 模态窗口
- GL音乐播放器--代码实现<七>--实现换肤功能
- Quartus ii中使用testbench文件