Ifconfig 三大指令与CISCO指令的对应
Ifconfig -a
|
至关于show ip int brief
|
Ifconfig int up/down |
至关于no shutdown |
Ifconfig int address netmask … ifconfig lo 127.0.0.1 |
至关于ip address … |
ifconfig 配地址,注意掩码要有关键字netmask
[root@nm socket]# /sbin/ifconfig eth0:3 192.168.32.8 netmask 255.255.255.0
|
[root@nm socket]# /sbin/ifconfig -a eth0 Link encap:Ethernet HWaddr 00:0C:29:35:74:A1 inet addr:10.4.3.117 Bcast:10.4.255.255 Mask:255.255.0.0 |
一个ifconfig … up的实际应用例子
netstat -nr 看不见接口qfe1的路由,推测多是接口没打开 |
ifconfig -a 确实没看到接口
|
ifconfig -qfe1 up (至关于 no shutdown) |
netstat -nr 能够看见接口qfe1的路由 |
ifconfig le0 up/down和ifconfig le0 plumb/unplumb的区别
$ifconfig le0 up/down 配置网络接口状态
$ifconfig le0 plumb/unplumb 配置网卡起用/停用
为某个接口配多个IP地址---用虚拟接口的方式(实际至关于路由器的secondary地址)
ifconfig eth0 210.34.6.89 netmask 255.255.255.128 broadcast 210.34.6.127
ifconfig
eth0:0 210.34.6.88 netmask 255.255.255.128 broadcast 210.34.6.127
接口不论UP,DOWN,在本地都能PING通
- 无论是直接就没起来(ONBOOT=NO)
- 仍是没接网线
- 仍是接口ifconfig eth0 down
上面三种状况都能PING通eth0 的地址
接口不论UP,DOWN,ifconfig 都看不出区别来
PC有两块网卡(eth0,eth1)
把eth0 进行ifconfig eth0 down
居然还能从外边PING通eth0(10.4.3.135)
其实外边是从eth1 ping进来的。eth0甚至没连网线。
真要把接口DOWN掉,仍是建议用ONBOOT=NO,而后/etc/init.d/network restart
route add ,注意关键字-net和 netmask
[root@osms guan]# /sbin/route add
-net 192.168.1.0
netmask 255.255.255.0 gw 10.4.1.105
route add 的dev关键字和gw关键字
route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
|
route add -net 192.56.76.0 netmask 255.255.255.0 gw 192.56.76.123
|
route del –net 删除路由
route add -net 10.1.1.0 netmask 255.255.255.0 reject 拒绝路由(起过滤的做用)
solaris 下的route add -net
加静态路由
route add -net ... -netmask ... ... route add -net 182.1.1.0 -netmask 255.255.255.0 10.1.0.10 注意,无gw参数
|
加缺省网关
route add -net default ... route add -net default 134.2.250.254 1 (1的意思是1跳)
|
route add只是临时指令,怎么变成稳固指令?
- 用gated.conf ,但gated是一个专门的软件,不必定安装了.
- 用开机启动script:
在etc/rc3.d/中生成一个开机自起script
加入一行route add …
more /etc/rc3.d/S99ROUTE … route add -net 182.1.1.0 -netmask 255.255.255.0 10.1.0.10
|
固然也能够加到rc.local中
经过看log(/var/log/message)有可能看到网口的link up/down #tail -f /var/log/messages Oct 22 07:31:06 FW kernel: eth1: link down Oct 22 07:31:11 FW kernel: eth1: link up, 100Mbps, full-duplex, lpa 0x45E1 Oct 22 07:47:53 FW kernel: eth1: link down Oct 22 07:47:58 FW kernel: eth1: link up, 100Mbps, full-duplex, lpa 0x45E1 Oct 22 07:49:27 FW kernel: eth1: link down Oct 22 07:49:29 FW kernel: eth1: link up, 100Mbps, full-duplex, lpa 0x45E1 Oct 22 11:15:59 FW sshd(pam_unix)[3306]: session opened for user root by root(uid=0)