Originally posted by n0xvb
OK I can do that, unfortunately, I didn't ask you what your ifconfig returns (specifically what address is assigned to your eth0 interface), this is the number you'll need to use for the default gateway.
First I would check to see if your system already has a default route defined by running the route command with no parameters. If you see an entry marked as the default gateway and it does not match the address assigned to your eth0 interface, then delete it (I'll use 192.168.2.3 in this example):
So in your case, if your eth0 interface was assigned the IP address: 192.168.1.2 then you would set your default gateway with the following command:
route del default gw 192.168.2.3
You will need to substitute the actual IP address here, and if it was already set correctly, then you would not need to add it again.
#route add default gw 192.168.1.2
The eth0 interface is a standard ethernet network card in your computer, and the cable connects to your hub/switch/router. The ppp0 interface is used by dialup users (sorry I also didn't ask if you were using a dialup connection -- my bad!). To have the ppp0 interface set itself as a default gateway is different. This would be done in the /etc/ppp/options file by uncommenting the "defaultroute" option.
And to be at least somewhat complete, the routing table (what you see when you run the route command) tells your system which network interface to use when sending network traffic. Each line defines a specific IP address or range or addresses. If your system does not know which interface to use (for example I want to look at www.google.com but I don't have 188.8.131.52 in my routing table) then it will send the traffic over the default route.
Hope that helps!
[root@dhcppc0 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:13:20:61:81:1B
inet addr:192.168.1.33 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::213:20ff:fe61:811b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:581 errors:0 dropped:0 overruns:0 frame:0
TX packets:498 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:226277 (220.9 KiB) TX bytes:62004 (60.5 KiB)
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:16436 Metric:1
RX packets:5753 errors:0 dropped:0 overruns:0 frame:0
TX packets:5753 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:7552798 (7.2 MiB) TX bytes:7552798 (7.2 MiB)
[root@dhcppc0 ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
>>>I tried to del gw 192.168.1.1 & add gw 192.168.1.31, but It can't go out.
>>>I checked /etc/ppp/options, there is only "lock", no you mention "defaultroute"?
[root@dhcppc0 ~]# cd /etc/ppp/
[root@dhcppc0 ppp]# ls
chap-secrets ioptions ip-up ipv6-up peers
firewall-masq ip-down ip-up.ipv6to4 options pppoe-server-options
firewall-standalone ip-down.ipv6to4 ipv6-down pap-secrets
[root@dhcppc0 ppp]# cat options