Article 5GFKQ How to set gateway for eth0?

How to set gateway for eth0?

by
Creatorczyk
from LinuxQuestions.org on (#5GFKQ)
Hi,

In my file /etc/network/interfaces I declared "eth0" interface like below:

Code:auto eth0
iface eth0 inet static
address 172.16.25.126
netmask 255.255.255.224
gateway 172.16.25.63and later i added line "eth0=eth0" to file "/run/ifstate" and I make execute commands
Code:/sbin/ifdown eth0
/sbin/ifup eth0unfortunately after run "/sbin/ifup eth0" I received error in terminal:
Code:RTNETLINK answers: Network is unreachableError occurs when I have a gateway added to the "/etc/network/interfaces" file (after it has been closed, it disappears)

Code:# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 38:D2:69:7F:87:8C
inet addr:172.16.25.126 Bcast:0.0.0.0 Mask:255.255.255.224
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:175Code:# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.16.25.96 0.0.0.0 255.255.255.224 U 0 0 0 eth0
192.168.100.0 0.0.0.0 255.255.255.252 U 0 0 0 usb0I noticed that the IP for eth0 is wrong

I also tried to set the gateway with a commands:
Code:ip route add default via 172.16.25.63But I again get error:
Code:RTNETLINK answers: Network is unreachableI also try:
Code:route add -net 172.16.25.126 netmask 255.255.255.224 gw 172.16.25.63 eth0but I get:
Code:route: netmask and route address conflictWhat could I do to set gateway for my IP adress.latest?d=yIl2AUoC8zA latest?i=TJRbQnuJZuk:q1Vj-hjaqWI:F7zBnMy latest?i=TJRbQnuJZuk:q1Vj-hjaqWI:V_sGLiP latest?d=qj6IDK7rITs latest?i=TJRbQnuJZuk:q1Vj-hjaqWI:gIN9vFwTJRbQnuJZuk
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments