3

I need to setup my ubuntu pc single nic card ip as 192.168.1.6 for internet and 10.172.170.95 and 135.10.86.100 for my lan and for another network through my 4port DSL modem.So i defined like this.

Except addition of last two routes(10.0.0.0/8 & 200.200.176.0/24) everything worked as defined, what is the mistake i did?

In /etc/network/interfaces file

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.6
netmask 255.255.255.0
gateway 192.168.1.1

In /etc/rc.local file

/sbin/ifconfig eth0:0 135.10.86.100 netmask 255.255.255.0
/sbin/ifconfig eth0:1 10.172.170.95 netmask 255.0.0.0.0
ip route add 10.0.0.0/8 via 10.172.170.6 src 10.172.170.95
ip route add 200.200.176.0/24 via 135.10.86.176 src 135.10.86.100

after restart, i found

ifconfig output as,

eth0      Link encap:Ethernet  HWaddr 00:11:82:87:12:4b  
          inet addr:192.168.1.6  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::221:85ff:fe96:441b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:760 errors:0 dropped:0 overruns:0 frame:0
          TX packets:576 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:417620 (417.6 KB)  TX bytes:93772 (93.7 KB)
          Interrupt:26 Base address:0xa000 

eth0:0    Link encap:Ethernet  HWaddr 00:11:82:87:12:4b  
          inet addr:135.10.86.100  Bcast:135.10.86.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:26 Base address:0xa000 

eth0:1    Link encap:Ethernet  HWaddr 00:11:82:87:12:4b  
          inet addr:10.172.170.95  Bcast:10.255.255.255  Mask:255.0.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:26 Base address:0xa000 

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:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:240 (240.0 B)  TX bytes:240 (240.0 B)

and route -n as,

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
135.10.86.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
10.0.0.0        0.0.0.0         255.0.0.0       U     0      0        0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eth0
0

1 Answer 1

1

rc.local is not the best place to set up additional NIC aliases and routes.

Just use /etc/network/interfaces for that.

NIC alias example

static routes example

Concerning your problem:

you use an absolute path to the ifconfig tool, but a relative path to the ip tool. Try using an absolute path there too. Find it by using which ip or whereis ip.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .