Ubuntu 14配置网络

一、配置IP地址

通过修改文件/etc/network/interfaces可以设置为DHCP或手动设置静态ip,前面auto eth0是指让网卡开机自动挂载:

root@ccrfox141:/home/ye/xen-4.6.3# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#auto em1
#iface em1 inet static
#	address 172.16.0.141
#	netmask 255.255.0.0
#	network 172.16.0.0
#	broadcast 172.16.255.255
#	gateway 172.16.0.254
	# dns-* options are implemented by the resolvconf package, if installed
#	dns-nameservers 172.20.1.4
#	dns-search test

auto em1
iface em1 inet static
address 172.16.0.141
gateway 172.16.0.254
netmask 255.255.0.0

二、配置DNS

要访问DNS 服务器来进行查询,需要修改设置/et/resolv.conf.d文件:

root@ccrfox141:/home/test# cat /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 172.20.1.4

三、配置路由

root@ccrfox141:/etc# cat rc.local 
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
route add -net 0.0.0.0 netmask 0.0.0.0 gw 172.16.0.135 dev em1

exit 0

重启网络:

sudo /etc/init.d/networking restart



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值