昆明网站建设是什么,简阳网站建设,1006网站建设,喜茶vi设计案例分析pptLinux ifconfig 可以用来配置网络接口的IP地址、掩码、网关、物理地址等#xff1b;值得一说的是用Linux ifconfig 为网卡指定IP地址#xff0c;这只是用来调试网络用的#xff0c;并不会更改系统关于网卡的配置文件。 如果您想把网络接口的IP地址固定下来#xff0c;目前有…Linux ifconfig 可以用来配置网络接口的IP地址、掩码、网关、物理地址等值得一说的是用Linux ifconfig 为网卡指定IP地址这只是用来调试网络用的并不会更改系统关于网卡的配置文件。 如果您想把网络接口的IP地址固定下来目前有三个方法一是通过各个发行和版本专用的工具来修改IP地址二是直接修改网络接口的配置文件三是修改特定的文件加入Linux ifconfig 指令来指定网卡的IP地址比如在redhat或Fedora中把Linux ifconfig 的语名写入/etc/rc.d/rc.local文件中 Linux ifconfig 配置网络端口的方法 Linux ifconfig 工具配置网络接口的方法是通过指令的参数来达到目的的我们只说最常用的参数 Linux ifconfig 网络端口 IP地址 hw HW MAC地址 netmask 掩码地址 broadcast 广播地址 [up/down] 实例一 比如我们用Linux ifconfig 来调试 eth0网卡的地址 [rootlocalhost ~]# Linux ifconfig eth0 down [rootlocalhost ~]# Linux ifconfig eth0 192.168.1.99 broadcast 192.168.1.255 netmask 255.255.255.0 [rootlocalhost ~]# Linux ifconfig eth0 up [rootlocalhost ~]# Linux ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:11:00:00:11:11 inet addr:192.168.1.99 Bcast:192.168.1.255 Mask:255.255.255.0 UP 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 10. collisions:0 txqueuelen:1000 11. RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) 12. Interrupt:11 Base address:0x3400 注解 上面的例子我们解说一下 第一行Linux ifconfig eth0 down 表示如果eth0是激活的就把它DOWN掉。此命令等同于 ifdown eth0 第二行用Linux ifconfig 来配置 eth0的IP地址、广播地址和网络掩码 第三行用Linux ifconfig eth0 up 来激活eth0 此命令等同于 ifup eth0 第四行用 Linux ifconfig eth0 来查看 eth0的状态 当然您也可以用直接在指令IP地址、网络掩码、广播地址的同时激活网卡要加up参数比如下面的例子 [rootlocalhost ~]# Linux ifconfig eth0 192.168.1.99 broadcast 192.168.1.255 netmask 255.255.255.0 up 实例二在这个例子中我们要学会设置网络IP地址的同时学会设置网卡的物理地址MAC地址 比如我们设置网卡eth1的IP地址、网络掩码、广播地址物理地址并且激活它 [rootlocalhost ~]# Linux ifconfig eth1 192.168.1.252 hw ether 00:11:00:00:11:11 netmask 255.255.255.0 broadcast 192.168.1.255 up或[rootlocalhost ~]# Linux ifconfig eth1 hw ether 00:11:00:00:11:22[rootlocalhost ~]# Linux ifconfig eth1 192.168.1.252 netmask 255.255.255.0 broadcast 192.168.1.255 up 其中 hw 后面所接的是网络接口类型 ether表示乙太网 同时也支持 ax25 、ARCnet、netrom等详情请查看 man Linux ifconfig 3.3 如何用Linux ifconfig 来配置虚拟网络接口 有时我们为了满足不同的需要还需要配置虚拟网络接口比如我们用不同的IP地址来架运行多个HTTPD服务器就要用到虚拟地址这样就省却了同一个IP地址如果开设两个的HTTPD服务器时要指定端口号。 虚拟网络接口指的是为一个网络接口指定多个IP地址虚拟接口是这样的 eth0:0 、 eth0:1、eth0:2 ... .. eth1N。当然您为eth1 指定多个IP地址也就是 eth1:0、eth1:1、eth1:2 ... ...以此类推 其实用Linux ifconfig 为一个网卡配置多个IP地址就用前面我们所说的Linux ifconfig的用法这个比较简单看下面的例子 [rootlocalhost ~]# Linux ifconfig eth1:0 192.168.1.251 hw ether 00:11:00:00:11:33 netmask 255.255.255.0 broadcast 192.168.1.255 up或[rootlocalhost ~]# Linux ifconfig eth1 hw ether 00:11:00:00:11:33[rootlocalhost ~]# Linux ifconfig eth1 192.168.1.251 netmask 255.255.255.0 broadcast 192.168.1.255 up 注意指定时要为每个虚拟网卡指定不同的物理地址 在 Redhat/Fedora 或与Redhat/Fedora类似的系统您可以把配置网络IP地址、广播地址、掩码地址、物理地址以及激活网络接口同时放在一个句子中写入/etc/rc.d/rc.local中。比如下面的例子 Linux ifconfig eth1:0 192.168.1.250 hw ether 00:11:00:00:11:44 netmask 255.255.255.0 broadcast 192.168.1.255 up Linux ifconfig eth1:1 192.168.1.249 hw ether 00:11:00:00:11:55 netmask 255.255.255.0 broadcast 192.168.1.255 up 解说上面是为eth1的网络接口设置了两个虚拟接口每个接口都有自己的物理地址、IP地址... ... 3.4 如何用Linux ifconfig 来激活和终止网络接口的连接 激活和终止网络接口的用 Linux ifconfig 命令后面接网络接口然后加上 down或up参数就可以禁止或激活相应的网络接口了。当然也可以用专用工具ifup和ifdown 工具 [rootlocalhost ~]# Linux ifconfig eth0 down [rootlocalhost ~]# Linux ifconfig eth0 up [rootlocalhost ~]# ifup eth0 [rootlocalhost ~]# ifdown eth0 对于激活其它类型的网络接口也是如此比如 ppp0wlan0等不过只是对指定IP的网卡有效。 注意对DHCP自动分配的IP还得由各个发行版自带的网络工具来激活当然得安装dhcp客户端这个您我们应该明白比如Redhat/Fedora [rootlocalhost ~]# /etc/init.d/network start Slackware 发行版 [rootlocalhost ~]# /etc/rc.d/rc.inet1转载于:https://www.cnblogs.com/fanweisheng/p/11109277.html