读书人

配置Ubuntu网络参数小结

发布时间: 2013-10-15 16:47:37 作者: rapoo

配置Ubuntu网络参数总结

命令行设置:
===================
1.设置IP
--------------------

sudo ifconfig eth0 192.168.1.101或sudo ifconfig eth0 192.168.1.101 netmask 255.255.255.0或sudo ifconfig eth0 192.168.1.101/24

?
查看IP ifconfig

2.设置网关
--------------------

sudo route add default gw 192.168.1.12

?
查看网关 route 或 route -n

直接修改系统配置文件
===========================
配置文件:/etc/network/interfaces

配置lo
--------------------

auto loiface lo inet loopback

?
配置网卡
--------------------
1.以dhcp方式配置网卡
--------------------

auto eth0iface eth0 inet dhcp

?
使网络设置生效
--------------------

sudo /etc/init.d/networking restart或sudo dhclient eth0


2.以static方式配置网卡
--------------------

auto eth0iface eth0 inet staticaddress 192.168.1.101netmask 255.255.255.0gateway 192.168.1.12#network 192.168.1.0#broadcast 192.168.1.255


3.设定第二个网卡IP地址(虚拟IP地址)
--------------------

auto eth0:1iface eth0:1 inet staticaddress 192.168.1.110netmask 255.255.255.0gateway 192.168.1.110#network x.x.x.x#broadcast x.x.x.x


设置主机名称(hostname)
==========================
1.命令设置主机名称
--------------------

sudo /bin/hostname newname


2.配置文件设置主机名称
--------------------
sudo vi /etc/hostname


配置DNS
==========================
1.简单使用本机的静态查询
--------------------
sudo vi /etc/hosts
添加主机名称和对应的IP地址

2.访问DNS服务器
--------------------
sudo vi /etc/resolv.conf
添加以下内容:

search test.comnameserver 168.95.1.1

?


其他命令
===============
更改MAC地址:
sudo ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx

读书人网 >操作系统

热点推荐