Ubuntu server的网络配置,静态IP地址、默认路由以及dns等网络参数配置命令
2015-06-11 00:00
901 查看
摘要: 习惯了桌面版linux系统的图形界面管理工具,管理配置只有shell的linux server版系统,感觉非常茫然,无从下手。把一些常用的网络配置命令收集起来,方便日后查阅。
显示网络配置情况,借此查询网络接口name,一个网卡时,network name 一般是: eth0
临时生效,重启丢失的网络配置命令:
设置静态ip地址
设置缺省路由:
显示路由表:
设置dns,修改 /etc/resolv.conf 保存后立即生效
上述配置的网络环境,是即时生效,重启后失效。或者使用 ip addr flush eth0 ,也可不重启而令配置失效 ip addr flush eth0
禁用和启用网卡命令分别是:
令网络配置信息永久有效,把如下内容编辑到 /etc/network/interfaces 网络配置文件中
其中 dns-search example.com sales.example.com dev.example.com 可以删除不要。
dns-search 的意义是:
上述内容,整理自官方文档 Ubuntu net work configuation
ifconfig -a
显示网络配置情况,借此查询网络接口name,一个网卡时,network name 一般是: eth0
临时生效,重启丢失的网络配置命令:
设置静态ip地址
sudo ifconfig eth0 10.0.0.100 netmask 255.255.255.0
设置缺省路由:
sudo route add default gw 10.0.0.1 eth0
显示路由表:
route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.0.0.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0 0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 eth0
设置dns,修改 /etc/resolv.conf 保存后立即生效
nameserver 8.8.8.8 nameserver 8.8.4.4
上述配置的网络环境,是即时生效,重启后失效。或者使用 ip addr flush eth0 ,也可不重启而令配置失效 ip addr flush eth0
禁用和启用网卡命令分别是:
sudo ifdown eth0 sudo ifup eth0
令网络配置信息永久有效,把如下内容编辑到 /etc/network/interfaces 网络配置文件中
iface eth0 inet static address 192.168.3.3 netmask 255.255.255.0 gateway 192.168.3.1 dns-search example.com sales.example.com dev.example.com dns-nameservers 8.8.8.8 114.114.114
其中 dns-search example.com sales.example.com dev.example.com 可以删除不要。
dns-search 的意义是:
If you try to ping a host with the name of server1, your system will automatically query DNS for its Fully Qualified Domain Name (FQDN) in the following order: server1.example.com server1.sales.example.com server1.dev.example.com If no matches are found, the DNS server will provide a result of notfound and the DNS query will fail.
上述内容,整理自官方文档 Ubuntu net work configuation
相关文章推荐
- VirtualBox四种网络连接简介
- http://www.cnblogs.com/lanxuezaipiao/p/3440471.html
- HttpServlet动态生成网站访问次数的图像
- HTTP下载文件名称编码说明
- vbox下虚拟机同宿主机互相ping,且虚拟机能访问网络的配置
- 黑马程序员——Java基础——网络编程(客户端并发上传图片)
- 实验五 TCP传输及加解密
- 网络工程师第五站-有线、无线同网段混合组网(多FAT案例)
- IEEE会议投稿资料汇总http://cadcg2015.nwpu.edu.cn/index.htm
- Android5.0网络之netd
- Linux 网络概述
- TCP/IP初识
- 实验五Java网络编程及安全——20135337朱荟潼
- HttpServlet动态生成图像
- 一个最简单的通过WireShark破解SSL加密网络数据包的方法
- 写一个程序用来查询手机号码的归属地(使用的是HttpURLConnection的get提交方式)
- [FZYZOJ 2108] 连接网络
- JAVA课程实验报告 实验五 Java网络编程及安全
- http协议中get与post区别详解
- java发送http的get、post请求