0

I am starting a sub-interface off of my existing eth0, and its supposed to be an instant thing, so I'm trying to avoid using a config file. When I issue:

ifconfig eth0:1 192.168.0.2 up

The interface comes up, and works, but my DNS resolution is lost, and I can't ping anything even say www.google.com, yet I could before the interface was brought up. The configuration for the initial interface is:

[root@server-1 network-scripts]# cat ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="static"
HWADDR="00:50:56:AF:0C:06"
IPADDR="192.168.0.1"
IPV6INIT="yes"
NETMASK="255.255.255.0"
ONBOOT="yes"
TYPE="Ethernet"
DNS1="192.168.2.10"
DNS2="192.168.3.10"

Am I not able to resolve DNS names after I start the sub-interface because they're on the same network?

This is the output of ip addr show

$ ip addr list

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:97:0c:06 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.1/24 brd 10.162.111.255 scope global eth0
    inet 192.168.2.1/30 brd 192.168.2.3 scope global eth0:2
    inet 192.168.2.5/30 brd 192.168.2.7 scope global eth0:3
    inet6 fe80::250:56ff:fe97:c06/64 scope link
       valid_lft forever preferred_lft forever
FilBot3
  • 234
  • 4
  • 18
  • Look at the routing table, befote and after. My guess is that your neglegting to include a mask is trashing your routes. – Zoredache Sep 12 '13 at 15:24
  • I might have just solved this issue as well as my other one, I'm testing some more, I will post my answer in a bit. – FilBot3 Sep 12 '13 at 16:07
  • 1
    BTW, you really should avoid using ifconfig and start learning how to use ip instead. The equivalent command would be ip addr add 192.168.0.2/24 dev eth0. – Zoredache Sep 12 '13 at 16:30
  • What's the added benefit of using that? – FilBot3 Sep 13 '13 at 13:41
  • I used the ip addr add 192.168.02/24 dev eth0 command, and now the ip address is not showing, nor can I use ifconfig eth0:1 192.168.0.2 netmask 255.255.255.0 up command. Tells me: SIOCGIFADDR: Cannot assign requested address SIOCSIFBROADCAST: Cannot assign requested address SIOCSIFFLAGS: Cannot assign requested address and then when i use the command you suggested with up it tells me its garbage. How do I remove the file now since RTNETLINK answers: File exists – FilBot3 Sep 13 '13 at 16:18
  • Use ip addr to list addresses for an interface. As for why. See http://serverfault.com/questions/458628/should-i-quit-using-ifconfig – Zoredache Sep 13 '13 at 17:03
  • Even when I did the ip addr list the interface eth0:1 didn't show up. – FilBot3 Sep 13 '13 at 18:24
  • No it doesn't show up. ifconfig lies to you because it is using a deprecated kernel API. Sub-interfaces are not really interfaces. ip addr correctly reports how the kernel handles additional addresses assigned to an interface. eth0:n is not a separate interface. You need to accept that it isn't another interface, or you will see behaviors you don't understand, because you have invalid expectations. Using ip instead of ifconfig helps understand what is really going on. – Zoredache Sep 13 '13 at 18:29
  • Ok. Sorry for being a pain. I'm reading up on ip right now. – FilBot3 Sep 13 '13 at 18:31
  • Just posted the output of ip addr show – FilBot3 Sep 13 '13 at 19:00
  • What the heck? That is weird. – Zoredache Sep 13 '13 at 19:55

1 Answers1

1

Turns out, in relation to this post, the answer I got that helped fix that issue, also fixed this issue. Instead of just issuing:

ifconfig eth0:1 192.168.0.2 up

I issued the command with a netmask at the end:

ifconfig eth0:1 192.168.0.2 netmask 255.255.255.0 up

and it worked. I can ping any DNS name, traceroute and all that jazz.

FilBot3
  • 234
  • 4
  • 18
  • However, now that I have the ability to ping FQDN names, I cannot access my website provided by the IP I am bringing up. – FilBot3 Sep 16 '13 at 16:05
  • Turns out that there were multiple machines on my network with that same IP, just no FQDN with them. Someone who is running my network is not properly maintaining it. – FilBot3 Sep 20 '13 at 13:08