欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

FreeBSD操作系统下修改ip地址及捆定多个IP地址

程序员文章站 2022-06-25 18:07:20
 1.临时更改,即时生效. [root@freebsd7]# ifconfig le0: flags=8843 metric 0 mtu 1500      &n... 08-09-08...

 1.临时更改,即时生效.

[root@freebsd7]# ifconfig
le0: flags=8843<up,broadcast,running,simplex,multicast> metric 0 mtu 1500
        options=8<vlan_mtu>
        ether 00:0c:29:21:2d:a6
        inet 192.168.1.106 netmask 0xffffff00 broadcast 192.168.1.255
        media: ethernet autoselect
        status: active
plip0: flags=108810<pointopoint,simplex,multicast,needsgiant> metric 0 mtu 1500
lo0: flags=8049<up,loopback,running,multicast> metric 0 mtu 16384
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
        inet6 ::1 prefixlen 128
        inet 127.0.0.1 netmask 0xff000000

freebsd# ifconfig le0 10.0.0.123 netmask 255.255.255.0

这种方法即时生效,但是重启机器后,信息不保留。

2.永久保留.

打开/etc/rc.conf
加入或修改:ifconfig_网卡名称="inet x.x.x.x  netmask x.x.x.x"

之后 reboot 或 #sh /etc/rc

freebsd# more /etc/rc.conf

# -- sysinstall generated deltas -- # thu oct 12 09:37:56 2006
# created: thu oct 12 09:37:56 2006
# enable network daemons for user convenience.
# please make all changes to this file, not to /etc/defaults/rc.conf.
# this file now contains just the overrides from /etc/defaults/rc.conf.
defaultrouter="10.0.0.1"
hostname="freebsd.rhel5.com"
ifconfig_lnc0="inet 10.0.0.123  netmask 255.255.255.0"
keymap="us.iso"
linux_enable="yes"
sshd_enable="yes"
freebsd#
这种方法,信息永久保留,但是修改完需要重启机器。

如果要设置多ip地址可用别名方式作修改如下

ifconfig_lnc0="inet 10.0.0.199  netmask 255.255.255.0"
改为

ifconfig_lnc0_alias0="inet 10.0.0.198  netmask 255.255.255.0"
ifconfig_lnc0_alias1="inet 10.0.0.197  netmask 255.255.255.0"