`
ln_ydc
  • 浏览: 266878 次
  • 性别: Icon_minigender_1
  • 来自: 青岛
社区版块
存档分类
最新评论

配置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 lo
iface lo inet loopback

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

auto eth0
iface eth0 inet dhcp

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

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


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

auto eth0
iface eth0 inet static
address 192.168.1.101
netmask 255.255.255.0
gateway 192.168.1.12
#network 192.168.1.0
#broadcast 192.168.1.255


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

auto eth0:1
iface eth0:1 inet static
address 192.168.1.110
netmask 255.255.255.0
gateway 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.com
nameserver 168.95.1.1

 


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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics