A network client has an ethernet interface configured with an IP address in the subnet 192.168.0.0/24. This subnet has a router, with the IP address 192.168.0.1, that connects this subnet to the Internet. What needs to be done on the client to enable it to use the router as its default gateway?
A. Run route add default gw 192.168.0.1 eth1.
B. Run route add gw 192.168.0.1 eth1.
C. Run ifconfig eth0 defaultroute 192.168.0.1.
D. Add "defaultroute 192.168.0.1" to /etc/resolv.conf.
E. Run route add defaultgw=192.168.0.1 if=eth0.
题解
「route」指令用来显示或是管理 IP 路由表。「ifconfig」指令可以设置网络界面。
选项 A,为正确答案。
选项 B,少了目标(destination or target)。
选项 C,「ifconfig」指令没有「defaultroute」这样的用法。
选项 D,GNU C 语言的函数库会根据「/etc/resolv.conf」设置档所定义的网域名称服务器来查找网域名称实际对应的 IP 地址。可以使用的关键字如下:
- nameserver:要查找的网域名称服务器。
- domain:本地的网域名称。
- search:查找主机名称的时候所串接的网域名称。
- sortlist:排序 gethostbyname 函数的回传结果。
- options
所以「/etc/resolv.conf」设置档也没有「defaultroute」这样的用法。
选项 E,「route」指令用法错误。
