分页: 1 / 1

求一个 可以 永久修改ip的脚本 就是写文件的那种

发表于 : 2009-09-05 17:21
tianmaxj
求一个 可以 永久修改ip的脚本 就是写文件的那种
谢谢了!!各位

Re: 求一个 可以 永久修改ip的脚本 就是写文件的那种

发表于 : 2009-09-05 17:26
adagio

代码: 全选

#!/bin/bash
ifconfig eth0 192.168.0.10 netmask 255.255.255.0 getway 192.168.0.1
你对付用吧,不用谢

Re: 求一个 可以 永久修改ip的脚本 就是写文件的那种

发表于 : 2009-09-05 17:37
O_O_BOT
irc <fvw_> say: /etc/network/interfaces -> example in /usr/share/doc/

Re: 求一个 可以 永久修改ip的脚本 就是写文件的那种

发表于 : 2009-09-05 17:39
daf3707
adagio 写了:

代码: 全选

#!/bin/bash
ifconfig eth0 192.168.0.10 netmask 255.255.255.0 getway 192.168.0.1
你对付用吧,不用谢
:em04

Re: 求一个 可以 永久修改ip的脚本 就是写文件的那种

发表于 : 2009-09-06 13:11
tianmaxj
adagio 写了:

代码: 全选

#!/bin/bash
ifconfig eth0 192.168.0.10 netmask 255.255.255.0 getway 192.168.0.1
你对付用吧,不用谢
啊!!老大 ifconfig 每次重启都得重新设置啊!
影响效率!!!!

Re: 求一个 可以 永久修改ip的脚本 就是写文件的那种

发表于 : 2009-09-06 14:27
O_O_BOT
O_O_BOT 写了:irc <fvw_> say: /etc/network/interfaces -> example in /usr/share/doc/
:em06

Re: 求一个 可以 永久修改ip的脚本 就是写文件的那种

发表于 : 2009-09-09 10:58
sunsoft1021
#改变ip,如果出错,回滚至原ip地址
chip(){
sed -i "s/$old_ip/$new_ip/" /etc/network/interfaces
/etc/init.d/networking restart &>/dev/null
ping -c 2 www.google.com
if [ $? != 0 ];then
cp ./tmp/interfaces /etc/network/interfaces
/etc/init.d/networking restart &>/dev/null
else
echo "change ip success" >> $old_ip.log
fi
}

Re: 求一个 可以 永久修改ip的脚本 就是写文件的那种

发表于 : 2009-09-09 19:09
BigSnake.NET
LANG=C perl <(zcat /usr/share/doc/ifupdown/examples/generate-interfaces.pl.gz )

Re: 求一个 可以 永久修改ip的脚本 就是写文件的那种

发表于 : 2009-09-09 19:18
mickeywaley

代码: 全选

sudo gedit /etc/network/interfaces

代码: 全选

auto lo
iface lo inet loopback


auto dsl-provider # 开机自动拨号
iface dsl-provider inet ppp
pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf
provider dsl-provider

auto eth0
iface eth0 inet static
address 192.168.1.1  #设置eth0内网地址inet 地址
netmask 255.255.255.0 #设置eth0掩码地址
gateway 192.168.1.254 #设置eth0广播地址

代码: 全选

auto lo
iface lo inet loopback


auto dsl-provider
iface dsl-provider inet ppp
pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf
provider dsl-provider

auto eth0
iface eth0 inet dhcp
#iface eth0 inet static
address 192.168.1.6
netmask 255.255.255.0
gateway 192.168.1.1

代码: 全选

auto lo
iface lo inet loopback


auto dsl-provider
iface dsl-provider inet ppp
pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf
provider dsl-provider

auto eth0
iface eth0 inet static
address 192.168.1.6
netmask 255.255.255.0
gateway 192.168.1.1