发布: 更新时间:2022-12-22 00:08:50
1. 打开终端,使用【cd】命令切换工作目录,切换到网络配置目录
interfaces.bak:网卡配置文件的备份
if-down.d if-post-down.d if-pre-up.d if-up.d:是网络关闭前、网络关闭后、网络建立前、网络建立后都会
到/etc/network/里运行相应目录下的脚本
2. 编辑interfaces网卡配置文件,进行eth0静态IP地址修改
vi /etc/network/interfaces
进入插入模式,进行静态IP地址配置
3. 重新启动网络服务,使ip配置生效
/etc/init.d/networking restart
4. 检查ip网络配置是否生效
5. 检查网络连通性【测试相同网段,不同网段之间需要提前添加路由】
1. 按照单网卡网络服务操作步骤,先进行单口网IP配置
2. 创建需要配置子网卡【以eth0为例】,修改配置文件
root@linx:/etc/network # vim interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
gateway 192.168.1.1
pre-up ip addr flush dev $IFACE
auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
address 192.168.2.100
netmask 255.255.255.0
network 192.168.2.0
3.重启网络,检查是否生效
1.查看主机所有(包括没有激活的)网络接口情况
root@linx:/etc/network # ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0c:29:87:8a:9b
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe87:8a9b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:133 errors:0 dropped:0 overruns:0 frame:0
TX packets:113 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:18044 (17.6 KiB) TX bytes:17715 (17.2 KiB)
eth1 Link encap:Ethernet HWaddr 00:0c:29:87:8a:a5
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth2 Link encap:Ethernet HWaddr 00:0c:29:87:8a:af
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:13 errors:0 dropped:0 overruns:0 frame:0
TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:1376 (1.3 KiB) TX bytes:1376 (1.3 KiB)
2. 配置eth1和eth2网卡
注意事项:
3.重启网络,检查是否生效
1.DHCP自动获取IP地址
2.重启网络,检查是否生效
标签:DHCP, DHCP动态IP, Linux, 多物理网卡配置, 子网卡配置, 绑定静态IP