[已解决] archlinux ifconfig 设置静态ip怎么保存

其他Linux/Unix/BSD/OSX等发行版讨论
头像
missU
帖子: 1610
注册时间: 2010-03-28 16:16
来自: 你知道么?

[已解决] archlinux ifconfig 设置静态ip怎么保存

#1

帖子 missU » 2012-07-01 13:02

弄了两张网卡,eth0,eth1,eth1 dhcp能获取ip;

代码: 全选

ifconfig
时无法看到eth0;

代码: 全选

ifconfig -a
两张网卡都能看到。

使用

代码: 全选

ifocnfig eth0 up
ifconfig eth0 192.168.5.40 netmask 255.255.255.0
eth0果断ok。局域网也能ping通。
下次启动又需要重新搞,怎么保存起来了?
baidu,google实在是没找到办法。

ps.
系统:archlinux-2011.08.19-core-i686.iso
虚拟机:colinux。
rc.conf中都有设置eth0,eth1
没图形,只有命令。

先谢了
上次由 missU 在 2012-07-01 21:46,总共编辑 2 次。

代码: 全选

shutdown -h now && 睡觉
头像
cuihao
帖子: 4793
注册时间: 2008-07-24 11:33
来自: 郑州
联系:

Re: [新手求助] archlinux ifconfig 设置静态ip怎么保存

#2

帖子 cuihao » 2012-07-01 13:08

rc.conf
求人不如求它仨: 天蓝的Wiki 屎黄的Wiki 绿
Site: CUIHAO.TK    Twitter: @cuihaoleo
Machine: Athlon64 X2 5200+ / 2x2GB DDR2-800 / GeForce GTS 450
AD: ~まだ見ぬ誰かの笑顔のために~
头像
missU
帖子: 1610
注册时间: 2010-03-28 16:16
来自: 你知道么?

Re: [新手求助] archlinux ifconfig 设置静态ip怎么保存

#3

帖子 missU » 2012-07-01 13:15

cuihao 写了:rc.conf
如下:

代码: 全选

interface=eth0
address=192.168.0.11
netmask=255.255.255.0
broadcast=192.168.0.255
gateway=192.168.0.1

interface=eth1
address=
netmask=
broadcast=
gateway=

代码: 全选

shutdown -h now && 睡觉
头像
枫叶饭团
帖子: 14683
注册时间: 2010-06-16 1:05
系统: Mac OS X
来自: Tencent
联系:

Re: [新手求助] archlinux ifconfig 设置静态ip怎么保存

#4

帖子 枫叶饭团 » 2012-07-01 13:19

只是要保存命令?rc.local
头像
cuihao
帖子: 4793
注册时间: 2008-07-24 11:33
来自: 郑州
联系:

Re: [新手求助] archlinux ifconfig 设置静态ip怎么保存

#5

帖子 cuihao » 2012-07-01 13:20

network服务添加到DAEMON里没?
求人不如求它仨: 天蓝的Wiki 屎黄的Wiki 绿
Site: CUIHAO.TK    Twitter: @cuihaoleo
Machine: Athlon64 X2 5200+ / 2x2GB DDR2-800 / GeForce GTS 450
AD: ~まだ見ぬ誰かの笑顔のために~
头像
missU
帖子: 1610
注册时间: 2010-03-28 16:16
来自: 你知道么?

Re: [新手求助] archlinux ifconfig 设置静态ip怎么保存

#6

帖子 missU » 2012-07-01 13:22

cuihao 写了:network服务添加到DAEMON里没?
添加了~~

代码: 全选

shutdown -h now && 睡觉
头像
missU
帖子: 1610
注册时间: 2010-03-28 16:16
来自: 你知道么?

Re: [新手求助] archlinux ifconfig 设置静态ip怎么保存

#7

帖子 missU » 2012-07-01 13:24

枫叶饭团 写了:只是要保存命令?rc.local
没有,我是不想每次都手动ifconfig eth0 设置ip。
在rc.conf中已经设置了eth0为静态ip,但是启动后,用ifconfi看不到eth0,非要手动设置才行。

代码: 全选

shutdown -h now && 睡觉
头像
cuihao
帖子: 4793
注册时间: 2008-07-24 11:33
来自: 郑州
联系:

Re: [新手求助] archlinux ifconfig 设置静态ip怎么保存

#8

帖子 cuihao » 2012-07-01 13:30

哦,俩链接……
rc.conf是shell脚本格式,那样做是不行的,后面的会把前面的覆盖,所以eth0不行。

要么用rc.conf,要么换networkmanager吧。
求人不如求它仨: 天蓝的Wiki 屎黄的Wiki 绿
Site: CUIHAO.TK    Twitter: @cuihaoleo
Machine: Athlon64 X2 5200+ / 2x2GB DDR2-800 / GeForce GTS 450
AD: ~まだ見ぬ誰かの笑顔のために~
头像
枫叶饭团
帖子: 14683
注册时间: 2010-06-16 1:05
系统: Mac OS X
来自: Tencent
联系:

Re: [新手求助] archlinux ifconfig 设置静态ip怎么保存

#9

帖子 枫叶饭团 » 2012-07-01 13:31

你把这几个设置保存到rc.local,就能在开机的时候自动运行设置了嘛
头像
missU
帖子: 1610
注册时间: 2010-03-28 16:16
来自: 你知道么?

Re: [新手求助] archlinux ifconfig 设置静态ip怎么保存

#10

帖子 missU » 2012-07-01 13:36

cuihao 写了:哦,俩链接……
rc.conf是shell脚本格式,那样做是不行的,后面的会把前面的覆盖,所以eth0不行。

要么用rc.conf,要么换networkmanager吧。

暴汗了,当年还能用

代码: 全选

INTERFACES=(eth0 eth1)     
指定两张网卡呢,现在咋不行了。
没networkmanager。
rc.conf怎么弄?
上次由 missU 在 2012-07-01 13:38,总共编辑 1 次。

代码: 全选

shutdown -h now && 睡觉
头像
missU
帖子: 1610
注册时间: 2010-03-28 16:16
来自: 你知道么?

Re: [新手求助] archlinux ifconfig 设置静态ip怎么保存

#11

帖子 missU » 2012-07-01 13:37

枫叶饭团 写了:你把这几个设置保存到rc.local,就能在开机的时候自动运行设置了嘛
实在不行,只能用这个绝招了。哈哈

代码: 全选

shutdown -h now && 睡觉
头像
枫叶饭团
帖子: 14683
注册时间: 2010-06-16 1:05
系统: Mac OS X
来自: Tencent
联系:

Re: [新手求助] archlinux ifconfig 设置静态ip怎么保存

#12

帖子 枫叶饭团 » 2012-07-01 13:39

rc.conf都没有怎么办呢... :em03
头像
missU
帖子: 1610
注册时间: 2010-03-28 16:16
来自: 你知道么?

Re: [新手求助] archlinux ifconfig 设置静态ip怎么保存

#13

帖子 missU » 2012-07-01 13:41

枫叶饭团 写了:rc.conf都没有怎么办呢... :em03
这个有呢。

代码: 全选

shutdown -h now && 睡觉
头像
missU
帖子: 1610
注册时间: 2010-03-28 16:16
来自: 你知道么?

Re: [新手求助] archlinux ifconfig 设置静态ip怎么保存

#14

帖子 missU » 2012-07-01 18:40

google了一个办法。还是翻墙搞到了,不知道行不行。等会下回家试试。
先记录下。

arch的rc.conf配置如下

代码: 全选

 # Use 'ip addr' or 'ls /sys/class/net/' to see all available interfaces.
#
# Wired network setup
#   - interface: name of device (required)
#   - address: IP address (leave blank for DHCP)
#   - netmask: subnet mask (ignored for DHCP) (optional, defaults to 255.255.255.0)
#   - broadcast: broadcast address (ignored for DHCP) (optional)
#   - gateway: default route (ignored for DHCP)
# 
# Static IP example
# interface=eth0
# address=192.168.0.2
# netmask=255.255.255.0
# broadcast=192.168.0.255
# gateway=192.168.0.1
#
# DHCP example
# interface=eth0
# address=
# netmask=
# gateway=

interface=eth0
address=
netmask=
broadcast=
gateway=

interface=eth1
address=192.168.1.111
netmask=255.255.255.0
brodcast=192.168.1.255
gateway=192.168.1.1
配置arch的时候老出现eth0无法自动使用dhcp的情况根据wiki,原来需要修改/etc/rc.local

代码: 全选

#!/bin/bash
#
# /etc/rc.local: Local multi-user startup script.
#
dhcpcd -k eth0
dhcpcd -nd eth0
这样,vitualbox中的arch和freebsd就可以上网和本地链接了.

参考:http://jarodlau.blogspot.com/2011/10/vi ... eebsd.html

代码: 全选

shutdown -h now && 睡觉
头像
missU
帖子: 1610
注册时间: 2010-03-28 16:16
来自: 你知道么?

Re: [新手求助] archlinux ifconfig 设置静态ip怎么保存

#15

帖子 missU » 2012-07-01 21:45

搞不定了,感觉还是用 枫叶饭团 的方法好了。

在/etc/rc.local中加入:

代码: 全选

ifconfig eth1 up
ifconfig eth1 192.168.0.22 netmask 255.255.255.0
感谢两位的回复。
上次由 missU 在 2012-07-01 21:46,总共编辑 1 次。

代码: 全选

shutdown -h now && 睡觉
回复