设为首页收藏本站language 语言切换
查看: 1464|回复: 2
收起左侧

linux下修改IP、DNS、路由命令行设置

[复制链接]
发表于 2011-7-27 17:54:59 | 显示全部楼层 |阅读模式
ubuntu 版本命令行设置IP

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 eth0
iface eth0 inet static
        address 192.168.1.104
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.2
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 58.22.96.66 218.104.128.106 202.101.138.8
        dns-search .COM

重启网卡: /etc/init.d/networking restatr

redhat linux版本命令行设置IP:

ifconfig eth0 新ip
然后编辑/etc/sysconfig/network-scripts/ifcfg-eth0,修改ip
一、修改IP地址
[aeolus@db network-scripts]$ vi ifcfg-eth0

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=219.136.241.211
NETMASK=255.255.255.128
GATEWAY=219.136.241.254

二、修改网关
vi /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=Aaron
GATEWAY=192.168.1.1

三、修改DNS
[aeolus@db etc]$ vi resolv.conf

nameserver 202.96.128.68
nameserver 219.136.241.206

四、重新启动网络配置
/etc/init.d/network restart
五、例子
1、修改ip地址
即时生效:
# ifconfig eth0 192.168.0.20 netmask 255.255.255.0
启动生效:
修改/etc/sysconfig/network-scripts/ifcfg-eth0
2、修改default gateway
即时生效:
# route add default gw 192.168.0.254
启动生效:
修改/etc/sysconfig/network-scripts/ifcfg-eth0
修改dns
修改/etc/resolv.conf
修改后可即时生效,启动同样有效
3、修改host name
即时生效:
# hostname fc2
启动生效:
修改/etc/sysconfig/network

ps:

DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.8.85

NETMASK=255.255.248.0
GATEWAY=192.168.8.1

HWADDR=00:0uu3:47:2C5:40
ONBOOT=yes
TYPE=Ethernet
发表于 2011-11-25 15:23:45 | 显示全部楼层
顶一下
沙发 2011-11-25 15:23:45 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2011-11-25 15:23:57 | 显示全部楼层
再顶一下
板凳 2011-11-25 15:23:57 回复 收起回复
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2025-5-25 17:10 , Processed in 0.097118 second(s), 24 queries , Redis On.  

  Powered by Discuz!

  © 2001-2025 HH010.COM

快速回复 返回顶部 返回列表