The easiest way would be something like this:
- Disable DHCP on eth0, or down the interface (disconnect it in Network Manager, or use
ifdown eth0, etc.)
ip -4 addr add 10.0.0.2/30 dev eth0
ip link set eth0 up
Alternatively, if you prefer the older
ifconfig, I believe that'd be
ifconfig eth0 10.0.0.2 netmask 255.255.255.252 up
Final alternative, if you're using Network Manager (probably the case if you configure your networking using a GUI), set up a profile for eth0 with a static IP address of 10.0.0.2 and a netmask of 255.255.255.252. Leave the default route and DNS servers blank.
After doing any of these, you should be able to ping 10.0.0.1 and also still reach the rest of the Internet.
Why does this work?
(This is a simplification, routing on Linux actually has a lot of optional complexity.) When the kernel wants to send an IP packet, it consults the routing table to determine which interface it sends the packet out of.
The routing table will generally contain a route for the local subnet on each interface. The above commands all put the subnet 10.0.0.0/30 on eth0. A /30 is 4 IP addresses: 10.0.0.0–10.0.0.3 in this case. That conveniently includes your router (.1) and your box (.2). The first (.0 = "network") and last (.3 = "broadcast") addresses in most subnets have a special reserved meaning, so we can't use them.
In addition to the routes for the local subnets, there will be any static routes you've configured, and any routes that come from routing protocols (which doesn't apply to you, or 99% of people).
Finally, there will be a "default" route, which says where to send the rest of the traffic. This route isn't actually special, it's a route for 0.0.0.0/0—that is, the entire IPv4 address space. It is default because of how routing lookups work...
By default, it checks in this order:
- Is it a local IP address (that is, an IP address of this machine)? If so, route it to myself.
- Next, sort all the routes from most-specific (subnet with the fewest IP addresses) to least-specific (subnet with the most IP addresses).
- Go down that sorted list, starting from the top, until something matches.
- If nothing matches, give up and generate unreachable error.
So your 0.0.0.0/0 route is default because it gets sorted to the bottom of the list. And your 10.0.0.0/30 route will be pretty high on the list, if not the very top. Basically it functions as an exception—"send the traffic to the Internet, unless it's for 10.0.0.0/30"
What are these weird /30 things?
/X, sometimes called "CIDR notation", is a quick way to specify netmasks. It counts the number of bits set in the metmask. So a netmask of 255.255.255.255 (single IP) is /32, because all bits are set. …254 (two IPs) is /31, …252 is /30, all the way to 0.0.0.0 (all IPv4 addresses) is /0. The common 255.255.255.0 is /24.