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

网络安全 2021-07-04 10:23www.168986.cn网络安全知识

 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
        i 192.168.1.106 mask 0xffffff00 broadcast 192.168.1.255
        media: Ether 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
        i6 fe80::1%lo0 prefixlen 64 scopeid 0x3
        i6 ::1 prefixlen 128
        i 127.0.0.1 mask 0xff000000

Freebsd# ifconfig le0 10.0.0.123 mask 255.255.255.0

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

2.永久保留.

打开/etc/rc.conf
加入或修改ifconfig_网卡名称="i x.x.x.x  mask 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 work 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."
ifconfig_lnc0="i 10.0.0.123  mask 255.255.255.0"
keymap="us.iso"
linux_enable="YES"
sshd_enable="YES"
Freebsd#
这种,信息永久保留,修改完需要重启机器。

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

ifconfig_lnc0="i 10.0.0.199  mask 255.255.255.0"
改为

ifconfig_lnc0_alias0="i 10.0.0.198  mask 255.255.255.0"
ifconfig_lnc0_alias1="i 10.0.0.197  mask 255.255.255.0"
 

 

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by