登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

ideality

@linux c 编程@

 
 
 

日志

 
 
 
 

freebsd7 ip配置  

2010-02-23 15:31:44|  分类: freebsd |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

       安装完freebsd7后,没有配置网络我的配置过程如下:

ee  /etc/rc.conf

ifconfig_rl0="inet 192.168.1.25  netmask 255.255.255.0"   /*其中rl0为网卡的名字,可以使用ifconfig -a 来查看 */

defaultrouter="192.168.1.1"

hostname="myfreebsd"

还要修改DNS地址的配置

ee   /etc/resolv.conf    /*如果没有resolv.conf 这个文件,可以自己创建*/

nameserver  202.112.114.68

nameserver   218.156.157.158

修改完/etc/rc.conf配置后可以通过如下方式生效:

       1.  #sh /etc/rc

        2. # /etc/netstart

        3. 重新启动电脑

 FreeBSD IP 配置总结

                作者: 剑心通明

#####
# 手工指定的方式
################################

# ipconfig fxp0 192.168.8.33/24     # 添加网卡ip
# route add default 192.168.8.1     # 添加路由(也可理解为网关)
立即生效,但是重启后失效。

如何重启后仍然保持呢?
# ee /etc/rc.conf
ifconfig_fxp0="inet 192.168.8.8 netmask 255.255.255.0 "   # fxp0 网卡地址和子网掩码
defaultrouter="192.168.8.10"      # 网关地址
hostname="study.nowire.com.cn"      # 机器名
ifconfig_wi0="inet 192.168.8.55 netmask 255.255.255.0"   # wi0 网卡地址,对应无线网卡

修改 /etc/rc.conf 配置之后可以通过如下方式生效:
第一种方法:# sh /etc/rc
第二种方法:# /etc/netstart
第三种方法:重启机器

#####
# DHCP 方式
################################

在 /etc/rc.conf 中添加:
ifconfig_fxp0="DHCP"
需要根据具体情况指定网卡名称。

修改 /etc/rc.conf 配置之后可以通过如下方式生效:
第一种方法:# sh /etc/rc
第二种方法:# /etc/netstart
第三种方法:重启机器

#####
# 关于 DNS 地址的配置
################################

# ee /etc/resolv.conf
nameserver 202.96.209.133
nameserver 202.96.209.5

#####
# 控制网卡的开关
################################

ifconfig fxp0 up
ifconfig fxp0 down

#####
# 路由方面的配置
################################

查看路由
netstat -rn

添加路由(相当于配置gateway)
route add default 192.168.8.1      # 192.168.8.1为网关地址

如果要修改当前路由配置,需要先删除,再新增一条,当然如果不是同名的,如不是default的可以直接添加
route delete default 192.168.8.1
route add default 192.168.8.10

#####
# DHCP release
################################

# dhclient -r    Release the current lease and exit the client.

Here's a clip of dhclient from the FreeBSD man pages;
"The client normally doesn't release the current lease as it is not required by the DHCP protocol. Some cable ISPs require their clients to notify the server if they wish to release an assigned IP address. The -r flag explicitly releases the current lease, and once the lease has been released, the client exits."
If you are getting kill: xxxx: No such process This means the dhclient process was already stopped

#####
# 指定 interface 通过 dhcp 获取 IP
################################

# dhclient xl0    Starts the dhclient process for interface xl0

I think its a good idea to specify an interface Otherwise you may notice your /var/log/messages filling up with "dhclient: send_packet: Address family not supported by protocol family"

Here's a clip of dhclient from the FreeBSD man pages;
"If no interface names are specified on the command line dhclient will normally identify all network interfaces, elimininating non-broadcast interfaces if possible, and attempt to configure each interface."

#####
# 指定某个 interface 在通过 DHCP 获取不成功的时候,限定一个固定 IP
################################

方法:
在 /etc/dhclient.conf 中添加
alias {
interface "xl0";
fixed-address 192.168.42.40;
option subnet-mask 255.255.255.0;
}

举例:
# ee /etc/dhclient.conf

# $FreeBSD: src/etc/dhclient.conf,v 1.2.2.1 2001/12/14 11:44:31 rwatson Exp $
#
#    This file is required by the ISC DHCP client.
#    See ``man 5 dhclient.conf'' for details.
#
#    In most cases an empty file is sufficient for most people as the
#    defaults are usually fine.
#
alias {
interface "xl0";
fixed-address 192.168.42.40;
option subnet-mask 255.255.255.0;
}

上例的作用是,当 dhclient 不能通过 DHCP server 获取 IP 时,则使用 192.168.42.40 这个固定 IP。

  评论这张
 
阅读(894)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018