一、配置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