| Multiple IP adresses for network device |
|
|
| Linux |
|
Q. I am using Ubuntu Linux and I would like to know how to create alias for eth0 so that I can have multiple IP address?
OR sudo /sbin/ifconfig eth0:0 192.168.1.11 up Verify that alias is up and running using following two command(s): /sbin/ifconfig Permanent configurationYour ethernet configuration is located in a file called /etc/network/interfaces. If you reboot system you will lost your alias. To make it permanent you need to add it network configuration file: sudo vi /etc/network/interfaces OR sudo vi /etc/network/interfaces Append the following configuration: auto eth0:0 Save the file and restart system or restart the network: sudo /etc/init.d/networking restart Please note that you can also use graphical tools located at System > Administration > Networking menu. Or use the following GUI tool to setup aliases, hostname, dns settings etc: sudo network-admin If you want more network aliases, use eth0:1, eth0:2, eth0:N (max upto 254). |
| Last Updated on Monday, 28 November 2011 15:30 |


Same here.
Seems to be broken on Ubuntu 11.10
I'm new to linux.
I'm trying to access 2 networks from the same pc with 1 NIC.
Main network:
IP: 192.168.15.30
Mask: 255.255.255.0
Gateway: 192.0168.15.254
Secondary network:
IP: 192.168.1.30
Mask: 255.255.255.0
Gateway: 192.168.1.254
I tried your example:
sudo ifconfig eth0:0 192.168.1.30 up
and it worked fine.
Now I want to make it permanent but I can't figure out what to add to my /etc/network/interfaces file.
auto eth0:0
iface eth0:0 inet static
name Ethernet alias LAN card
address 192.168.1.30
netmask 255.255.255.0
broadcast 192.168.1.254
network 192.168.1.254
Is this correct?
It is not working for me.
Thanks in advance.
Regards,
Rurinho
In /etc/iproute2/rt_tables, add those two at the bottom:
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
1 first
2 second
then, in /etc/rc.local add the following (before exit 0):
EXTIP="`/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`"
EXTMASK="`/sbin/ifconfig eth0 | grep 'mask' | awk '{print $4}' | sed -e 's/.*://'`"
EXTNET="`/sbin/route -n | grep 'eth0' | awk '{print $1}' | sed -e 's/\0\.\0\.0\.0//'`"
EXTGW="`/sbin/route -n | grep 'eth0' | awk '{print $2}' | sed -e 's/\0\.\0\.0\.0//'`"
ip route add $EXTNET/$EXTMASK dev eth0 src $EXTIP table first
ip route add default via $EXTGW table first
ip route add 10.64.99.0/24 dev eth1 src 10.64.99.11 table second
ip route add default via 10.64.99.1 table second
ip rule add from $EXTIP table first
ip rule add from 10.64.99.11 table second
It should work, in theory. (I haven't tested it with variables, I use static IPs in all my setups). If that doesn't work, you'll have to manually replace the variables with IPs. This will give you 2 routes, with access to both external and internal networks.
but my it goes directly to internet... in windows i defined routes so i was able to use both networks at one time.
hope you understand my problem
details for my network is given below:
IP address:10.64.99.11
Subnet MAsk: 255.255.255.0
Gateway : 10.64.99.1
DNS Server : 10.202.103.5
hope you understand my problem
thanks!