A network client has an ethernet interface (eth0) 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? (Choose TWO correct answers.)
A.
route add default gw 192.168.0.1 eth0
B.
ifconfig eth0 defaultroute 192.168.0.1
C.
ip route add default via 192.168.0.1 dev eth0
D.
echo defaultroute 192.168.0.1 >> /etc/resolv.conf
E.
route add defaultgw=192.168.0.1 if=eth0
题解
「route」指令用来显示或是管理 IP 路由表。
「ifconfig」指令可以设置网络界面。
「ip」指令可以显示或是管理路由、设备、路由政策和隧道协定。
GNU C 语言的函数库会根据「/etc/resolv.conf」设置档所定义的网域名称服务器来查找网域名称实际对应的 IP 地址。可以使用的关键字如下:
- nameserver:要查找的网域名称服务器。
- domain:本地的网域名称。
- search:查找主机名称的时候所串接的网域名称。
- sortlist:排序 gethostbyname 函数的回传结果。
- options
选项 A,为正确答案。
选项 B,「ifconfig」指令没有「defaultroute」这样的用法。
选项 C,「ip」指令的「route」参数可以用来管理路由表。此为正确答案。
选项 D,「/etc/resolv.conf」设置档也没有「defaultroute」这样的用法。
选项 E,「route」指令没有「defaultgw=」或是「if=」这样的用法。
