Jump to content

Bridge connections [solved]


Guest churchnilled
 Share

Recommended Posts

Guest churchnilled

Hi Folks

 

New to these forums but not to linux, formerly running pclinuxos which is a offshoot of mandriva-mandrake anyhoos and currently using Mandriva, Unbuntu, XP Pro & Windows 7 Beta.

 

Ive searched high & low in the forums for my answers but to no avail if my questions have already been answered then i aplogise and would be thankful for link to correct thread.

 

Ok now onto my problems, Im using wifi on this box to connect to router then internet but i also have a LAN card in this box that i bridge with my wifi in XP so my xbox 360 can access XBL.

 

Is it possible to bridge these two connections? I have used the MCC but only option is ICS.

 

So basically have pc connected to net via wifi, have xbox360 plugged into same pc LAN card then bridged in XP and works a charm.

 

Any pointers? Am i just being a complete numpty?

 

Cheers Folks

 

Churchnilled

Link to comment
Share on other sites

I'm not quite really understanding how you got it set up. Let's ignore the XP side, because it confuses things.

 

How many network cards does the PC have?

Is the XBOX connected via cable to the PC?

 

If I'm not mistaken, it sounds like you have the wifi card which is connecting to the router, and you have a standard ethernet card, which is then directly connected to the xbox. At least that's how it sounds, so please correct me if I'm wrong. If so, this is how I picture it:

 

xbox --> cable --> pc --> wireless --> router --> internet

 

But yes, there are bridge utilities in Linux so you can bridge interfaces, and I've done this normally when bridging with interfaces between my PC and virtual machines inside Xen or whatever. But the same process generally applies - so if you can confirm the above, as well as the names of your network interfaces under Linux, that would be cool :)

 

For example, eth0 and wlan0 for example. That's what I have in my machine, but let me know, so we can try and ascertain, as it wasn't clear how you said you got it setup.

Link to comment
Share on other sites

Guest churchnilled

Hi Ian

 

Thanks for the reply and apologises for not making myself clear, throwing xp into the mix is confusing as it has nothing what so ever to do with this.

 

2x network cards in pc, 1x wifi 1x lan,

 

Yes you are correct in the setup, xbox 360 connected to eth0 on pc which i want to bridge with wlan0 on same pc.............. xbox-cable-pc-wifi-router-internet.

 

I have wlan0 set with a static ip the xbox 360 also has a static ip

 

Thanks for your help

Link to comment
Share on other sites

OK, I'm pretty sure you could do two things on this.

 

1. Bridge the cards into the same IP range, and then you'd have connectivity.

2. Assign different IP range to LAN card than the WIFI card and then enable IP routing.

 

For me, the second is the easiest, because I've done it. The first, whilst in theory it should work, I'm not entirely sure as I've not tested it. But you could try, and I'll explain how I think it should work.

 

Bridging the cards

 

Ensure that bridge-utils are installed. You can then use a command called brctl to do many things such as add a bridge, etc. Here is how I just bridged my eth0 with wlan0.

 

root@esprit:/home/ian# brctl show
bridge name	bridge id		STP enabled	interfaces
pan0		8000.000000000000	no

 

shows that I don't have any bridges other than the bluetooth one that was set up on my system already.

 

root@esprit:/home/ian# brctl addbr mybridge
root@esprit:/home/ian# brctl show
bridge name	bridge id		STP enabled	interfaces
mybridge		8000.000000000000	no		
pan0		8000.000000000000	no

 

now you can see I've created a bridge called mybridge, and so now I need to add interfaces:

 

root@esprit:/home/ian# brctl addif mybridge eth0 wlan0
root@esprit:/home/ian# brctl show
bridge name	bridge id		STP enabled	interfaces
mybridge		8000.001a4b65d43e	no		eth0
						wlan0
pan0		8000.000000000000	no

 

now you can see I've added eth0 and wlan0 to "mybridge". Now, you can allocate IP addresses from the same range to the xbox as you would for the wlan0 interface. For example, if I had all this, I would have something like:

 

Internet Router - 192.168.1.1

wlan0 - 192.168.1.2

xbox - 192.168.1.3

 

default router for the xbox would be 192.168.1.1, the same as it is for wlan0, and then of course you just need to supply the same DNS servers that you have for the PC using wlan0, so check /etc/resolv.conf and look for the nameserver lines, and give this IP address in here to the xbox for the DNS.

 

As I said, I don't know if this works, you can try it, but the next step definitely works.

 

Routing

 

Now, another way is with routing, and so what you'd need to do is look inside /etc/sysctl.conf for the following line:

 

net.ipv4.ip_forward = 1

 

if it's set to 0 set it to 1 like above, and then do:

 

sysctl -p

 

to activate the setting, or alternatively, just simply reboot. Now, ensure you have an IP address assigned to eth0 that is different from wlan0. For example, this is how I would do it:

 

xbox: 192.168.2.2

eth0: 192.168.2.1

wlan0: 192.168.1.2

router: 192.168.1.1

 

so that you understand the above, your current internet connection is via the router, which is 192.168.1.1 in my example (of course replace this with your IP that you have for your router). Also, replace my IP for wlan0 with your IP. Then, what you need to do is ensure that the xbox uses a default gateway that points to the IP of eth0, so the default gateway for the xbox in my example is 192.168.2.1. For DNS, you'll have to use whatever you normally use for your PC that has the internet connection (check in /etc/resolv.conf as before). Now, once that's been done, you should be able to ping eth0 and wlan0 from the xbox, but you won't be able to go any further. This is because now, we need to set up iptables to do NAT'ing for us, so ensure you have iptables installed, and then run it by doing:

 

chkconfig iptables on
service iptables start

 

then, do:

 

iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

 

this will ensure that you have source nat set up for the xbox connection, so that it will pass through your PC and go to the internet. Once this is done, you should then be able to ping the internet router, which in my example was 192.168.1.1. And if that works, you should be able to browse the internet!

Link to comment
Share on other sites

Guest churchnilled

Hi Ian

 

Went with the routing method as it looked the quickest but to no avail but could be something i overlooked so will hang on to see if you can see anything obvious before i attempt the other method.

 

Ive given

 

xbox ip 192.168.11.29 subnet 255.255.255.0 gateway 192.168.11.28 dns 192.168.11.1

pc lan ip 192.168.11.28 subnet 255.255.255.0 gateway 192.168.11.1 dns 192.168.11.1

pc wlan ip 192.168.11.27 subnet 255.255.255.0 gateway 192.168.11.1 dns 192.168.11.1

 

Under etc/sysct.conf i could not find the line "net.ipv4.ip_forward = 1" so i inserted as below in # Controls source route verification

 

# Kernel sysctl configuration file for Mandriva Linux

#

# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and

# sysctl.conf(5) for more details.

 

# Disables IP dynaddr

net.ipv4.ip_dynaddr = 0

# Disable ECN

net.ipv4.tcp_ecn = 0

# Controls source route verification

net.ipv4.conf.default.rp_filter = 1

net.ipv4.ip_forward = 1

 

# Do not accept source routing

net.ipv4.conf.default.accept_source_route = 0

 

# Controls the System Request debugging functionality of the kernel

#kernel.sysrq = 0

 

# Controls whether core dumps will append the PID to the core filename.

# Useful for debugging multi-threaded applications.

kernel.core_uses_pid = 1

 

# If you set this variable to 1 then cd tray will close automatically when the

# cd drive is being accessed.

# Setting this to 1 is not advised when supermount is enabled

# (as it has been known to cause problems)

dev.cdrom.autoclose=1

# removed to fix some digital extraction problems

# dev.cdrom.check_media=1

 

# to be able to eject via the device eject button (magicdev)

dev.cdrom.lock=0

net.ipv4.icmp_ignore_bogus_error_responses=0

net.ipv4.conf.all.rp_filter=1

net.ipv4.icmp_echo_ignore_broadcasts=0

net.ipv4.icmp_echo_ignore_all=0

net.ipv4.conf.all.log_martians=1

kernel.sysrq=1

 

 

I ran the commands as per instructions

 

chkconfig iptables on

service iptables start

 

iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

 

I lose wifi connection but xbox does get as fair as connecting to pc

Link to comment
Share on other sites

Hi, for it to work, etho has to be in a different IP range than wlan0, the same for the xbox. You're using the same IP range, which is why it doesn't work. we effectively end up with two different IP ranged networks, and provide routing between the two on the machine, therefore:

 

xbox ip 192.168.11.29 subnet 255.255.255.0 gateway 192.168.11.28 dns 192.168.11.1

pc lan ip 192.168.11.28 subnet 255.255.255.0 gateway 192.168.11.1 dns 192.168.11.1

 

should be:

 

xbox ip 192.168.12.29 subnet 255.255.255.0 gateway 192.168.12.28 dns 192.168.11.1

pc lan ip 192.168.12.28 subnet 255.255.255.0 gateway 192.168.11.1 dns 192.168.11.1

 

since the default gateway for PC LAN is serving the wlan0 interface. You can't route between the same network, since they are in the same range - then you would be using bridging, and not routing!

Link to comment
Share on other sites

Guest churchnilled

Thanks Ian

 

That done the job, i knew it would have to be something i over looked or read wrong i missed the blatantly obvious IP Range change on the LAN & xbox. Doh! I feel a right lemon now, but many thanks for pointing out the errors of my ways :-)

 

Just for educational purposes for myself im going to do the bridge way you described tomorrow as well, always keen to learn new stuff and different methods to get the same outcome (GUI & CLI).

 

Just out of curiosity, when i edited the sysctl.conf & added net.ipv4.ip_forward = 1 as i couldn't find it, i was not sure where to place the line of code as there seemed several different sections in the file, had i placed anywhere else within that file would that also cause problems or is there no relevance to where it was placed?

Link to comment
Share on other sites

Doesn't matter where you place it. It's just a config file with various options for the system. Normally, I tend to group things together, but if I'm just adding one thing, then I generally put it at the bottom of the file so I can find it easily :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...